
var slideOutName = "#slideoutContainer";   
var slideOutMenuYloc = null;	

$(document).ready(function() {
						   
	//************************************************************
	// floating coupon slider event handler
	// requires dimensions.js plugin
	//************************************************************
	
		// get initial positioning of slideout menu
	slideOutMenuYloc = parseInt($(slideOutName).css("top").substring(0,$(slideOutName).css("top").indexOf("px")))
	//event listerner for scroll
	$(window).scroll(function () { 
		//get the amount of scroll on window
		offset = slideOutMenuYloc+$(document).scrollTop();
		//subtract 170 from the offset because the panel needs at least that much 
		//to display entire panel in 1024x768 window
		offset=offset-170;
		//check if the offset is larger than the initial position of slideout menu
		if(offset>slideOutMenuYloc){
			//if new scrolled position larger the initial psoition use the new offset value
			offset = offset + "px";
		} else {
			//new scolled position not larger than initial position so use the initial position
			offset = slideOutMenuYloc + "px";
		}
		//float the slidemenu to new position
		$(slideOutName).animate({top:offset},{duration:500,queue:false});
		$('#slideoutTab').addClass("slideActive");
	});
	//************************************************************
	// animate action for slideout reengergize menu
	//************************************************************
	$('#slideoutTab a').toggle(function() {
		$(this).addClass("clicked");
		$('#slideoutContainer').animate({left:'0px'}, {queue:false, duration: 500});
		
		//Anil edition - Fade in Background
		$('#product-detail-video').addClass("hide");
		
        $('body').append('<div id="coupon-promotions-fade"></div>'); //Add the fade layer to bottom of the body tag.
        $('#coupon-promotions-fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 

		return false;
	}, function() {
		$(this).removeClass("clicked");
		$('#slideoutContainer').animate({left:'-400px'}, {queue:false, duration: 500});	
		
		//Anil edition - Fade out Background
		$('#product-detail-video').removeClass("hide");
		
		$('#coupon-promotions-fade').fadeOut(function() {
            $('#coupon-promotions-fade').remove();  //fade them both out
        });	
        
		return false;
	});
	//************************************************************
});


