﻿/** DOM-READY ****************************************************************************/
$(document).ready(function(){
	if($('#prev_viewed').length > 0)
        PrevViewedSetup();
});
/////////////////////////////////////Start of ProductLastViewedCookie//////////////////////////////////
	var pfid="";
	var deptid="";
	var producttypeid="";
	function SetLastViewedCookie()
	{
	    var cookieName = 'LastViewedProducts';
		var currentViewedProducts = GetCookie(cookieName);
		var url = document.location.href;		
  		     disectUrl(url);
		
		// get the current product and documentid
		var currentProduct = "";
		if(pfid !="")
			currentProduct = pfid;
		else
			currentProduct ="";	
			
		currentProduct +="#";
		
		if(producttypeid !="")
			currentProduct += producttypeid;
		else
			currentProduct += producttypeid;
		
		currentProduct += "*";
		
		if(deptid !="")
		{currentProduct +=deptid;}
		
		else
			currentProduct +="";
				
		if (currentProduct == null)
  		     {currentProduct = "";}

		if (currentViewedProducts == null)
		     {currentViewedProducts = "";}

		//Ten products
		if (currentViewedProducts.length > 11*50)
		  {currentViewedProducts =popFirstOne(currentViewedProducts);}
		
		var currentViewedProductsList = "";
		currentViewedProductsList = currentViewedProducts.split(',');
		if(currentViewedProductsList != null && currentViewedProductsList.length >11)
		{
		    if (currentViewedProducts.indexOf(currentProduct) == -1)
  		       {currentViewedProducts =popFirstProduct(currentViewedProducts);}
		}
		
		if (currentProduct.length > 4)
		{
			if (currentViewedProducts.length == 0)
			   {currentViewedProducts = currentProduct;}
			else
			{	
				if (currentViewedProducts.indexOf(currentProduct) == -1)
 			   	      {currentViewedProducts = currentProduct+  ','  + currentViewedProducts;}
			}
			var today = new Date();
			var expires_date = new Date(today.getTime() + 30 * 1000 * 60 * 60 * 24);			
			setNoEscapeCookie(cookieName,currentViewedProducts,expires_date);
		}
	}	
	function getCookieVal (offset)
	{
		var endstr = document.cookie.indexOf (";", offset);
		if (endstr == -1)
			endstr = document.cookie.length;
		return unescape(document.cookie.substring(offset, endstr));
	
	}
	function GetCookie (name)
	{
		var arg = name + "=";
		var alen = arg.length;
		var clen = document.cookie.length;
		var i = 0;
		while (i < clen)
		{
			var j = i + alen;
			if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
			i = document.cookie.indexOf(" ", i) + 1;
			if (i == 0) break; 
		}
		return null;
	}
	function setNoEscapeCookie(name, value, expires, path, domain, secure)
	{
		var thisCookie = name + "=" + value +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path :"; path=/") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
		document.cookie = thisCookie;
	}
	function popFirstOne(list)
	{
		var templist=list;
		templist = templist.substr(templist.indexOf(',')+1,templist.length);
		return templist;
		
	}
	function popFirstProduct(list)
	{
		var templist=list;
		templist = templist.substr(0,templist.lastIndexOf(','));
		return templist;
		
	}
	function disectUrl(url)
	{
		var cntQuest=0;
		var cntUrlLen=0;
		var tempurl="";
		var arrWhole = "";
		var arrPart  = new Array();
		var arrDeptid= new Array();
		var arrProductType = new Array();
		var navigator="";
		tempurl=url.toLowerCase();
		cntQuest = tempurl.indexOf('?');
		cntUrlLen = tempurl.length;
		tempurl= tempurl.substr(cntQuest+1,cntUrlLen);
		arrWhole= tempurl.split('&');
		for(i=0;i<arrWhole.length;i++)
		{
			arrPart= arrWhole[i].split('=');
			navigator=arrPart[0];
			switch (navigator)
			{
				case "pfid":
					pfid = arrPart[1];
					break;
				case "deptid":
					deptid = arrPart[1];
				case "producttypeid":
					producttypeid = arrPart[1];				
	}}}
