if( document.domain.toLowerCase().indexOf("msrvaq") == 0 )
{
	window.resizeTo(1024,768);
	window.onresize = function(){ try{ window.setTimeout("try{window.resizeTo(1024,768);} catch(err){alert(err.message)}",1);} catch(err){}}
}

if( location.href.indexOf('%') >= 0 ) location.replace(unescape(location.href));
if( window.rootPath == null )
{
	rootPath = location.href.split('?')[0].replace(/[a-z0-9_]+\.(htm|html|cfm)/i,'');
	if( rootPath.indexOf('/login/') >= 0 ) rootPath = rootPath.replace(/[a-z0-9_]+\/login\/.*/i,'');
} 
if( window.windowTitle == null ) windowTitle = "SIGAL v4.2";
lstFlush = "[clientcode][holdingcode][entreprisecode][temp]";
if( window.urlParam == null ) urlParam = '';
erreur = false;
myParams = getUrlParams();
ProductName = ProductName.toLowerCase();
ClientCode = ClientCode.toLowerCase();	
	
function backExpired()
{
	erreur = false;
	/*
    cookies = getCookies();
    if( cookies.secu != null){
		ptrCook = cookies.secu[ProductName];
		lastTime = ( ptrCook == null ) ? 0 : parseInt(ptrCook,10);
	    currTime = (new Date()).getTime();
    	if( lastTime > 0 && currTime - lastTime > 1000 )
		{ 
			err = true;
			setCookie('secu.'+ProductName,0);
			location.href = location.href;
			erreur = true;
	    }
	}
	*/
	return erreur;
}
	
function doubleFenetre()
{  
	err = false;
    cookies = getCookies();
    if( cookies.secu != null && cookies.secu[ProductName] != null )
		err = true;
    return err;
}

if( myParams.entreprisecode != null )
	EntrepriseCODE = myParams.entreprisecode;


if( (rootPath != "" || window.modeHTTP != null) && document.domain != 'localhost' )
{
	currHTTP = location.href.split(':')[0].toLowerCase();
	wantHTTP = ( window.modeHTTP != null ) ? window.modeHTTP : rootPath.split(':')[0].toLowerCase();
	if( currHTTP != wantHTTP )
	{
		document.open();
		document.close();
		location.replace(location.href.replace(currHTTP,wantHTTP));
	}
}


if( doubleFenetre() )
{
	location.replace(rootPath + '_generic/tools/errors/error.cfm?code=3');
	erreur = true;
}

//erreur = backExpired();

for( i in myParams )
{
	if( lstFlush.indexOf('[' + i + ']') < 0 )
	{
		if( i.toLowerCase() == 'language' && window.strLanguage != null )
			urlParam += (( urlParam.length == 0 )? '' : '&') + i + '=' + window.strLanguage;
		else
			urlParam += (( urlParam.length == 0 )? '' : '&') + i + '=' + myParams[i];
	}
}
if( myParams.language == null && window.strLanguage != null )
	urlParam += (( urlParam.length == 0 )? '' : '&') + 'language=' + window.strLanguage;

if (window.urlParamAddons != null)
{
	for( i in urlParamAddons )
	{
		if( lstFlush.indexOf('[' + i + ']') < 0 )
		{
			urlParam += (( urlParam.length == 0 )? '' : '&') + i + '=' + urlParamAddons[i];
		}
	}
}
	
if( erreur == false){
	window.name = ProductName;
	window.onunload = function(){ setCookie('secu.' + ProductName, ''); };
	document.open();
	document.writeln('<' + 'html>');
	document.writeln('<' + 'head>');
	document.writeln('	<' + 'title>' + windowTitle + '<' + '/title>');
	document.writeln('<' + '/head>');
	document.writeln('<' + 'noframes>');
	document.writeln('	<' + 'meta http-equiv="refresh" content="0; url=' + rootPath + '_generic/tools/errors/error.cfm?code=9">');
	document.writeln('<' + '/noframes>');
	if(document.domain == 'msrvdev04'){
		document.writeln('<' + 'frameset  rows="*,0">');
	}
	else{
		document.writeln('<' + 'frameset framespacing="0" frameborder="0" rows="*,0">');
	}
	document.writeln('    <' + 'frame name="CONTENT" src="' + rootPath + '_generic/tools/AppStarter/init.htm?clientCode=' + ClientCode + '&entrepriseCode=' + EntrepriseCODE + "&HoldingCode=" + HoldingCODE + '&temp=' + (new Date()).getTime() + '&' + urlParam + '" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0">');
	if(document.domain == 'msrvdev04'){
		document.writeln('    <' + 'frameset  cols="*,0,0,0">');		
	}
	else{
		document.writeln('    <' + 'frameset framespacing="0" frameborder="0" cols="*,0,0,0">');
	}
	document.writeln('        <' + 'frame name="HIDDEN" src="' + rootPath + '_generic/tools/blank.htm" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0">');
	document.writeln('        <' + 'frame name="SESSION" src="' + rootPath + '_generic/tools/blank.htm" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">');
	document.writeln('        <' + 'frame name="WINDOW" src="' + rootPath + '_generic/tools/blank.htm" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">');
	document.writeln('        <' + 'frame name="CONNEXION" src="' + rootPath + '_generic/tools/blank.htm" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">');
	document.writeln('    <' + '/frameset>');
	document.writeln('<' + '/frameset>');
	document.writeln('<' + '/html>');
	document.close();
}




