$(document).ready(function() {

    if ($("#pageName").length > 0) {
        topNavStatus($("#pageName").val());
    }
  /*  if ($("#homeImage").length > 0) {
        i = 0;
        fancyImage();
        window.setInterval(function() {
            fancyImage();
        }, 5000);
    }*/

    if ($("#himages").length > 0) {
        j = 0;
        fancyImagetop();
        window.setInterval(function() {
            fancyImagetop();
        }, 4000);
    }

   /* if ($("#rhsimage").length > 0) {
        k = 0;
        fancyImagerhs();
        window.setInterval(function() {
            fancyImagerhs();
        }, 4500);
    }*/
    $('#slideshow1').cycle()
    $('#rhsimage').cycle()
    $("a.galleryThumb").fancybox();
}
);

function topNavStatus(currentSection) {
    $(".sf-menu li").each(function(i) {
        valueToCheck = $("a", this).eq(i).text();
        //console.log(valueToCheck);
        if (valueToCheck == currentSection) {
            $("a", this).addClass("current");
        }
    });
}


function fancyImage(){
	/* 
		Title: FancyImageCycle
		Description: Image cycler with mouseover text
		Author: IPAG (Ireland) Ltd. KG
		Version: 0.2
	*/
	
	imageArray = [
		'url(\'images/template/forsurface1.jpg\')',
		'url(\'images/template/forsurface2.jpg\')',
		'url(\'images/template/forsurface3.jpg\')',
		'url(\'images/template/forsurface4.jpg\')'
	];
	
	linkArray = [
		'#1',
		'#2',
		'#3',
		'#4'
	];
	
	$("#homeImage").show(800, function(){
	    $("#homeImage").css("background-image", imageArray[i]);
		$("#homeImage").fadeIn(800, function(){
		//$("#homeImageText").animate({bottom: '-340'}, 300);
			//check with differeing images
		});
		i++;
		if(i >= 5){ i = 0;}
	});
}


function fancyImagetop() {
    /* 
    Title: FancyImageCycle
    Description: Image cycler with mouseover text
    Author: IPAG (Ireland) Ltd. KG
    Version: 0.2
    */

    imageArrayt = [
		'url(\'images/template/Top_01nb.png\')',
		'url(\'images/template/Top_02nb.png\')',
		'url(\'images/template/Top_03nb.png\')',
		'url(\'images/template/Top_04nb.png\')'
    ]
    textArrayTag = [
        'Pioneering Surfaces For Competitive Advantage',
        'Ultimate Surfaces For The Most Challenging Of Applications',
        'Chemically Bonded Surfaces - Why Settle for Mechanical Bonding',
       
    ]
   

    $("#tagline").fadeOut(500, function() {
    //$("#himages").css("background-image", imageArrayt[i]);
    $("#tagline").html( textArrayTag[j]);
        $("#tagline").fadeIn(500, function() {
            //$("#homeImageText").animate({bottom: '-340'}, 300);
        });
        j++;
        if (j >= 3) { j = 0; }
    });
}

function fancyImagerhs() {
    /* 
    Title: FancyImageCycle
    Description: Image cycler with mouseover text
    Author: IPAG (Ireland) Ltd. KG
    Version: 0.2
    */

    imageArrayr = [
		'url(\'http://devserver06/enbio/images/template/Application-Banner_01.png\')',
		'url(\'http://devserver06/enbio/images/template/Application-Banner_02.png\')',
		'url(\'http://devserver06/enbio/images/template/Application-Banner_03.png\')',
		'url(\'http://devserver06/enbio/images/template/Application-Banner_04.png\')',
		'url(\'http://devserver06/enbio/images/template/Application-Banner_05.png\')',
		'url(\'http://devserver06/enbio/images/template/Application-Banner_06.png\')'
		//reconfigure urls for live site!
    ]
    
    linkArrayr = [
        '#Aerospace',
        '#Automotive',
        '#Industrial',
        '#Medical',
        '#Oil and Gas',
        '#Space'
    ]
    

    $("#rhsimage").fadeOut(500, function() {
    $("#rhsimage").css("background-image", imageArrayr[k]);
    $("#rhsimagelink").attr("href", linkArrayr[k]);
        $("#rhsimage").fadeIn(500, function() {    
        });
        k++;
        if (k >= 6) { k = 0; }
    });
}