/////////////////////////////////////End of ProductLastViewedCookie////////////////////////////////////
/////////////////////////////////////Start of Products ////////////////////////////////////////////////
/* start - scripts used from ProductVariants controls */
 
  function SelectItemByDefault(ddlSizeId,chkId,hiddenSizeId,hdItemSelect,ddlQtyId)
 {
    var ddlSize = document.getElementById(ddlSizeId);
    var chkBox = document.getElementById(chkId);
    var hiddenSizectrl = document.getElementById(hiddenSizeId);
    var hiddenItemSelect = document.getElementById(hdItemSelect);
    var ddlQty = document.getElementById(ddlQtyId);
    
    if(ddlSize != null )
    {
        if( hiddenSizectrl != null)
        {hiddenSizectrl.value = ddlSize.value;}
           if(chkBox != null && hiddenSizectrl != null)
             {
               if(hiddenSizectrl.value != "0")
                 {
                   chkBox.checked = true;
                    if( hiddenItemSelect != null)
                      {hiddenItemSelect.value = true;}
                       if(ddlQty !=  null)
                        {ddlQty.value = "1";}
       }}}}
 
function SetSizeDropdownDefaultValues(sizedropdownId,qtyDropdownId)
    {
        var sizeDropdown = document.getElementById(sizedropdownId);        
        var quantityDropdown  = document.getElementById(qtyDropdownId); 
        if(sizeDropdown.length == 2)
        { 
            //remove the default "select size" option if only one size and one color available
            sizeDropdown.remove(0);
        }
        quantityDropdown.selectedIndex=1;
    }
     //Helper function to populate color options  for product
    ////sample color option "***15840281|0||1190|One Size|LINEN|$12.99|B***15840283|0||1190|One Size|RUSSET|$12.99|B"
    
     function FillColorDropdownForProduct(colordropdownId,selectedSize,hidSizeValueID)
     {        
        //get color dropdown refernce
        
        var colorDropdown = document.getElementById(colordropdownId);          
        var hidsize = document.getElementById(hidSizeValueID);
         
        if(colorDropdown == null)
        {
            return;
        }        
               
        colorDropdown.length=0;   
        colorDropdown[0] = new Option("Then, Select Color", "0");
        //if size is not yet selected add this default option
        if (selectedSize == "")
        colorDropdown[1] = new Option("Select Size First", "0");
       
        //variable to track if available color option is selected
        var selected = -1;        
        //split the selectedSize option value, it has all the available colors seperated by ***    
        //sample color option "***15840281|0||1190|One Size|LINEN|$12.99|B***15840283|0||1190|One Size|RUSSET|$12.99|B"
        var colorOptions = selectedSize.split("***");                   
       if(colorOptions.length > 0)
       {                              
            for(var index =1; index<colorOptions.length; index++)
            {               
                var optionvalues = colorOptions[index].split("|");                  
                if(optionvalues.length > 0)
                {                   
                    var colorDesc = optionvalues[5];
                    var price = optionvalues[6];
                    var displayOption = colorDesc +" "+price;
                    var newOption = new Option(displayOption, colorOptions[index]);                  
                    colorDropdown[index] = newOption;
                    if(colorOptions[index] == hidsize.value)
                    {                        
                        newOption.selected = true;  
                         selected=1; 		   
                    }
                    //if only one color option is available for the selected size, select that color by default                    
                    if(colorOptions.length ==2)
		            { 
		              newOption.selected = true;  
		              //remove the default option		              
		              colorDropdown.remove(0);		              	             		               
		              hidsize.value = 	colorOptions[1];	
		               //set the tracking variable to 1		                
		                selected=1; 	
		            }
		          
                 }
            }            
            //if no color option is selected reset the hidden variable
             if( selected == -1)
	        {
	            hidsize.value = "0";
    	        
	        }     
       }              
     }
     
 function OnOutfitSubItemSelectionChanged(chkId,hdId )
    { 
         var chkBox = document.getElementById(chkId);
         var hiddenctrl = document.getElementById(hdId);
         
         if(chkBox != null && hiddenctrl != null)
            {hiddenctrl.value = chkBox.checked;}
    }
    
	function ShowPopUPWindow( href )
	{
	    var x = window.open(
	            href,
	            'newwin', 
	            'left=20,top=20,width=620,height=500,menubar=no,toolbar=no,scrollbars=yes,resizable=no,location=no,status=yes '
	            ); 
                x.focus(); 
 }
	function displayMonogramDetail( addmonigramid, monogramdDetailID )
      {
        var checkbox = document.getElementById(addmonigramid);
        var monogramDetail = document.getElementById(monogramdDetailID);
        monogramDetail.style.display = checkbox.checked?"inline":"none";
      }
    
    function OnGiftCardAddMessageSelectionChanged(chkId,hdId,txtSender,txtRecipient,txtMessage)
    { 
         var chkBox = document.getElementById(chkId);
         var hiddenctrl = document.getElementById(hdId);
         var txtSenderCtrl = document.getElementById(txtSender);
         var txtRecipientCtrl = document.getElementById(txtRecipient);
         var txtMessageCtrl = document.getElementById(txtMessage);
         
         if(chkBox != null && hiddenctrl != null)
         {
           hiddenctrl.value = chkBox.checked;
           if(!chkBox.checked)
           {
             if(txtSenderCtrl != null)
                {txtSenderCtrl.value ="";}
             if(txtRecipientCtrl != null)
                {txtRecipientCtrl.value ="";}
             if(txtMessageCtrl != null)
                {txtMessageCtrl.value ="";}       
      }}}

