// <!-- FEB 2003 -->
// redirect.js


//  =======================================================================================
//  Entry to Javascript "Shop@ssistant" Shopping Basket (for qualified browsers)
//  with provision for other graphical browsers
//  Copyright © 1997-2001 Shop@ssistant eCommerce Solutions Ltd
//  Version MC4_
//  Developed by Rodney Myers
//  =======================================================================================

var INSASS=false;
var is_aol34;
var firstTime=true;

function startShopBrowserTest(){
// BROWSER TEST : Adapted by Rodney Myers from
// Ultimate client-side JavaScript client sniff.
// (C) Netscape Communications 1999 who grant permission to reuse and distribute.
var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
		&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
		&& (agt.indexOf('webtv')==-1));
var is_nav4up = (is_nav && (is_major >=4));

var is_ie   = (agt.indexOf("msie") != -1) && (agt.indexOf('opera')==-1);
var is_ie3  = (is_ie && (is_major < 4));
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")==-1) ); // Modified from 5.0
var is_ie4up  = (is_ie  && (is_major >= 4));
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")!=-1) );
var is_ie6  = (is_ie && (agt.indexOf("msie 6")!=-1) );
var is_ie7  = (is_ie && (agt.indexOf("msie 7")!=-1) );
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);

// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
// or if this is the first browser window opened.  Thus the
// variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
var is_aol   = (agt.indexOf("aol") != -1);
var is_aol3  = (is_aol && is_ie3);
var is_aol4  = (is_aol && is_ie4);
var is_aol5  = (agt.indexOf("aol 5") != -1);
var is_aol6  = (agt.indexOf("aol 6") != -1);
var is_aol7  = (agt.indexOf("aol 7") != -1);
var is_aol8  = (agt.indexOf("aol 8") != -1); // 19 May 2003

is_aol34 = (is_aol3 || is_aol4) && !(is_aol5 || is_aol6 || is_aol7 || 
is_aol8); // 19 May 2003

////// Allow OPERA 6 : July 2002
var is_opera6up=(is_major >= 4) && ((agt.indexOf('opera 6')>-1) || (agt.indexOf('opera 7')>-1));

V4=(is_nav4up||is_ie4up||is_opera6up);

return(V4);
} // end startShopBrowserTest

function redirect(){
 if(window.name!="X_AUDIT")
	{
	var SameSASS = ( top.INSASS && top.SassLicence == SassLicence ) ;
	// Still in the site, so just load Shop Entrance page
	if (SameSASS)  {
		if(top.LobbyName != "" + window.location)
			{ top.ToLobby();}
	}
	else
	{
	// if contained within a foreign frame structure, kill it by using "top" location
	if (startShopBrowserTest())
		{
//is_aol34=true //!!!! un-comment to test layout of confirm box in absence of an AOL3/4 browser
		if(is_aol34)
			{
			if(confirm(AOL_Message))
				{ top.location = System;}
			else
				{alert(AOL_Alert);}
			}
		else
			{ top.location = System;}
       }
	else     { alert(nqmsg);top.location = OldBrows  }
	}
 }//endif
}

function openew(){
 if(window.name!="X_AUDIT")
	{
	var SameSASS = ( top.INSASS && top.SassLicence == SassLicence ) ;
	// Still in the site, so just load Shop Entrance page, first check if _this_is_ entrance page
	if (SameSASS)  {
		if(top.LobbyName != "" + window.location)
			{ top.ToLobby();}
	}
	// if contained within a foreign frame structure, kill it by using "top" location
	else // be sure NOT to reload if not required
	{
	if (startShopBrowserTest())
		{

// is_aol34=true //!!!! un-comment to test layout of confirm box in absence of an AOL browser
		if(is_aol34) // == AOL3 or AOL4
			{
			if(confirm(AOL_Message))
				{  openWin( System ,"SASS");}
			else
				{alert(AOL_Alert);}
			}
		else
			 {
			 openWin( System ,"SASS");}
       }
	else     { alert(nqmsg);top.location = Entrance  }
    }
 }//endif
}//
var popwin=null;

// POP-UP CREATION FUNCTION
function openWin(URL,Wname) {
// command is built from strings into the var "exec"
// window settings made in rootsettings.js

if (windowSizing=="maxxed")
	{
	// optimise window size, ensuring status and scroll bars are visible
	// by default 1024 x 768 window is the biggest it will go - full screen on a really big monitor is super naff!
	win_w=(window.screen)?Math.min(window.screen.availWidth,win_w_max)-w_adjust : win_w;
	win_h=(window.screen)?Math.min(window.screen.availHeight,win_h_max)-h_adjust: win_h;
	left_coord=0;
	top_coord=0;
	}
else if (windowSizing=="centred-pixelsize")
	{
	// win_w,win_h as set in rootsettings.js
	left_coord=(window.screen)?Math.floor((screen.width-win_w)/2):100;
	top_coord=(window.screen)?Math.floor((screen.height-win_h)/4):100;
	}
else if (windowSizing=="centred-percent")
{
	win_w=(window.screen)?Math.floor(window.screen.availWidth*win_w_pct/100): win_w;
	win_h=(window.screen)?Math.floor(window.screen.availHeight*win_h_pct/100): win_h;
	left_coord=(window.screen)?Math.floor((screen.width-win_w)/4):100;
	top_coord=(window.screen)?Math.floor((screen.height-win_h)/8):100;
}

/*
alert("windowSizing = " + windowSizing +"\n"
+ "win_w = " + win_w +"\n"
+ "win_h = " + win_h +"\n"
+ "left_coord = " + left_coord +"\n"
+ "top_coord = " + top_coord +"\n"
)
*/

var exec = 'popwin=window.open("';
exec+= URL   + '", "';
exec+= Wname + '", "';
exec+='width='+win_w+',';
exec+='height='+win_h+',';

exec+='top='+top_coord+',';
exec+='left='+left_coord+',';
exec+='screenX='+left_coord+',';
exec+='screenY='+top_coord+',';

exec+='toolbar='+myToolbar+',';
exec+='location='+myLocation+',';
exec+='directories='+myDirectories+',';
exec+='status='+myStatus+',';
exec+='menubar='+myMenubar+',';
exec+='resizable='+myResizable+',';
exec+='scrollbars='+myScrollbars;

exec+='")';
// eval of exec causes the built up command to be executed.


eval (exec);
return (popwin);
}//




function currentPath(Loc) { /* 16MAR2000 */
Loc=""+Loc;var L=Loc.length;
var suffices="|htm|html|shtml|asp|php|HTM|";
var qry=Loc.lastIndexOf("?");
Loc=(qry==-1)?Loc:Loc.substring(0,qry);
var normal=Loc.lastIndexOf("/");
var back=Loc.lastIndexOf("\\");
var dot=Loc.lastIndexOf(".");
var sfx=Loc.substring(dot+1);
var OK=(suffices.indexOf("|"+sfx+"|")>-1)||(normal==L-1)||(back==L-1);
if(!OK){Loc+="/";normal=Loc.lastIndexOf("/");}
var ret=Loc;
if(back>normal){ret=ret.substring(0,back+1)}
else{ret=ret.substring(0,normal+1)};
return(ret);
}//

function shopStart(marketSetting){
	if(top.INSASS&&!firstTime)
		{alert(top.SL.alreadyLoaded);}
	else if(top.INSASS&&firstTime){firstTime=false;}
	else
		{
		if (marketSetting!=null){setmarket(marketSetting);}
			if(newWindowOpen){openew();} // set in rootsettings.js
			else{redirect();}
		}
}


redirect_ok=true;
start();

// end
