//---- Reload Page ----
function reloadPage()
	{
		window.location.reload();
	}

//----- ATL-Motorsport.nl -----

function breakFrame()
	{
		if(parent.frames.length>=1)
			{
				window.top.location.href="http://www.atl-motorsport.com/index.php";
		}
	}

//-------- Cookie --------------
		  	
function setCookie(name, value, domain, expires, path, secure)
	{
		var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
		document.cookie = curCookie;
	}
  
function testCookie() {
	var exp = new Date(); 
 	exp.setTime(exp.getTime() + 1800000); 
  
 	setCookie("cookies", "cookies", false, exp, false, false); 
 	if (document.cookie.indexOf('cookies') == -1) { 
 		alert('Your browser does not have cookies enabled. To use the language options for this site you have to enable cookies.'); 
 	}

	exp = new Date(); 
  	exp.setTime(exp.getTime() - 1800000); 
  	setCookie("cookies", "cookies", false, exp, false, false);
}

function getCookie(name)
	{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
  if (begin == -1)
  	{
			begin = dc.indexOf(prefix);
			if (begin != 0)
				{
					return null;
				}
		}
	else
		{
			begin += 2;
		}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
  	{
			end = dc.length;
			return unescape(dc.substring(begin + prefix.length, end));
		}
	}
	
	


//-------- Vars to Flash ---------

function doPassVar(vak,args){
   var sendText = args;
   window.document.myHeader.SetVariable(vak, sendText);
}

function doPassVars(vak,args){
   var sendText = args;
   window.document.myMenu.SetVariable(vak, sendText);
}


// ------- Vars from Flash -----------

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
function myMenu_DoFSCommand(command, args)
	{
		var myMenuObj = InternetExplorer ? myMenu : document.myMenu;
		testCookie();
		setCookie('language', args);
		reloadPage();
	}
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
	{
		document.write('<SCRIPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('Sub myMenu_FSCommand(ByVal command, ByVal args)\n');
		document.write(' call myMenu_DoFSCommand(command, args)\n');
		document.write('end sub\n');
		document.write('</SCRIPT\> \n');
	}
//---------- Wijzig DropdownMenu --------------

function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem)
	{
		var i, j;
		var prompt;
		for (i = selectCtrl.options.length; i >= 0; i--)
			{
				selectCtrl.options[i] = null; 
			}
		prompt = (itemArray != null) ? goodPrompt : badPrompt;
		if (prompt == null)
			{
				j = 0;
			}
		else
			{
				selectCtrl.options[0] = new Option(prompt);
				j = 1;
			}
		if (itemArray != null)
			{
				for (i = 0; i < itemArray.length; i++)
					{
						selectCtrl.options[j] = new Option(itemArray[i][0]);
						if (itemArray[i][1] != null)
							{
								selectCtrl.options[j].value = itemArray[i][1]; 
							}
						j++;
					}
				selectCtrl.options[0].selected = true;
   		}
	}
	
//---------- submitForm ------

function submitForm(taal,types)
	{
		if(types != "")
			{
				document.main.submit();
			}
		else
			{
				if(taal == 'nl')
					{
						alert("Kies eerst een model en een type auto.");
					}
				else if(taal == 'du' )
					{
						alert("Please choose a model and a type of car first en dan in het duits :D.");
					}		
				else if(taal == 'en')
					{
						alert("Please choose a model and a type of car first.");
					}
			}
		
	}
	
//---------- Flash Menu Workaround ------

function RunMenu(taal)
{
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="700" height="70" id="myMenu" align="middle">\n');
		document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
		if(taal == 'nl') {
			document.write('<param name="movie" value="swf/menunl.swf" />\n');
		}
		else {
			document.write('<param name="movie" value="swf/menu.swf" />\n');
		}			
		document.write('<param name="loop" value="false" />\n');
    document.write('<param name="loop" value="false" />\n');
    document.write('<param name="menu" value="false" />\n');
    document.write('<param name="quality" value="best" />\n');
    document.write('<param name="wmode" value="transparent" />\n');
    document.write('<param name="bgcolor" value="#000000" />\n');
    document.write('<embed src="swf/menu.swf" loop="false" menu="false" quality="best" wmode="transparent" bgcolor="#000000" width="700" height="70" swLiveConnect="true" name="myMenu"  id="myMenu" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
    document.write('</object>\n');
}

//---------- Flash Welkom Workaround ------

function RunWelkom()
{
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="750" height="40" id="myHeader" align="middle">\n');
	document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write('<param name="movie" value="swf/header.swf" />\n');
	document.write('<param name="loop" value="false" />\n');
    document.write('<param name="menu" value="false" />\n');
    document.write('<param name="quality" value="best" />\n');
    document.write('<param name="wmode" value="transparent" />\n');
    document.write('<param name="bgcolor" value="#000000" />\n');
    document.write('<embed src="swf/header.swf" loop="false" menu="false" quality="best" wmode="transparent" bgcolor="#000000" width="750" height="40" name="myHeader" align="middle" allowScriptAccess="sameDomain" swLiveConnect="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
    document.write('</object>\n');
}

//---------- Flash Slideshow Workaround ------

function RunSlideshow() {
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="670" height="472" id="slideshow" align="middle">\n');
	document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write('<param name="movie" value="swf/slideshow.swf" />\n');
	document.write('<param name="menu" value="false" />\n');
    document.write('<param name="quality" value="high" />\n');
    document.write('<param name="wmode" value="transparent" />\n');
    document.write('<param name="bgcolor" value="#000000" />\n');
    document.write('<embed src="swf/slideshow.swf" menu="false" quality="high" wmode="transparent" bgcolor="#000000" width="670" height="472" name="slideshow" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
    document.write('</object>\n');
}

//----------  Formulier alleen nummers ------

function isNumberKey(evt) {
 var charCode = (evt.which) ? evt.which : event.keyCode
 if (charCode > 31 && (charCode < 48 || charCode > 57))
    return false;

 return true;
}