function SetState(textareaId,hdId, chkId)
    { 
        var chkBox = document.getElementById(chkId);
        var hiddenctrl = document.getElementById(hdId);
        var txtCtrl = document.getElementById(textareaId);
          
          if(chkBox != null && hiddenctrl != null && txtCtrl != null)
          {  
                if(!txtCtrl.checked)
                {
                chkBox.checked = true;
                hiddenctrl.value = 'true';
                }
                else
                {
                chkBox.checked = false;
                hiddenctrl.value = 'false';
                }
            }
    }

//////////////////////////////////////End of Products ////////////////////////////////////////////////
//////////////////////////////////////Start of Slideshow /////////////////////////////////////////////

/* UNIVERSAL VARIABLES */

var this_slideshow;                     /* determines which slide show is involved */
var main_image_params = '?wid=269&hei=387&qlt=95&op_sharpen=1" width="269" height="387" />';
var thumb_width = 53;
var thumb_padding = 8;
var thumbnail_params = '?wid=' + thumb_width + '&qlt=95&op_sharpen=1" width="' + thumb_width + '" /></a>';
var swapped;	                        /* position in the array of clicked thumbnail    */
var sliding;	                        /* the timeout object for a slide */
var container_width = 271;
var slider_limit_left = 12;	
var slide_distance = thumb_width + thumb_padding;
var slide_delay = 30;		        	/* delay of the longest slide anim frame */

/* placeholder image for unfetched thumbnails */
var placeholder = nav_base_url + "spacer.gif";

/* misc */
var loop = 0;
var temp; var j = 0;

/* navigation image locations */
var nav_base_url = "http://images.redcatsusa.com/images/site_images/roamans/";
var prev_active = nav_base_url + "rom_slide_show_prev.gif";
var next_active = nav_base_url + "rom_slide_show_next.gif";
var prev_inactive = nav_base_url + "rom_slide_show_prev_off.gif";
var next_inactive = nav_base_url + "rom_slide_show_next_off.gif";
var slideshow_wrapper_div = "";	        /* contents of the script-created slide show container */

/* ARRAYS */
var slide_travel = new Array();	        /* current position during slide */
var main_image_div = new Array();       /* html contents of the main product image's div */
var thumbnails_div = new Array();	    /* html contents of the preview images' div      */

/* thumbnails and nav */
var slider_width = new Array();
var slider_position = new Array();
var slider_limit_right = new Array();
var fp_slider_pos = new Array();        /* floating point position of the slider */
var fetched = new Array();		        /* as per requirements, only three thumbnails
							    	       get loaded with the page. the rest get pulled
							    	       only when the user activates the scroller.    
							    	       toggle: true = load all thumbnails.
							    	       false = load three + placeholders     */
    
/* create a unique slide show for each product */

