
//=================================================
//  start: javascript for video on the hero spot  
//=================================================
		
	//swfobject usage reference: http://code.google.com/p/swfobject/wiki/documentation 
	//define express install swf location
	var expressInstall = js_jspStoreImgDir + 'swf/express_install.swf';
	
	//variables passed to swf
	var flashvars = {};
	flashvars.playerSource = js_staticPath + 'NewPigUSCatalogAssetStore/Attachment/videos/prodVideos/pigMatDurability_02.flv';
	flashvars.playerSkin = js_jspStoreImgDir + 'swf/ClearExternalAll_cm.swf';
	flashvars.videoTitle = "June Homepage - PIG&reg; Mat Durability Video"; //for coremetrics element tag
	
	//params for object element
	var params = {};
	params.menu = "true";
	params.allowfullscreen = "true";
	params.wmode = "transparent";
	params.allowScriptAccess = "always";
	
	//attributes for object element
	var attributes = {};
	attributes.id = "myDynamicContent";
	attributes.name = "myDynamicContent";
	
	$(document).ready(function(){
			try {
				if(document.getElementById('alternate_content'))
				{
					swfobject.embedSWF(js_jspStoreImgDir + 'swf/flvPlayer_360x270.swf', 'alternate_content', '360', '315', '8.0.0', expressInstall, flashvars, params, attributes);
				}
			}
			catch (e){}
		});
		
	var parentPig = window.opener; 
	function gotoSite()
	{
		try
		{
			//focus parent window and close
			parentPig.parentWin.focus();
			window.close();
			return false;
		}
			catch(e)
	{
			//return true so href fires to newpig.com
		return true;
		}
	}
	function callJavascript(msg0,msg1,msg2)
	{
		//console.info(msg0 +' - '+ msg1 +' - '+ msg2);
			if(msg0 == 'cmCreatePageElementTag')
	{
			// Coremtrics Element tag to capture info from flash. cm js libraries should already be on page
			try{cmCreatePageElementTag(msg1,msg2);}catch(e){}
			}			}
		
//=================================================
// end: javascript for video on the hero spot
//=================================================


//=====================================================================
//  start: javascript for jquery cycle slideshow on the hero spot  
//=====================================================================
	// uk hero
	$(document).ready(function() {
		if(document.getElementById('slideshow'))
		{
			$('#slideshow')
				.after('<div id="nav">')
				.cycle({ 
					fx:     'fade', 
					speed:  '800', 
					timeout: 7000, 
					pager:  '#nav',
					pause: 1
				});
			$('a.pause').click(function() {
				if($(this).hasClass('pause'))
				{
					$('#slideshow').cycle('pause');
					$(this).removeClass('pause');
					$(this).addClass('resume');
				}
				else
				{
					$('#slideshow').cycle('resume');
					$(this).removeClass('resume');
					$(this).addClass('pause');
				}
			});
		}

		// us/fd/ca/ot hero
		if(document.getElementById('hero_july_wiper'))
		{
			$('#hero_july_wiper')
				.cycle({ 
					fx:     'fade', 
					speed:  '800', 
					timeout: 7000, 
					pager:  '#tabs_hero',
					pause: 1
				});
		}
			
		// august hero uk
		if(document.getElementById('hero_august_uk'))
		{
			$('#hero_august_uk')
				.cycle({ 
					fx:     'fade', 
					speed:  '800', 
					timeout: 5000,
					cleartypeNoBg: true,
					pause: 1
				});
		}
		// september hero uk
		if(document.getElementById('hero_september_uk'))
		{
			$('#hero_september_uk')
				.cycle({ 
					fx:     'fade', 
					speed:  '800', 
					timeout: 5000,
					cleartypeNoBg: true,
					pager: '#nxtimg',
					pause: 1
				});
		}
		
	});
	function setObjVis(slideshow,vis) {var objs = document.getElementById(slideshow).style; document.getElementById(slideshow); objs.visibility = vis;}
	function start() {
		try{setObjVis('slideshow','visible')}catch(e){};
		try{setObjVis('hero_july_wiper','visible')}catch(e){};
		try{setObjVis('hero_august_uk','visible')}catch(e){};
		try{setObjVis('hero_september_uk','visible')}catch(e){};
	}
	window.onload = start;



//=====================================================================
//  end: javascript for jquery cycle slideshow on the hero spot  
//=====================================================================



//=================================================
// start: jcarousel jquery plugin init
//=================================================

	/**
	 * We use the initCallback callback
	 * to assign functionality to the controls
	 */
/*
	function mycarousel_initCallback(carousel) {
	    jQuery('.jcarousel-pagination a').bind('click', function() {
	        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr('title')));
			carousel.startAuto(0);
			$('.jcarousel-playpause a').removeClass('pause');
			$('.jcarousel-playpause a').addClass('play');
	        return false;
	    });
		
		//playpause button
		$('.jcarousel-playpause a').bind('click', function() {
			if($(this).hasClass('play'))
			{
				carousel.next();
	        	carousel.startAuto(7);
				$(this).removeClass('play');
				$(this).addClass('pause');
			}
			else
			{
				carousel.startAuto(0);
				$(this).removeClass('pause');
				$(this).addClass('play');
			}
				
	    });
	};
*/
	/**
	 * This is the callback function which receives notification
	 * when an item becomes the first one in the visible range.
	 */
/*
	function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
	    //console.info('Item #' + idx + ' is now the first item');
		
		//var matchedElement = '.jcarousel-control a:eq('+idx+')'
		
		$('.jcarousel-pagination a').removeClass('active');
		$('.jcarousel-pagination a:eq('+ (idx - 1) +')').addClass('active');
	
	};
*/	
	
	// Ride the carousel...
/*
	jQuery(document).ready(function() {
	    jQuery("#mycarousel").jcarousel({
	        scroll: 1,
			visible: 1,
	        initCallback: mycarousel_initCallback,
	        auto: 7,
			animation: 'normal',
			wrap:'last',
			buttonNextHTML:'',
			buttonPrevHTML:'',
			itemFirstInCallback: mycarousel_itemFirstInCallback
		});
	});
	function setObjVis(spccTable,vis) {var objs = document.getElementById(spccTable).style; document.getElementById(spccTable); objs.visibility = vis;}
	function start() {
		try{setObjVis('spccTable','visible')}catch(e){}
	}
	window.onload = start;
*/	
//=================================================
// end: jcarousel init
//=================================================


//=================================================
// start: CachedHomeProductCategories.jsp Accordian
//=================================================	

$(document).ready(function(){
    $("#accordion").accordion();
    
    $(".hoverover").hover(function () {
    	var thishref= $(this).attr("href");
        $(thishref).fadeIn(500);
      }, 
      function () {
        var thishref= $(this).attr("href");
        $(thishref).fadeOut(500);
      }
    );
    
  });	
	
//=================================================
// end: CachedHomeProductCategories.jsp Accordian
//=================================================	