// TurnPages functions
// (c) 2007, Forward Thinking BV
// www.turnpages.com
//
function getQueryVariable(variable) {
  		var query = window.location.search.substring(1);
  		var vars = query.split("&");
  		for (var i=0;i<vars.length;i++) {
    		var pair = vars[i].split("=");
    		if (pair[0] == variable) {
      			return pair[1];
    		}
  		} 
	}
//
//
function getWebtrendsID(){
	var myWebtrendsID = top.getQueryVariable("webtrendsID");
	  if (myWebtrendsID == undefined | myWebtrendsID == ""){
		return "TEST";
	  } else {
	  	return myWebtrendsID
	  }
}
//
function loadPreloader(){
/////////////////////  DEFINITIONS
	  movieName = "preloader";
      flName = "preloader.swf";
      flColor = "#FFFFFF";
	  flWidth = "970";
      flHeight = "580";
	  flId = "turnpages";
	  
	  
	  gXMLWebtrends = "xml/";

	  
	  FlRequestString = "?gPage=" + top.getQueryVariable("openPage");
	  FlRequestString = FlRequestString + "&gXMLWebtrends=" + top.gXMLWebtrends;			  
	  FlRequestString = FlRequestString + "&gWebtrendsID=" + top.getWebtrendsID();		  	  
	  FlRequestString = FlRequestString + "&gCall=" + top.getQueryVariable("call");		

/////////////////////  HTML
	  FlObject = '<OBJECT '
	  +  'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'			  
      + ' WIDTH="' + flWidth + '"'
      + ' HEIGHT="' + flHeight + '"'
	  + ' id="' + flId + '">'
      + '<PARAM NAME="movie" VALUE="' + flName + FlRequestString + '">'
      + '<PARAM NAME="quality" VALUE="high">'
      + '<PARAM NAME="bgcolor" VALUE="' + flColor + '">'
	  // Embed
      + '<EMBED src="' + flName + FlRequestString + '"'
      + ' name="' +  flId + '"'
      + ' quality="high" bgcolor="' + flColor + '"'
      + ' WIDTH="' + flWidth + '"'
      + ' HEIGHT="' + flHeight + '"'
      + '>'
      + '</EMBED></OBJECT>'
	document.write(FlObject);
	make_log();	
}
//
//
function make_log(){	
	$logURL = "http://log.turnpages.nl/toyota/services/toyota_log_browser.php?";
	$browserName = navigator.appName; 
	$browserVersion = navigator.appVersion; 
	$browserOS = navigator.platform;
	$referrer = document.referrer;  
	
	$width = screen.width; 
	$height = screen.height; 
	$color = screen.colorDepth; 

	$Session = "toyota_";
	$Session = $Session+Math.floor(Math.random()*9999999); 
	
	$t0 = "tSession="+$Session;
	$t1 = "&tBrowserName="+$browserName;
	$t2 = "&tBrowserVersion="+$browserVersion;
	$t3 = "&tBrowserOS="+$browserOS;
	$t4 = "&tReferrer="+$referrer;
	
	$t5 = "&tWidth="+$width;
	$t6 = "&tHeight="+$height;
	$t7 = "&tColorDepth="+$color;
	$t8 = "&tCall="+top.getQueryVariable("call");
	
	$myVars = $t0 + $t1 + $t2 + $t3 + $t4 + $t5 + $t6 + $t7 + $t8;
/*	document.write($myVars); */
	document.write("<img src='" + $logURL + $myVars+" ' width=0 height=0 ");
}
//
// RESIZE AND CENTER BROWSER WINDOW
	if (document.all) {
		top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
	else if (document.layers||document.getElementById) {
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
		top.window.outerHeight = screen.availHeight;
		top.window.outerWidth = screen.availWidth;
		}
	}

	var myScreenWidth = screen.availWidth;
	var myScreenHeight = screen.availHeight;
	var myX0 = (myScreenWidth/2) - 512;
	var myY0 = (myScreenHeight/2) - 384;
	if (myX0 < 0) {
		myX0 = 0;
	}
	if (myY0 < 0) {
		myY0 = 0;
	}	
	window.moveTo(myX0,myY0);
	
	var myWidth = 1024;
	var myHeight = 768;
	
	if (myWidth > myScreenWidth){
		myWidth = myScreenWidth
	}

	if (myHeight > myScreenHeight){
		myHeight = myScreenHeight
	}
	
	self.resizeTo(myWidth,myHeight);
	var win= null;
//// END