function setup_slideshow(this_slideshow) {

    slideshow_wrapper_div = "";

	slideshow_wrapper_div +=
	
		'<div id="slideshow_' + this_slideshow + '" class="product-image-wrapper">' +
			'<div id="previewPane_' + this_slideshow + '">' +
				'<div id="alt_main_image_' + this_slideshow + '">' +
					'<!-- placeholder -->' +
				'</div>' +
			'</div>' +
			'<div id="gallery-container_' + this_slideshow + '" class="gallery-container">' +
				'<div id="arrow_left_' + this_slideshow + '" class="arrow_left">' +
					'<a href="javascript:slide_right(' + this_slideshow + ')">' +
						'<!--<asp:Literal ID="litLeft" runat="server"></asp:Literal>-->' +
						'<img src="' + prev_inactive + '" id="arrow_left_image_' + this_slideshow + '" />' +
					'</a>' +
				'</div>' +
				'<div id="arrow_right_' + this_slideshow + '" class="arrow_right">' +
					'<a href="javascript:slide_left(' + this_slideshow + ')">' +
						'<!--<asp:Literal ID="litRight" runat="server"></asp:Literal>-->' +
						'<img src="' + next_active + '" id="arrow_right_image_' + this_slideshow + '" />' +
					'</a>' +
				'</div>'+
				'<div id="slideshow_images_' + this_slideshow + '" class="slideshow_images">' +
					'<div id="alt_thumbnails_' + this_slideshow + '">' +
						'<!-- placeholder -->' +
					'</div>' +
					'<div class="slideEnd"></div>' +
				'</div>' +
			'</div>' +
		'</div><!-- end slide show -->' +
		'<div class="clear"></div>' +
		'\n\n';
	
	document.getElementById("slideshow_wrapper_" + this_slideshow).innerHTML = slideshow_wrapper_div;
	
	/* populate arrays and put the images in the page layout */
	fetched[this_slideshow] = false;
	slide_travel[this_slideshow] = slide_distance;
	fp_slider_pos[this_slideshow] = 12;
	
	refresh_main_image(this_slideshow);
	setup_thumbnails(this_slideshow);
}
	


/* INITIALIZE */

function setup_thumbnails(this_slideshow) {

	/* nav setup */
	if (product_images[this_slideshow].length < 6) {
		/* if there are fewer than the main image and five thumbs, there's 
		   no need for slider navigation or fetching additional thumbs. */
		document.getElementById("arrow_left_" + this_slideshow).style.visibility = "hidden";
		document.getElementById("arrow_right_" + this_slideshow).style.visibility = "hidden";
		fetched[this_slideshow] = true;
	}
	if (product_images[this_slideshow].length < 2) {
		/* if there are no alt images, there's no need for their div. */
		document.getElementById("gallery-container_" + this_slideshow).style.display = "none";
		fetched[this_slideshow] = true;
	}
	
	/* size and position the thumbnail container */
	slider_width = (product_images[this_slideshow].length - 1) * (thumb_width + thumb_padding);
	document.getElementById("slideshow_images_" + this_slideshow).style.width = slider_width + "px";
	slider_position[this_slideshow] = slider_limit_left;
	slider_limit_right[this_slideshow] = container_width - slider_width - thumb_width;
	
	set_slider_position(this_slideshow);
	refresh_thumbnails(this_slideshow);
}



/* FUNCTIONS */

function get_slider_position(this_slideshow) {
	/* get the thumbs container's position without the 'px' */
	slider_position[this_slideshow] = fp_slider_pos[this_slideshow];
}

function set_slider_position(this_slideshow) {
	/* make the thumbs container's position css-friendly */
	slider_position[this_slideshow] = fp_slider_pos[this_slideshow] + "px";
	document.getElementById("slideshow_images_" + this_slideshow).style.left = slider_position[this_slideshow]
}

function slide_left(this_slideshow) {
	/* with the first slide, load any unfetched thumbnails */
	if (!fetched[this_slideshow]) {
		fetched[this_slideshow] = true;
		refresh_thumbnails(this_slideshow);
	}
	
	get_slider_position(this_slideshow);
	
	/* if the thumbs container is in range, and no slide is in progress, go! */ 
	if ((slider_position[this_slideshow] >= slider_limit_right[this_slideshow] + slide_distance) && slide_travel[this_slideshow] == slide_distance) {
		/* if we can slide, we can slide back. turn the other arrow on. */
		document.getElementById("arrow_left_image_" + this_slideshow).src = prev_active;
		
		sliding_left(this_slideshow);
	}
}	

