function openWin(URL,width,height,scroll,resize, status, menubar, toolbar, location, directories, winName) {
	noUrl = false	
	if (URL == "" || URL == null) { URL="about:blank"; noUrl=true }
	if (width == "" || width == null ) { width = 640 }
	if (height == "" || height == null ) { height = 480 }
	if (width == "*" ) { 
		width = (screen.availWidth * (100/99)) ;
		if (width > 800) width="800"; //since the site isn't wider than 800px, there's no point in opening in fullscreen mode, it just looks silly!
	}
	if (height == "*" ) { 
	height =  (screen.availHeight * (100/95));
		if (height > 580) height="580";//since the site isn't taller than 800px, there's no point in opening in fullscreen mode, it just looks silly!
	}
	if (scroll == "" || scroll == null ) { scroll = 1 }
	if (resize == "" || resize == null ) { resize = 1 }
	if (status == "" || status == null ) { status = 1 }
	if (menubar == "" || menubar == null) {menubar=0}
	if (toolbar == "" || toolbar == null) {toolbar=0}
	if (location == "" || location == null) {location=0}
	if (directories == "" || directories == null) {directories=0}
	if (winName == "" || winName == null) {winName="NEW"}
	
	PARMS = 'toolbar='+toolbar +',location='+location +',directories='+directories +',status='+status +',menubar='+menubar +',scrollbars=' + scroll + ',resizable=' + resize + ',width=' + width + ',height=' + height
  var newWin = window.open(URL,winName,PARMS);
	/* newWin.screenX = 0;
  newWin.screenY = 0; */
	if (noUrl) {
		newWin.document.writeln("<BR><BR><FONT color='red'>It seems like you forgot to put in a value for URL when you called for <I>openWin()</I></FONT>")
		newWin.document.close()
	}
	newWin.focus();
	return;
}

function openWinDefault(URL) {
	noUrl = false;
	PARMS = "";
	if (URL == "" || URL == null) { URL="about:blank"; noUrl=true }
	
	var newWin = window.open(URL,"NEW",PARMS);
	
	if (noUrl) {
		newWin.document.writeln("<BR><BR><FONT color='red'>It seems like you forgot to put in a value for URL when you called for <I>openWin()</I></FONT>")
		newWin.document.close()
	}
	return;
}

