if( location.href.indexOf('%') >= 0 ) location.replace(unescape(location.href));
if( window.rootPath == null ) rootPath = location.href.replace(/[a-z0-9_]+\.htm/i,'');
if( window.windowTitle == null ) windowTitle = "SIGAL v4.2";
lstFlush = "[clientcode][holdingcode][entreprisecode][temp]";
urlParam = '';
erreur = false;
myParams = getUrlParams();
ProductName = ProductName.toLowerCase();
	
	
function doubleFenetre()
{   err = false;
    cookies = getCookies();
    if( cookies.secu != null){
		ptrCook = cookies.secu[ProductName];
		lastTime = ( ptrCook == null ) ? 0 : parseInt(ptrCook,10);
	    currTime = (new Date()).getTime();
    	if( currTime - lastTime < 1000 * 1 ) err = true;
	    }
    return err;
}

if( myParams.entreprisecode != null )
	EntrepriseCODE = myParams.entreprisecode;


if( rootPath != "" )
{
	currHTTP = location.href.split(':')[0].toLowerCase();
	wantHTTP = rootPath.split(':')[0].toLowerCase();
	if( currHTTP != wantHTTP )
	{
		document.open();
		document.close();
		location.replace(location.href.replace(currHTTP,wantHTTP));
	}
}

if( doubleFenetre() )
{
	var d = new Date();
	var d2 = new Date();
	while( d2.getTime() - d.getTime() < 1000 * 1 ) d2 = new Date();
	if( doubleFenetre() )
	{
		location.replace(rootPath + '_generic/tools/errors/error.cfm?code=3');
		erreur = true;
	}
}

for( i in myParams )
{
	if( lstFlush.indexOf('[' + i + ']') < 0 )
		urlParam += (( urlParam.length == 0 )? '' : '&') + i + '=' + myParams[i];
}


if( erreur == false){
	window.name = 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>');
	document.writeln('<' + 'frameset  rows="*,0">');
	document.writeln('    <' + 'frame name="CONTENT" src="' + rootPath + 'init.htm?clientCode=' + ClientCode + '&entrepriseCode=' + EntrepriseCODE + "&HoldingCode=" + HoldingCODE + '&temp=' + (new Date()).getTime() + urlParam + '" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0">');
	document.writeln('    <' + 'frameset  cols="*,0,0,0">');
	document.writeln('        <' + 'frame name="HIDDEN" src="' + rootPath + 'blank.htm" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">');
	document.writeln('        <' + 'frame name="SESSION" src="' + rootPath + 'blank.htm" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">');
	document.writeln('        <' + 'frame name="WINDOW" src="' + rootPath + 'blank.htm" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">');
	document.writeln('        <' + 'frame name="CONNEXION" src="' + rootPath + 'blank.htm" marginwidth="0" marginheight="0" scrolling="no" frameborder="0">');
	document.writeln('    <' + '/frameset>');
	document.writeln('<' + '/frameset>');
	document.writeln('<' + '/html>');
	document.close();
	}