function sliding_left(this_slideshow) {
	get_slider_position(this_slideshow);
	
	/* find the distance to slide */
	if (slide_travel[this_slideshow] < .3) {
		/* the slider is close enough, so finish the slide and reset. */
		fp_slider_pos[this_slideshow] -= slide_travel[this_slideshow];
		set_slider_position(this_slideshow);
		slide_travel[this_slideshow] = slide_distance;
	} else {
		/* continue the slide */
		slide_travel[this_slideshow] *= .5;
		fp_slider_pos[this_slideshow] -= slide_travel[this_slideshow];
		set_slider_position(this_slideshow);
		sliding = setTimeout("sliding_left(" + this_slideshow + ")", slide_delay);
	}
	
	/* if no more sliding can be done, dim the control */
	get_slider_position(this_slideshow);
	
	if (fp_slider_pos[this_slideshow] <= slider_limit_right[this_slideshow] + slide_distance) {
		document.getElementById("arrow_right_image_" + this_slideshow).src = next_inactive;
	}
}

function slide_right(this_slideshow) {
	get_slider_position(this_slideshow);
	
	/* if the thumbs container is in range, and no slide is in progress, go! */ 
	if ((slider_position[this_slideshow] <= slider_limit_left - slide_distance + 1) && slide_travel[this_slideshow] == slide_distance) {
		/* if we can slide, we can slide back. turn the other arrow on. */
		document.getElementById("arrow_right_image_" + this_slideshow).src = next_active;
		
		sliding_right(this_slideshow);		
	}
}

function sliding_right(this_slideshow) {
	get_slider_position(this_slideshow);
	
	/* find the distance to slide */
	if (slide_travel[this_slideshow] < .3) {
		/* the slider is close enough, so finish the slide and reset. */
		fp_slider_pos[this_slideshow] += slide_travel[this_slideshow];
		set_slider_position(this_slideshow);
		slide_travel[this_slideshow] = slide_distance;
	} else {
		/* continue the slide */
		slide_travel[this_slideshow] *= .5;
		fp_slider_pos[this_slideshow] += slide_travel[this_slideshow];
		set_slider_position(this_slideshow);
		sliding = setTimeout("sliding_right(" + this_slideshow + ")", slide_delay);
	}

	/* if no more sliding can be done, dim the control */
	get_slider_position(this_slideshow);
	
	if (fp_slider_pos[this_slideshow] >= slider_limit_left - 1) {
		document.getElementById("arrow_left_image_" + this_slideshow).src = prev_inactive;
	}
}

//this function gets the zoom control href and assigns
// it to onclick event of product main image.
function setMainImageOnClickEvent()
{
    //get the zoom control
    if($("#lnkzoomprod")!=null)
    {
        //get the  zoom control url from hidden field
        var imageurl =$("#lnkzoomprod").val();
        var onclickevent = "ShowPopUPWindow('"+imageurl+"')";
        //get the main image
        if($("#Main_Image_0")!=null)
        {     
            $("#Main_Image_0").click(function() {ShowPopUPWindow($("#lnkzoomprod").val())});              
            $("#Main_Image_0").css("cursor", "pointer");
        }
    }
}

	function ShowPopUPWindow2( href )
	{
	    var x = window.open(
	            href,
	            'newwin', 
	            'left=20,top=20,width=578,height=460,menubar=no,toolbar=no,scrollbars=yes,resizable=no,location=no,status=yes '
	            ); 
                x.focus(); 
	}

function swap_alt_image(this_slideshow,swapped) {
	/* re-order the image array when user clicks a thumbnail.
	   selection replaces the main image and vice-versa. */
	temp = product_images[this_slideshow][0];
	product_images[this_slideshow][0] = product_images[this_slideshow][swapped];
	product_images[this_slideshow][swapped] = temp;	
	refresh_main_image(this_slideshow);
	refresh_thumbnails(this_slideshow);
	setMainImageOnClickEvent();
}

function refresh_main_image(this_slideshow) {
	/* create the new main image's source link */
	main_image_div = '<img id="Main_Image_' + this_slideshow + '" alt="' + eval("product_images_alt_tag_" + this_slideshow) + '"' + '" title="' + eval("product_images_title_tag_" + this_slideshow) + '"'+ ' src="' + product_images[this_slideshow][0] + main_image_params;

	/* replace the old main image */
	document.getElementById("alt_main_image_" + this_slideshow).innerHTML = main_image_div;
}
	
