//////////////////////////////////////////////////////////////
//Banner
//////////////////////////////////////////////////////////////
function anxChgLang(lang)
{   		
	if (lang != 'en' && lang != 'pl' && lang != 'de' && lang != 'fr' && lang != 'es')
		lang = 'en';
		
	eraseCookie("anxlang");	  
	
	ToDay=new Date(); 
    ToDay.setTime(Expires = (24*60*60*1000*365) + ToDay.getTime()); 
    Expires= (ToDay.toGMTString()); 
    document.cookie= "anxlang=" + lang + "; expires="+Expires; 

    var loc = window.location.pathname;	
	cmd = false;
	
	commands = ['LOT_IBE_ContactSave','LOT_IBE_AccessSave','LOT_IBE_AddressSave','LOT_IBE_PassengerSave','LOT_IBE_PaymentSave',
	'Command_LOT_IBE_ZapiszDoProgramu','Command_LOT_IBE_PrzypomnijHaslo','Command_LOT_IBE_PrzypomnijHasloZmien','Command_LOT_IBE_UsunProfil','Book'];
	locat = '';
	location.replace('/Schedule2/'+lang+'/Start.aspx?_lang='+lang)
	//try{locat = document.Language._cmd.value;}
/*	catch(e){}	
	
	for(i = 0; i < commands.length; i++)
		{					
			if(locat.indexOf(commands[i]) != -1)
				cmd = true;
		}
   
	if(findBannerCookie("country"))
	{
		var newCountry = findBannerCookie("country");
		eraseCookie("country");
		createCookie("country",newCountry);
	}
	*/
	/*if(cmd)
	{
		location.replace('/default.aspx?_lang='+lang)
	}	
	else if(loc.indexOf("Portal") != -1)
    {
        newloc = loc.substring(0,13)+lang+loc.substring(15);
        location.replace(newloc);
    }
    else
        {
            document.Language._lang.value = lang;
            document.Language.submit(); 
        }    
        */
}
function anxChgCountry(country)
{
	var loc = window.location.pathname;	
	eraseCookie("country");
	createCookie("country",country);
	
	if(loc.indexOf("Portal") != -1)
    {
        lang = loc.substring(13,15);
		location.replace(loc)        
    }
	else
		{
			lang = document.Language._lang.value;
			location.replace('/Schedule2/'+lang+'/Start.aspx?_lang='+lang+'&_cid='+country)
		}
	         
	
          
}
function anxLogin(user, pass)
{
	var loc = window.location.pathname;
	var n = loc.indexOf("Portal");
	var lang = 'pl';
	if(n != -1)
    {
        lang = loc.substring(n+7,n+9);	
		document.Login._lang.value = lang;	       
    }
	
    document.Login.login.value = user;
    document.Login.password.value = pass;
    document.Login.submit()
}
function anxLogout()
{
	var lang = document.Language._lang.value;			
	var country = readCookie("country");
	if(!readCookie("country"))
		{
			country = '1010';
		}
    location.replace('/Default.aspx?_cmd=LOT_IBE_Logout&_lang='+lang+'&_cid='+country);
}
function anxPassForget()
{
	var loc = window.location.pathname;
	if(loc.indexOf("Portal") != -1)
    {
        lang = loc.substring(13,15);		       
    }
	else
		{
			lang = document.Language._lang.value;			
		}
	country = readCookie("country");
	if(!readCookie("country"))
		{
			country = '1010';
		}
    location.replace('/Default.aspx?_cmd=Command_LOT_IBE_PrzypomnijHasloFormularz&_lang='+lang+'&_cid='+country);
//    alert("pass forget")
}
function anxEditProfile()
{
	var loc = window.location.pathname;
	if(loc.indexOf("Portal") != -1)
    {
        lang = loc.substring(13,15);		       
    }
	else
		{
			lang = document.Language._lang.value;			
		}
	country = readCookie("country");
	if(!readCookie("country"))
		{
			country = '1010';
		}
    location.replace('/Default.aspx?_cmd=LOT_IBE_ProfileInfo&_lang='+lang+'&_cid='+country);
}

function findBannerCookie(nazwa)
{
	
	return readCookie(nazwa);
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function createCookie(name,value)
{
	document.cookie = name+"="+value+"; path=/";
}

function eraseCookiePath(name,path)
{
	
	createCookiePath(name,"",-1,"");
}

function createCookiePath(name,value,date,path)
{
	document.cookie = name+"="+value+"; path=/"+path+";EXPIRES="+date;
;
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
