// 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);

is_aol34 = is_aol3 || is_aol4;




V4=(is_nav4up||is_ie4up);
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_aol=true //!!!! un-comment to test layout of confirm box in absence of an AOL browser
		if(is_aol) // == 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
}//

// POP-UP CREATION FUNCTION
function openWin(URL,Wname) {
// command is built from strings into the var "exec"
// window settings made in rootsettings.js
var popwin;
var exec = 'popwin=window.open("';
if (window.screen){test_display();} // test for max size if browser can do it

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 test_display() {
// optimise window size, ensuring status and scroll bars are visible
var height_adjust=125;
// 1024 x 768 window is the biggest it will go
win_w=Math.min(window.screen.availWidth,win_w_max)-10;
win_h=Math.min(window.screen.availHeight,win_h_max)-height_adjust;
}//

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
