
// used to write flash object code to circumvent IE flash activating problem
function writecode (htmlcode) {
      document.write(htmlcode);
}

// defines the style to use according to OS type
	stil = ((navigator.platform.indexOf('Win') > -1) ? "http://www.yelkoch.com/autoo1.css" : "http://www.yelkoch.com/macautoo1.css");
	document.write('<link rel="stylesheet" href="' + stil + '">');	
	

function getHeight() {
  myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;

}

function getWidth() {
  myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

// opens a window without navigation etc
function openClearWin(url, w, h)
{
	if (url != "")
	{
		if (parent.clearWin == null)
		{
			newWindow = window.open(url,'clearWin', 'width = 640, height =500, toolbar = no, resizable=no, scrollbars=no,left=20, top = 20');
			newWindow.focus();
		}
		else 
		{
			parent.clearWin.location.href = url;
			parent.clearWin.focus();
		}
	}
}


function openExtWin(url) {
	if (url != "")
	{
		if (parent.extResults == null)
		{
			newWindow = window.open(url,'extResults','width=1000, height=760, toolbar = yes, resizable=yes, scrollbars=yes,left=' + (getWidth()-1000)/2 +' ,top=100');
			newWindow.focus();
		}
		else 
		{
			parent.extResults.location.href = url;
			parent.extResults.focus();
		}
	}
}
//opens A window for the webCams in traffic info
var camWin;
function openCamWin(url)
{
	self.location.reload();
	if(camWin)
	{
		if(!camWin.closed) camWin.close();
	}
	   camWin = open(url, 'camWin', 'toolbar =no, scrollbar=no ,resizable= no, width=352, height=300, left=10, top=10');
	   camWin.focus();
}

//resizes the Exterior window
function resizeExtWin(width, height)
	{
		this.window.resizeTo(width, height);
	}

// resets the exterior window size to the regular size
function resetExtWin()
	{
		this.window.resizeTo(800, 600);
	}

// opens a window with variable size and position 
//var varWin=0;
function openVarWin(url, width, height, left, top, scr, res)
{
	if(parent.varWin == null) 
	{
	   	varWin = window.open(url, 'varWin', 'toolbar = no, scrollbar='+scr+',resizable='+res+', width='+width+',height='+height+',left='+left+', top='+top+'');
		varWin.focus();		
	}
	else
	{
		//parent.varWin.resizeTo(120,120);
		//parent.varWin.location.href = url;
		//parent.varWin.close();
		parent.varWin = null;
		varWin = window.open(url, 'varWin', 'toolbar = no, scrollable='+scr+',resizable='+res+', width='+width+',height='+height+',left='+left+', top='+top+'');
		varWin.focus();
	}
	
}
//used in deleteList and renewList to show the pic of the car
var dealWin;
function openDealerWin(url, left, top)
{
	if(dealWin)
	{
		if(!dealWin.closed) dealWin.close();
	}
	   dealWin = open(url, 'dealWin', 'toolbar =no, scrollbar=no ,resizable= no, width= 356,height= 280 ,left='+left+', top='+top+'');
	   dealWin.focus();
}
// makes sure its being regerred by autoo.ch ??? Not Too Sure what it does anymore
function assureReferer(referFilename, URLToOpen) 
{
	referingURL = window.opener.document.location.href;
	if (referingURL.substr((referingURL.length - referFilename.length), referingURL.length -1 ) == referFilename || referingURL.substr((referingURL.length - referFilename.length), referingURL.length -1 ) == "siteMap/siteMap.htm")
	{
		document.location.href = URLToOpen;
	}
	else
	{
		document.location.href = "http://www.autoo.ch";
	}

}


function changePic(pic)
{
	document.display.src = pic;
}
// used to display the description of the content when mousovering the various sections (occasionen, etc)
function displayDescription(elementID)
{
	document.getElementById(elementID).style.display='block';
}

function hideDescription(elementID)
{
	document.getElementById(elementID).style.display='none';
}
//PROBABLY NOT USED ANYMORE !!!
/*
// those two functions toggle between various content blocks within a page in order
// to work properly  an array by the name of 'formElements' containing the ids of the 
// elemnts to be toggled between has to be instantiated in the respective page
	//var toggleElemnts = Array();
function hideAllContent(actualID)
{	
	document.getElementById(actualID).style.display='none';
}

function toggleResult(newID, actualID)
{
	//alert("actualID am Eingang = " + actualID + "Element Typ : " + document.form1.Marke.type + "  Modell Element Typ  " + document.form1.Modell.type);
	hideAllContent(actualID);
	document.getElementById(newID).style.display='inline';
	actualID = newID;
	return actualID;
	//alert("actualID ist jetz = " + actualID);
}


// gets the new actual ID that is selected for showing in order to know which one to hide 
// if the shown element is changed the next time. HAS TO BE INITIALIZED (body onLoad) !!
function getNewActualID(newID, oldID)
{
	actualID = toggleResult(newID, oldID);
	return;
}
*/



//selects the index to be selected in the Marke form
function setMakeOptionIndex(make)
{
	document.form1.Marke.options.selectedIndex = make;
}
//returns the index that is selcted in the Marke form
function getMakeSet()
{
	return document.form1.Marke.options[document.form1.Marke.options.selectedIndex].index;
}

//gets the name of the actual file
function getSelfFileName()
{
	return self.location.href;
}

// constructs a php uri string in order to change the make and models to be set in the form
// sourceFileName has to be defined (set) in the respective file using the function
function resetMakeAndModel(makeIndex, modelIndex)
{
	fileNameParts = getSelfFileName().split("?");
	fileName = fileNameParts[0];
	self.location.href='' + fileName + '?makeIndex=' + makeIndex + '&modelFile=' + modelIndex + '';
}

function resetModelValue()
{
	if (document.form1.Modell.type == 'select-one')
	{
		for (i=2; i < document.form1.Modell.options.length; i++)
		{	
			document.form1.Modell.options[i].value = document.form1.Modell.options[i].text;
		}
	}
}

// sets the model select type to an input text type
function setModelToAll()
{
	if (document.form1.Modell.options[document.form1.Modell.options.selectedIndex].index ==1)
	{
		resetMakeAndModel(getMakeSet(), 0);
	}
}


// loads the content of uri into the window
function picWarning()
{
	alert("Bitte beachten Sie, dass das Bild vom Typ '.jpg' sein muss und maximal 30 KB haben darf \n  -- SONST WIRD DAS BILD IGNORIERT ! ---- \n Für beste Bildqualität Grösse = 320 x 240 pixel");
}


//changes picture and picture text on newCars page
function changePicAndText(pic, picText)
{
	document.display.src = pic;
	
	var textToSet = picText;
 	var rd_Start = 0;
 	var rd_Length = document.getElementById("textArea").firstChild.nodeValue.length;
 	document.getElementById("textArea").firstChild.replaceData(rd_Start,rd_Length,textToSet);
}

// relocation of the auto pages !!
function relocatePage(target)

{	
	if (target == "")
	{
		window.location.href= "http://www.autoo.ch";
	}
	else 
	{
	
		window.location.href= target;
	}

}
/*
function PopupImage(img) {
	w=open("",'image','width=500,height=500,toolbar=no,scrollbars=no,resizable=yes');	
	w.document.write("<HTML><HEAD><TITLE>Zoom Image .:: RETROMOBILE ::..</TITLE><LINK href='/sommaire/home.css' type=text/css rel=stylesheet></HEAD>\n");
	w.document.write("<SCRIPT language='javascript'>\nfunction checksize()\n  { if (document.images[0].complete)\n {  window.resizeTo(document.images[0].width+12,document.images[0].height+46);\n window.focus();\n}\n else\n { setTimeout('check()',250)\n }\n}</"+"SCRIPT>\n");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><table border=0 width=100% height=100%><tr><td align='center'><IMG src='"+img+"' border=0>");
	w.document.write("<br><div align='center'><font face='verdana' size='1'><a href='javascript:window.close ()' class='red2'>Fermer</a></font></td></tr></table>");
	w.document.write("</BODY></HTML>");
	w.document.close();
}
*/