﻿var urlList2060 = new Array();
var urlList2067 = new Array();
var urlList1033 = new Array();

function checkLanguage()
{
	var lg = getSirrisLanguage();
	if (lg == "2067" || lg == "2060" || lg == "1033")
		document.location = "homePage.aspx";
}
//--------------------------------------------------------------------
function getSirrisLanguage() {
        var label = "SirrisLanguage="
        var labelLen = label.length
        var cLen = document.cookie.length
        var i = 0
        while (i < cLen) {
                var j = i + labelLen
                if (document.cookie.substring(i,j) == label) {
                        var cEnd = document.cookie.indexOf(";",j)
                        if (cEnd ==     -1) {
                                cEnd = document.cookie.length
                        }
                        return unescape(document.cookie.substring(j,cEnd))
                }
                i++
        }
        return ""
}
//--------------------------------------------------------------------
function setLanguage (value)
{
	// Ektron cookie
	//document.cookie='ecm=user_id=0&site_id=&username=&new_site=/Xylos/&unique_id=0&site_preview=0&langvalue=0&DefaultLanguage=1033&NavLanguage=1033&LastValidLanguageID=1033&ContType=&UserCulture=1033&SiteLanguage=' + escape(value);
	// Sirris cookie
	var expdate = new Date();
	//expiration = 1 year
	expdate.setTime(expdate.getTime()+(1000*60*60*24*365));
	setCookie ("SirrisLanguage", escape(value) , expdate);
	if (document.location.href.indexOf("indexBo.aspx") >= 0)
	    document.location = "homePage.aspx";
	else
	    document.location.reload(true);
}
//--------------------------------------------------------------------
function setLanguage_v2 (id,value)
{
	var expdate = new Date();
	//expiration = 1 year
	expdate.setTime(expdate.getTime()+(1000*60*60*24*365));
	setCookie ("SirrisLanguage", escape(value) , expdate);
	if (eval("urlList"+value+"["+id+"]") != "" && eval("urlList"+value+"["+id+"]") != "undefined"  && eval("urlList"+value+"["+id+"]") != undefined)
		document.location = eval("urlList"+value+"["+id+"]");
	else
		document.location.reload(true);
}
//--------------------------------------------------------------------
function setLanguageRedirect (value,url)
{
	var expdate = new Date();
	//expiration = 1 year
	expdate.setTime(expdate.getTime()+(1000*60*60*24*365));
	setCookie ("SirrisLanguage", escape(value) , expdate);
	document.location = url;
}
//--------------------------------------------------------------------
function setLanguageLogin (value)
{
	// Ektron cookie
	//document.cookie='ecm=user_id=0&site_id=&username=&new_site=/Xylos/&unique_id=0&site_preview=0&langvalue=0&DefaultLanguage=1033&NavLanguage=1033&LastValidLanguageID=1033&ContType=&UserCulture=1033&SiteLanguage=' + escape(value);
	// Sirris cookie
	var expdate = new Date();
	//expiration = 1 year
	expdate.setTime(expdate.getTime()+(1000*60*60*24*365));
	setCookie ("SirrisLanguage", escape(value) , expdate);
	//document.location.reload(true);
	document.location = "homePage.aspx";
}
//--------------------------------------------------------------------
function setMenu (name, value)
{
	setCookie (name, escape(value));
}
//--------------------------------------------------------------------		
function setCookie (name, value, expires) 
{
	if (!expires) 
	{
		document.cookie = name + "=" + escape (value) + "; path=/"; 			
	}
	else
	{
		document.cookie = name + "=" + escape (value) + "; expires=" + expires.toGMTString() + "; path=/"; 
	}
}  
//--------------------------------------------------------------------
function checkOldURL()
{
    
    if (document.location.href.indexOf("crif.be") >= 0) //crif
    {
        setLanguageRedirect ('2060','http://www.sirris.be/homePage.aspx');
    }
    else if (document.location.href.indexOf("wtcm.be") >= 0)    //wtcm
    {
        setLanguageRedirect ('2067','http://www.sirris.be/homePage.aspx');
    }
    else
        checkExpertoUK();
}
//--------------------------------------------------------------------
function checkOldURLInPage()
{
    //alert("checkOldURLInPage");
    if (document.location.href.indexOf("crif.be") >= 0) //crif
    {
        var url = document.location.href.substring(document.location.href.indexOf("crif.be")+7);
        //alert(url);
        setLanguageRedirect ('2060','http://www.sirris.be' + url);
    }
    else if (document.location.href.indexOf("wtcm.be") >= 0)    //wtcm
    {
        var url = document.location.href.substring(document.location.href.indexOf("wtcm.be")+7);    
        //alert(url);
        setLanguageRedirect ('2067','http://www.sirris.be' + url);
    }
    else
        checkExpertoUK();
}
//--------------------------------------------------------------------
function checkExpertoUK()
{
    if (document.location.href.indexOf("experto.be") >= 0) //Experto uniquement en EN pour l'instant 2009-04-06
       	setLanguageRedirect('1033','http://www.experto.be/experto/homePage.aspx');
}
//--------------------------------------------------------------------
function checkSubsiteURL()
{        
    if (document.location.href.indexOf("norm.sirris.be") >= 0)    //norm.sirris.be
        document.location = "defaultPage.aspx?id=1230";
    else if (document.location.href.indexOf("www.goformistral.be") >= 0)    //www.goformistral.be
        document.location = "defaultPage.aspx?id=1228";
    else if (document.location.href.indexOf("www.goformistral.be") >= 0)    //www.goformistral.be
        document.location = "defaultPage.aspx?id=1228";
    else if (document.location.href.indexOf("webdev.sirris.be") >= 0)    //www.sirris.be:8888/
        document.location = "defaultPage.aspx?id=1272";
    else if (document.location.href.indexOf("www.rohsservice.be") >= 0)    //www.rohsservice.be
        document.location = "defaultPage.aspx?id=1272";
    else if (document.location.href.indexOf("www.superfmea.be") >= 0)    //www.superfmea.be
        document.location = "/superfmea/defaultPage.aspx?id=448";
    else if (document.location.href.indexOf("www.superfmea.com") >= 0)    //www.superfmea.com
        document.location = "/superfmea/defaultPage.aspx?id=448";
    /*else if (document.location.href.indexOf("pi.sirris.be") >= 0)    //pi.sirris.be
        document.location = "defaultPage.aspx?id=1200";
    else if (document.location.href.indexOf("ip.sirris.be") >= 0)    //ip.sirris.be
        document.location = "defaultPage.aspx?id=1200";*/
    else if (document.location.href.indexOf("pi.sirris.be") >= 0)    //pi.sirris.be
        document.location = "/PI/homepage.aspx";
    else if (document.location.href.indexOf("ip.sirris.be") >= 0)    //ip.sirris.be
        document.location = "/PI/homepage.aspx";
    else if (document.location.href.indexOf("technology-strategy.sirris.be") >= 0)    //technology-strategy.sirris.be
        document.location = "defaultPage.aspx?id=1860";
    else if (document.location.href.indexOf("www.pictor-office.org") >= 0)    //www.pictor-office.org
        document.location = "/pictor/homePage.aspx";
    else if (document.location.href.indexOf("www.experto.be") >= 0)    //www.experto.be
        document.location = "/experto/homePage.aspx?LangType=1033";
    else if (document.location.href.indexOf("innovate.sirris.be") >= 0)    //innovate.sirris.be
        document.location = "/innovate09/homePage.aspx";
    /*else if (document.location.href.indexOf(".sirris.be") >= 0)    //trillingen & geluid
        document.location = "defaultPage.aspx?id=1358";
    */
    else if (document.location.href.indexOf("www.edmp.be") >= 0)    //www.edmp.be
        document.location = "/EDM/EDMHome.aspx?LangType=1033";

}
//----------------------------------------------------------------------
function checkSubsiteURLWithOneLg()
{        
    if (document.location.href.indexOf("www.experto.be") >= 0)    //www.experto.be
        document.location = "/experto/homePage.aspx?LangType=1033";
    else if (document.location.href.indexOf("www.edmp.be") >= 0)    //www.edmp.be
        document.location = "/EDM/EDMHome.aspx?LangType=1033";
}


