// JavaScript Document

function launchHpBikes() {
	openWin("http://www.bmw-motorrad.com/com/en/specials/hp/index_vision.html", "hpbikes", 590, 790, false)
}

function openWin(winUrl, winName, height, width, scrollbars, customProps) // scrollbars is boolean, not a String
{
	var props
	if (arguments.length==6) // note: if customProps is passed, then scrollbars is ignored
	{
		props=""+customProps
	}
	else
	{
		props="toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars="+(scrollbars?"1":"0")+", resizable=1, "
	}
	if (winName!=null) {
		winName=winName.replace(/_/g, "")
	}
	props+="height="+height+", width="+width
	var win=window.open(winUrl,winName,props)
	var winOpen=false
	if (win.opener) {
		if (win.opener==window) {
			win.focus()
			return win
		}
	}
	alert("You appear to have software that is blocking popups. Please disable this software for this site.")
}

function getDiv(divId) {
	if (document.getElementById) {
		return document.getElementById(divId)
	}
	return document.all[divId]
}

function publisherImage(src, align) {
	if (arguments.length==1) {
		align=null;
	}
	document.write("<img "+(align==null?"":"align=\""+align+"\" ")+" src=\""+ctxRoot+"/gen/publisherimages/"+src+"\" />")
}

function containsOnly(okChars, s) {
	for (var i=0; i<s.length; i++) {
		var c=s.charAt(i)
		if (okChars.indexOf(c)==-1) {
			return false;
		}
	}
	return true
}
function isPosInteger(s) {
	return containsOnly("1234567890", s)
}
function isPosNumber(s) {
	return containsOnly("1234567890.", s)
}

function getSitemapLink(url) {
	if (url.indexOf("http://")==0 || url.indexOf("https://")==0) {
		window.open(url, ""+new Date().getTime(), null)
	}
	else {
		location.href="/"+url
	}
}


/* 
* *** quickLinksSubmit ( formName ) ***
* function submits the form and calls the corresponding URL when the quicklink dropdown menu is used.
* Menu is located in the 2008 footer, /common/footer_2008.jsp
*/
function quickLinksSubmit(formName) {
	var els=document.getElementById(formName);
	var dest = els.gotoUri.options[els.gotoUri.selectedIndex].value
	var externalURL = new RegExp ('^http\:\/\/');
	if ( ( els.gotoUri.selectedIndex > 0 ) && ( externalURL.test(dest) !== false ) ) {
		location.href = dest;
	} else {
		location.href="/"+dest;
	}
	return false
}