function refresh_thumbnails(this_slideshow) {
	thumbnails_div[this_slideshow] = "";
	/* should > 4 thumbs get fecthed? or use placeholders? */
	if (fetched[this_slideshow]) {
		/* update all thumbnails */
		for (j=1; j<product_images[this_slideshow].length; j++) {
			thumbnails_div[this_slideshow] += '<a href="javascript:swap_alt_image(' + this_slideshow + ',' + j +')">';
			thumbnails_div[this_slideshow] += '<img id="image_' + this_slideshow + '_' + j + '" src="' + product_images[this_slideshow][j] + thumbnail_params;
		}
	} else {
		/* load first four thumbs. the rest get placeholders */
		for (j=1; j<5; j++) {
			thumbnails_div[this_slideshow] += '<a href="javascript:swap_alt_image(' + this_slideshow + ',' + j +')">';
			thumbnails_div[this_slideshow] += '<img id="image_' + this_slideshow + '_' + j + '" src="' + product_images[this_slideshow][j] + thumbnail_params;
		}
		/* here are those placeholders... */
		for (j=5; j<product_images[this_slideshow].length; j++) {
			thumbnails_div[this_slideshow] += '<a href="#">';
				/* need a link so styles will apply */
			thumbnails_div[this_slideshow] += '<img id="image_' + this_slideshow + '_' + j + '" src="' + placeholder + thumbnail_params;
		}
	}
	document.getElementById("alt_thumbnails_" + this_slideshow).innerHTML = thumbnails_div[this_slideshow];
}
////////////////////////////////////////End of Slideshow /////////////////////////////////////////////
////////////////////////////////////////Start of Zoom swatch /////////////////////////////////////////
  function SwitchMenu(obj,imgPath)
{
    var zoomimage = document.getElementById(obj);
    
    if( zoomimage!=null && imgPath !=null && imgPath.length > 1)
    {
        zoomimage.style.visibility  = 'visible'; 
        zoomimage.src=imgPath;
    }
    else
    {zoomimage.style.visibility  = 'hidden';} 
 }
////////////////////////////////////////End of Zoom Swatch //////////////////////////////////////////
/// Tabs ////////////////////////////////////////////////////////////////////////////////////////////
		$(function () {
			var tabContainers = $('div.tabs > div');
			tabContainers.hide().filter(':first').show();
 			  $('div.tabs ul.tabNavigation a').click(function () {
				tabContainers.hide();
				tabContainers.filter(this.hash).show();
			  	 $('div.tabs ul.tabNavigation a').removeClass('selected');
				 $(this).addClass('selected');
				return false;
			}).filter(':first').click();
		});		
/// [END] Tabs /////////////////////////////////////////////////////////////////////////////////////	
/// CR /////////////////////////////////////////////////////////////////////////////////////////////
   function showTabWithScroll(tab1) {
       scrollWindow();
     $('div.tabs ul.tabNavigation a').removeClass('selected');      
     $('#openCR').addClass('selected');
     $("a#openCR:first").click();} 
