var $j = jQuery.noConflict(); 



function getCookie(c_name)
{
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));
    }
  }
return "";
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toUTCString())+"; path=/";
}

function checkCookie()
{
	lang=getCookie('store');
	if (lang!=null && lang!="")
	  {
	  return true;
	  }
	else
	  {
	  return false;
	  }
}
///////////////// JQUERY RUNS FROM HERE /////////////////////////////////////
$j(document).ready(function(){ 
	$j('#features').jshowoff({ speed:3000, links: false, controls: false }); 
	
	if(checkCookie()) return;
	var id = "#lngDialog";
	
		//Get the screen height and width
		var maskHeight = $j(document).height();
		var maskWidth = $j(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$j('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$j('#mask').fadeIn(200);	
		$j('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $j(window).height();
		var winW = $j(window).width();
              
		//Set the popup window to center
		//$j(id).css('top',  winH/2-$j(id).height()/2-150);
		$j(id).css('top',  50);
		$j(id).css('left', winW/2-$j(id).width()/2);
	
		//transition effect
		$j(id).fadeIn(200); 
		
		//if french is clicked
	$j('#french').click(function () {
		setCookie("store", "fr", 180);
		location.href='http://clubecoplus.com/webstore/fr';
		$j('#mask').hide();
		$j('#lngDialog').hide();
	});	
	
	//if english is clicked
	$j('#english').click(function () {
		setCookie("store", "en", 180);
		location.href='http://clubecoplus.com/webstore/en';
		$j('#mask').hide();
		$j('#lngDialog').hide();
	});		
	
});