function openWinNoLocation(URL){
	noUrl = false;
	PARMS = "";
	if (URL == "" || URL == null) { URL="about:blank" }
		
	var newWin = window.open(URL,"NEW",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=820,height=660');
	return;
}


function openWinNoOptions(URL){
	noUrl = false;
	PARMS = "";
	if (URL == "" || URL == null) { URL="about:blank" }
		
	var newWin = window.open(URL,"NEW",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,width=820,height=660');
	return;
}

function openEnhancedSpecs (featureCode, cpart, market, language, modelCode)
{
	PARMS = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=false,resizable=0,width=678,height=356';
	var url = ""
	
	//cType = modelCode;
	if (modelCode == "95"  ||  modelCode == "95_WAGON")
	{
		url = "/microsites/9-5/95.xml"
		cType = (modelCode == "95") ? "s" : "w";
	}
	else if (modelCode == "93_S"  ||  modelCode == "93_WAGON")
	{
		url = "/main/" + market + "/" + language + "/93s_enhancements_container.xml"
		cType = "93s";
	}
	
	if (cType != '') 
	{
		var enhancedSpec = window.open (
			url +"?market=" + market 
				+ "&language=" + language
				+ "&ctype=" + cType 
				+ "&cpart=" + cpart, 
			"Saab95", 
			PARMS)
	}
}

function openEnhancedSpecsWithID(cpart){
        var triggerID = 0
        var ctype = ''
        for (i=0; i< mappedArray.length; i++) {
                if (cpart == mappedArray[i][0]) {
                        triggerID = mappedArray[i][1]
                        ctype = mappedArray[i][2]
                        }
        }

        cpart = triggerID
        PARMS = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=false,resizable=0,width=678,height=356';
        var url = ""
        if (ctype == "w" || ctype == "s") url = "../../../microsites/9-5/95.xml"
        else if(ctype=="93s") url = "93s_enhancements_container.xml"
        if(ctype!='') {
                var enhancedSpec = window.open(url +"?market="+market+"&language="+language+"&ctype=" + ctype + "&cpart=" + cpart, "Saab95", PARMS)
        }
}

function openFullScreenWin(u) {
	
	var w = screen.availWidth * (99/100);
	var h = screen.availHeight * (99/100);
	var parms = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+w+',height='+h+',top=1,left=1';
	var windowname = 'fullscreenpop';
	
	var newfullscreenWin = window.open(u,windowname,parms);
  
	return;
	
}

function getCleanUrl() {
	URL = document.URL
	myParamStartPos = URL.indexOf("?",0)
	if(myParamStartPos>0){
		URL = document.URL.substr(0,myParamStartPos)
		return URL
	}
	else return URL
}

function getParam(name) 
{
	var param;
	var idxStart = document.URL.indexOf('?');
	
	if (idxStart >= 0) {
		// get the query string, prepend and append & to make searching easier
		idxStart += 1;
		var url = "&"+document.URL.substring(idxStart, document.URL.length)+"&";
		
		// found the param?
		idxStart = url.indexOf("&"+name+"=");
		if (idxStart >= 0) {
			idxStart += name.length+2;
			var idxEnd = url.indexOf("&", idxStart);
			param = url.substring(idxStart, idxEnd);
		} else debug("Couldn't find param: "+name, "DEBUG");
	}
	
	debug("getParam('"+name+"') = "+param, "DEBUG");
	return param;
} // getParam(name)


function getDirectoryFromUrl(dirNo) 
{
	var i = 0;
	var url = location.href;
	var ret = "";
	
	url = url.substring (url.indexOf ("/", 9) + 1)
	while (i < Number (dirNo) - 1  &&  url.indexOf ("/") != -1)
	{
		url = url.substring (url.indexOf ("/") + 1);
		++i;
	}
	
	if (url.indexOf ("/") != -1)
	{
		ret = url.substring (0, url.indexOf ("/"));
	}
	
	return ret;
} // getDirectoryFromUrl(dirNo)


function changeUrlParams(params){
	currentCleanUrl = getCleanUrl()
	newUrl = currentCleanUrl + "?" +params
	document.location = newUrl
}

function getServerInfo() {
 return document.location.host
 //alert(document.location.port)
}
//Swaps image
// LAF: this doesn't look netscape compatible, especitially with layers
function swapImage(imgName,imgSrc) {
	document.images[imgName].src=imgSrc
}


// debug level setting for displaying debug messages with the debug() function
// this can be set in any javascript file or block
var DEBUG; // 'DEBUG', 'ERROR', 'WARNING'


// debug message alerts
// uses the global variable DEBUG 
// msg = the message to display in the alert
// logLevel = only displays the msg if the current log level, or higher, is being used
// where log levels are: debug, warning, info
// if DEBUG='DEBUG' all messages are shown, i.e. debug, error, and warning messages
// if DEBUG='WARNING' only warning and error messages are shown
// if DEBUG='ERROR' only error messages are shown
function debug(msg, logLevel) {
	//if (!DEBUG) DEBUG = getParam("DEBUG");
	if (!DEBUG || (DEBUG=='')) return; // debugging is turned off
	if (!logLevel) logLevel = 'DEBUG'; // default
	if (DEBUG != 'DEBUG') {
		if ((DEBUG == 'ERROR') && (logLevel != 'ERROR')) return;
		if ((DEBUG == 'WARNING') && (logLevel == 'DEBUG')) return;
	}
	alert('Debug level: '+DEBUG+'\nMessage level: '+logLevel+'\n'+msg);
}

function returnBASE() {
        url = location + "";

        // remove the query string if it exists
        idxQuery = url.indexOf( '?' );
        if ( idxQuery >= 0 ) {
                 url = url.substring( 0, idxQuery );
        }

        // get the BASE
        idxLast = url.lastIndexOf( '/' ) + 1;
        base = url.substring( 0, idxLast );
        return base;
}
 
function setBase(form) {
        BASE = returnBASE();
        form.BASE.value = BASE;
}




/*
function newWinNoresizeCHde()
{
	window.open ('http://www.saab-promotion.ch/93aero/de/popup_de.html', 'Window', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=485,height=460');
}

function newWinNoresizeCH()
{
	window.open ('http://www.saab-promotion.ch/93aero/fr/popup_fr.html', 'Window', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=485,height=460');
}


function newWinNoresize (url, w, h)
{
	window.open (url, 'Window', 'toolbar=no,location=no,status=no,menubar=yes,scrollbars=yes,resizable=no,width='+w+',height='+h);
}						

function newWin (url, w, h,trackingid)
{
	if(trackingid){
		measureIt(trackingid);
	}
	//alert(w+"_"+h);
	if(w==""){	w=500;	}
	if(h==""){	w=400;	}
	window.open (url, 'WindowRez', 'toolbar=no,location=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width='+w+',height='+h);
}
function OpenWin (url,trackingid)
{
	if(trackingid){
		measureIt(trackingid);
	}
	//alert(url);
	window.open (url);
}
function newWin_nobars (url, w, h)
{
	//alert(w+"_"+h);
	if(w==""){	w=500;	}
	if(h==""){	w=400;	}
	window.open (url, 'WindowRez', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h);
}
*/