// JavaScript Document

//set as homepage
function setHomepage()
{
    if (document.all)
    {
        document.body.style.behavior='url(#default#homepage)';
        document.body.setHomePage('http://www.capitalfm.co.ke');
    }
    else if (window.sidebar)
    {
        if(window.netscape)
        {
            try
            {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch(e)
            {
                alert("this action was aviod by your browser，if you want to enable，please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");
            }
         }
         var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
         prefs.setCharPref('browser.startup.homepage','http://www.capitalfm.co.ke');
     }
}



//main nav

function getLeaf(url) {
 var splited=url.split('?');// remove all the parameter from url
 url=splited[0];
 return url.substring(url.lastIndexOf("/")+1);// return file name without domain and path
} 

jQuery.fn.extend({
 enter: function() {//plugins creation
     return this.each(function() {
       var pth = $(this).find("img")[0];
	   //alert($(this).children().attr("href"));
	    if($(this).children().attr("href")==getLeaf(document.location.href)){// check that the link url and document url is same
           $(pth).attr("src",pth.src.replace(/.jpg/g, '_active.jpg'));
		 } else{
               $(this).hover(function(){
                  $(pth).attr("src",pth.src.replace(/.jpg/g, '_active.jpg'));// mouse over Image
                  },function(){
                      $(pth).attr("src",pth.src.replace(/_active.jpg/g, '.jpg'));// mouse out image
                      });
               }
               });
     }
});
$(function(){  // Document is ready
 $("#nav td").enter();// call the function
});


var myimages=new Array()
function preloadimages(){
for (i=0;i<preloadimages.arguments.length;i++){
myimages[i]=new Image()
myimages[i].src=preloadimages.arguments[i]
}
}
//Enter path of images to be preloaded inside parenthesis. Extend list as desired.
preloadimages("pics/menu/home_active.jpg","pics/menu/who_active.jpg","pics/menu/portfolio_active.jpg","pics/menu/advertise_active.jpg","pics/menu/talk_active.jpg")


/*mainslide
 $(function() {
        $("div#controller").jFlow({
            slides: "#slides",
            width: "929px",
            height: "421px",
			autoplay: "true",
		easing: "easeIn",
		duration: 1200

        });
    });
 

 
 $(document).ready(function(){
	    $("#controller").jFlow({
        slides: "#slides",  // the div where all your sliding divs are nested in
        controller: ".jFlowControl", // must be class, use . sign
        slideWrapper : "#jFlowSlide", // must be id, use # sign
        selectedWrapper: "jFlowSelected",  // just pure text, no sign
        width: "929px",  // this is the width for the content-slider
        height: "421px",  // this is the height for the content-slider
        duration: 800,  // time in miliseconds to transition one slide
        prev: ".jFlowPrev", // must be class, use . sign
        next: ".jFlowNext", // must be class, use . sign
		auto: true
			
    });
});
 */

 
 
 //testimonials
 
 	$(document).ready(function(){
				
				$('.ezjax').ezjax({	
					container: '#testimonial',
					initial: '1.html',
					effect: 'slide',
					easing: 'easeInBounce',
					bind: 'a'
				});
				
			});
