$(function(){
	var c_data = $.cookie("Etuning_basket");
	if(c_data){
		$('.checkout').show();
		var SumPrice=0;
		var Quantity=0;
		var data = c_data.split('|');
		for(var i=0;data.length>i;i++){
			var each_i = data[i].split(',');
			Quantity += parseFloat(each_i[1]);
			SumPrice += parseFloat(each_i[2])*parseFloat(each_i[1]);
		}
		(Quantity>0)?$('#QItems').html(Quantity+' αντικείμενα |'):$('#QItems').html('Άδειο καλάθι');
		(Quantity>0)?$('.SUMPrice').html('Σύνολο: '+SumPrice.toFixed(2)+'&euro;'):$('.SUMPrice').html('');	
	}else{
		$('.checkout').hide();
	}
});

/*function GetPagename(){
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	return sPage;
}*/
function GetFullPagename(){
	var sPage = window.location.toString().split('/');
	return sPage[sPage.length-1];
}
function GetDir(){
	var sPage = window.location.toString().split('/');
	return sPage[sPage.length-2];
}
function SetLangCookie(lang){
	$.cookie("Etuning_lang", lang, { path: '/', expires: 30});
}
function GetLangCookie(){
	return $.cookie("Etuning_lang");
}
//$.cookie("Exensian_lang", null);// delete cookie
$(function(){
	if(GetDir()!="en"&&GetLangCookie()=="EN")document.location='en/'+GetFullPagename();//if client is not in en but have cookie set to EN redirect
	else if(GetDir()=="en"&&GetLangCookie()=="GR")document.location='../'+GetFullPagename();//if client is in en but cookie set to GR redirect
	
	$('.Gr_flag').click(function(){//greek flag click
		SetLangCookie("GR");
		document.location='../'+GetFullPagename();
	});
	$('.En_flag').click(function(){//En flag click
		SetLangCookie("EN");
		document.location='en/'+GetFullPagename();
	});
});