/// [END] CR ///////////////////////////////////////////////////////////////////////////////////////
/**** PREVIOUSLY VIEWED PRODUCTS *********************************************************/
/** [PVP] Setup **************************************************************************/
function PrevViewedSetup(){
    // Setup Item Count (Don't Count the Controller List Item)
    var pv_item_count = $('ul.pv_items li').length - 1;
    
    if(pv_item_count >= 1){
        // Update 'View All' Link Item Count
        $('#pv_viewall').html('View All (' + pv_item_count + ')');
        // Set The Controller To Open
        $('#pv_display_ctrl').addClass('open');
        // Show The List
        PrevViewedShow();
     }
     
    // Get Previously Viewed Display State From Cookie
    var state = PrevViewedCookieGetState('PreviousViewedProductsState');
    if(state == 'undefined')
        state = true;
    // Set Previously Viewed Display Based On Cookie
    PrevViewedCookieCtrl(state);
}
/** [PVP] Show ***************************************************************************/
function PrevViewedShow(){
    // Show The List
    $('#prev_viewed').css('visibility', 'visible');
}
/** [PVP] Hide ***************************************************************************/
function PrevViewedHide(){
    // Hide The List
    $('#prev_viewed').css('display', 'none');
    // Remove Body Min-Width 
    $('body').css('min-width', '0');   
    $('#container').css('display', 'block');  
    $('#RM_UniversalBrandConnection_Header').css('display', 'block');  
}
/** [PVP] Justify Alignment for low resolution *******************************************/
function AlignLeft(){
    $('#container').css('float', 'left');     
    $('#RM_UniversalBrandConnection_Header').css('float', 'left');     
}
/** [PVP] Display Controller *************************************************************/
function PrevViewedCtrl(){
	if($('#pv_display_ctrl').attr('class') == 'open'){
		// Collapse Previously Viewed Content
		PrevViewedCtrlCollapse();
		// Set Display State Cookie (Closed)
		PrevViewedCookieSetState(false);
	} 
	else if($('#pv_display_ctrl').attr('class') == 'closed'){
        // Expand Previously Viewed Content
		PrevViewedCtrlExpand();
		// Set Display State Cookie (Open)
		PrevViewedCookieSetState(true);
	}
}
/** [PVP] Show Display *******************************************************************/
function PrevViewedCtrlShow(){
    // Enable Display
    $('#prev_viewed .content').css('display', 'block');
	// Change Display Controller Icon
	$('#pv_display_ctrl').removeClass('closed');
	$('#pv_display_ctrl').addClass('open');
	// Manually Change Controller Icon for IE6
	if($.browser.msie && $.browser.version.substr(0,1) < 7)
		$('#pv_display_ctrl').css('background-position', 'top left');
}
/** [PVP] Hide Display *******************************************************************/
function PrevViewedCtrlHide(){
    // Disable Display
    $('#prev_viewed .content').css('display', 'none');
	// Change Display Controller Icon
	$('#pv_display_ctrl').removeClass('open');
	$('#pv_display_ctrl').addClass('closed');
	// Manually Change Controller Icon for IE6
	if ($.browser.msie && $.browser.version.substr(0,1)<7)
		$('#pv_display_ctrl').css('background-position', 'top right');
}
/** [PVP] Expand Display *****************************************************************/
function PrevViewedCtrlExpand(){
    $('#prev_viewed .content').slideDown('normal');
	// Change Display Controller Icon
	$('#pv_display_ctrl').removeClass('closed');
	$('#pv_display_ctrl').addClass('open');
	// Manually Change Controller Icon for IE6
	if($.browser.msie && $.browser.version.substr(0,1) < 7)
		$('#pv_display_ctrl').css('background-position', 'top left');
}
/** [PVP] Collapse Display ***************************************************************/
function PrevViewedCtrlCollapse(){
	$('#prev_viewed .content').slideUp('normal');
	// Change Display Controller Icon
	$('#pv_display_ctrl').removeClass('open');
	$('#pv_display_ctrl').addClass('closed');
	// Manually Change Controller Icon for IE6
	if ($.browser.msie && $.browser.version.substr(0,1)<7)
		$('#pv_display_ctrl').css('background-position', 'top right');
}
/** [PVP] Cookie Controller **************************************************************/
function PrevViewedCookieCtrl(value){
	if(value=='false') // Hide Previously Viewed Content
		PrevViewedCtrlHide();
	else if(value=='true') // Show Previously Viewed Content
		PrevViewedCtrlShow();
}
/** [PVP] Set Cookie State ***************************************************************/
function PrevViewedCookieSetState(pvpState, path, domain, secure){
    var cookieName = 'PreviousViewedProductsState';
    var today = new Date();
    var thisCookie = cookieName + "=" + pvpState +
	((path) ? "; path=" + path :"; path=/") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = thisCookie;
}
/** [PVP] Get Cookie State ***************************************************************/
function PrevViewedCookieGetState(name){
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen){
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}
/**** [END] PREVIOUSLY VIEWED PRODUCTS ***************************************************/
/**** Add to Basket Script ***************************************************************/
 function ShowBagAgain(content) {
   var duration = 2000 ;
   var target = '.placeholderDropdown' ;
   if(IE6) {
     $(target).css('display', 'block');
     $(target).html('<div class="bg_load"><p class="loadPop"><span class="display">Loading...</span></p></div>');
     $(target).html(content);           
     $(".closeBag").click(
        function() {
        $(".placeholderDropdown").css('display', 'none');
     });
   }  else {
     $(target).fadeIn('slow').fadeTo(duration, 1).fadeOut('slow'); 
     $(target).html('<div class="bg_load"><p class="loadPop"><span class="display">Loading...</span></p></div>');
     $(target).html(content);
 }}
/**** [END] Add to Basket Script *********************************************************/
