//Drop Down Menu
sfHover = function() {
	var sfEls = document.getElementById("menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfHover";
		}
		sfEls[i].onmouseout=function() {
			this.className = this.className.replace(new RegExp("sfHover\\b"), "");
		}
	}
}

/* Toggle and open/close functions to show hide Divs */
function toggle(targetId){ 
  if (document.getElementById){ 
		target = document.getElementById(targetId); 
			 if (target.style.display == "none"){ 
					target.style.display = "block";
					target.style.visibility = "visible";
			 } else { 
					target.style.display = "none";
					target.style.visibility = "hidden";
		}
	}
}

function openTarget(targetId){ 
  if (document.getElementById){ 
	target = document.getElementById(targetId); 
		if (target.style.display == "none"){ 
			target.style.display = "block";
			target.style.visibility = "visible";
    }
	}
}

function closeTarget(targetId){ 
  if (document.getElementById){ 
	target = document.getElementById(targetId); 
		if (target.style.display == "block"){ 
			target.style.display = "none";
			target.style.visibility = "hidden";
    }
	}
}



/* Open browser window FULLSCREEN for Quote popups - Chromeless */
function fullWindow(url) { 
    var str = "left=0,screenX=0,top=0,screenY=0,resizable,status=yes,scrollbars=yes";
    if (window.screen) {
      var ah = screen.availHeight - 50;
      var aw = screen.availWidth - 10;
      str += ",height=" + ah;
      str += ",innerHeight=" + ah;
      str += ",width=" + aw;
      str += ",innerWidth=" + aw;
    }
    win=window.open(url, "w", str);
    win.focus();
}

// Centered Popup Javascript code v1.1 - 23_02_2007
// v1.0 - v1.1 Instructions added to code.
// To use the Popup function please follow these guidlines - Lukas Smola - 23_02_2007
// Example: <a href="javascript:void(0);" onclick="popupWindow('http://www.google.com.au','quote',920,700,yes,yes);">Google</a>
//                                                              ^URL                       ^PName ^Width ^Height ^Scrollbars ^Status
// Change the above variables to change the URL, Pagename, Width, Height, Scrollbars and Status.
function popupWindow(mypage, myname, w, h, scroll, stat) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
// to add resize functionality to page winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',status='+stat+''
win = window.open(mypage, myname, winprops)
// Put Focus on the Window if the Browser Navigator version is above 4.
if (parseInt(navigator.appVersion) >= 4) {
	win.focus();
	}
}

function openNewWinNoOptions(url,w,h){
	myWidth = 800;
	myHeight = 600;

	if(url != null){//if url is supplied continue
		if(w != null){myWidth=w;}	//define w if it is not already defined
		if(h != null){myHeight=h;}	//define h if it is not already defined
		window.open(url,'_blank','width='+ this.myWidth +',height='+this.myHeight+',resizable=no,scrollbars=no'+
				',toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no');
	}else{//tell the user that no parameters have been passed.
		window.alert("No URL specified. - Cannot continue");
	}
}

function openNewWinScroll(url,w,h){
	myWidth = 800;
	myHeight = 600;

	if(url != null){//if url is supplied continue
		if(w != null){myWidth=w;}	//define w if it is not already defined
		if(h != null){myHeight=h;}	//define h if it is not already defined
		window.open(url,'_blank','width='+ this.myWidth +',height='+this.myHeight+',resizable=no,scrollbars=yes'+
				',toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no');
	}else{//tell the user that no parameters have been passed.
		window.alert("No URL specified. - Cannot continue");
	}
}

function newWin(url,w,h){  
	myWidth = 800;
	myHeight = 600;

	if(url != null){//if url is supplied continue
		if(w != null){myWidth=w;}	//define w if it is not already defined
		if(h != null){myHeight=h;}	//define h if it is not already defined
		
		window.open(url,'_blank','width='+ this.myWidth +',height='+this.myHeight+',resizable=yes,scrollbars=yes'+
				',toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,copyhistory=yes');		 
	}else{//tell the user that no parameters have been passed.
		window.alert("No URL specified. - Cannot continue");
	}
}
function turnButtonOn(){
	closeTarget("menu_on_rider_rider");
	closeTarget("menu_off_road_rider");
	closeTarget("menu_scooter_rider");
	document.getElementById("but_road_rider").className = "road_bg";
	document.getElementById("but_off_road_rider").className = "off_road_bg";
	document.getElementById("but_scooter").className = "scooter_bg";
	
	if(turnButtonOn.arguments[0] == "but_road_rider"){
		document.getElementById(turnButtonOn.arguments[0]).className = "road_bg_on";
		openTarget(turnButtonOn.arguments[1]);
	}else if(turnButtonOn.arguments[0] == "but_off_road_rider"){
		document.getElementById(turnButtonOn.arguments[0]).className = "off_road_bg_on";
		openTarget(turnButtonOn.arguments[1]);
	}else if(turnButtonOn.arguments[0] == "but_scooter"){
		document.getElementById(turnButtonOn.arguments[0]).className = "scooter_bg_on";
		openTarget(turnButtonOn.arguments[1]);
	}
}



//**********************************
//Load Functions
//**********************************
$(document).ready( function() {

	sfHover();
							
	//external link
	$("a.newwindow").click( function() {
		this.target = "_blank";
	});

	$("a.popup").click( function() {
		window.open( $(this).attr('href'), "popup", "width=860, height=670,menubar=no,location=no,scrollbars=yes" );
		return false;
	});
	
});


