// Copyright S.Boylen 2008


/**
*  Saves the url of the last 5 pages visited, to help people nav back to them
*/
function breadCrumbs(urlAddress)
{
	try
	{
		
	var url = new Array();
	
	url[0] = getCookie('url0');
	url[1] = getCookie('url1');
	url[2] = getCookie('url2');
	url[3] = getCookie('url3');
	url[4] = getCookie('url4');
	url[5] = getCookie('url5');
	
	var j = -1;
	
	for (var i = 0; i <= 5; i++)
	{
		  if (url[i].length == 0)
		  {
				 if (i == 5){
					 j = 5;
					 i = 0;
				 }else{
					 j = i;
					 i = i+1;
				 } 
				 
				 break;
		  }
	}
	
	if (j != -1)
	{
	    setCookie('url' + j,urlAddress,14);	
	    setCookie('url' + i,'',14);	//blank next value	
	}
	
  }catch(e){
	  alert(e);
	  
  }
}


function setCookie(c_name,value,expiredays)
{
	try
	{
     var exdate=new Date();
     
     exdate.setDate(exdate.getDate()+expiredays);
     
     document.cookie=c_name+ "=" +escape(value)+
        ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
    }
    catch(e)
    {
	    //alert(e);    
    }
}

function getCookie(c_name)
{
	try
	{
	  if (document.cookie.length>0)
	  {
	    c_start=document.cookie.indexOf(c_name + "=");
	    if (c_start!=-1)
	    { 
	        c_start=c_start + c_name.length+1; 
	        c_end=document.cookie.indexOf(";",c_start);
	        if (c_end==-1) c_end=document.cookie.length;
	        return unescape(document.cookie.substring(c_start,c_end));
	    } 
	  }
    }catch(e){
	    //alert(e);
    }
	  
	return "";
}



//J-Query [http://docs.jquery.com/]
$(document).ready(
function()
{
	         
    //$("#jquery_ani").fadeOut(3000,fadeTo100);

     function fadeTo100()
     {
	     $("#jquery_ani").fadeIn(4000,fadeToZero);
     }
     
     function fadeToZero()
     {
	     $("#jquery_ani").fadeOut(4000,fadeTo100);
     }
     
     $("#product_table a").click(JQPopupwindow);
     
     function JQPopupwindow()
	  {
	      
	      l_url = $(this).attr("title");
	      l_urlArray = $(this).attr("href").split("?");                  
	      
	      if (l_urlArray.length > 0)
	      {
	          
	          l_qsArray = l_urlArray[1].split('&');		              
	          l_value   = l_qsArray[0].split('=');
	          
	          $("#divObj").addClass("hidden_div").load("productpopup.php?" + l_urlArray[1]);  
			   //set the pop-up's title
	          $("#divObj").attr("title",l_url);
	          $("#divObj").removeClass("hidden_div").dialog({ 
			    	modal: true, 
				    overlay: { 
				    opacity: 0.5, 
				    background: "black" 
				    },
				    height:500,
				    width:660
			    }); 
			    
			    return false; 
		  }
	  }
     
     
});


