﻿// JScript File

function bookmark(url, title) {
	if (window.sidebar) 
		window.sidebar.addPanel(title, url,"");	
	else if( window.external ) 
		window.external.AddFavorite( url, title); 
	else if(window.opera && window.print) 
		return true;
}
function searchGo() {
	var stb = document.getElementById('searchTextBox');
	if ( stb.value == "" || stb.value == stb.getAttribute("default") ) {
		alert("Please enter a Model or Product Line keyword.");
		return;
	} 
	//location.href='searchconf.asp?keywords=' + stb.value;
	//location.href='/search.asp?keywords=' + stb.value;
	location.href='/net/Search.aspx?keyword=' + stb.value;
	return false;
}
function show(elemId) {
	 var elem= document.getElementById(elemId);
		if (elem) {
				elem.style.display = (elem.style.display == "none")?"block":"none";
		}
}
		
function HtmlEncode(htmlcode)
{
	var encodedString = "";
	/*htmlcode = htmlcode.replace("<","&lt;");
	htmlcode = htmlcode.replace("\"","&#x22;");
	*/
	for(var i = 0; i < htmlcode.length; i++)
		{
			switch(htmlcode.charAt(i))
			{
				case '<': encodedString += "\&lt;";	break;
				case '>': encodedString += "\&gt;";	break;
				case '\'': encodedString += "\&apos;";	break;
				case '\"': encodedString += "\&#x22;";	break;
				case ')': encodedString += "\&#x29;";	break;
				case '(': encodedString += "\&#x28;";	break;
				default: encodedString += htmlcode.charAt(i);
			}//end of switch
		}//end of for
		
	return encodedString;
}//end of HtmlEncode()

function OpenPopup(url,w,h)
{
	var win = window.open(url, 'popup', 'menubar=no, location=no, status=no, resizable=no,toolbar=no,width='+ w +', height='+ h +', top=50,left=50');
	win.focus();
}//end of OpenPopup()


function OpenAddModel()
{
    OpenPopup('/net/AddModel.aspx','600','620');
}//end of OpenAddModel()

//This function sets the SRC for asp pages. It sets the SRC in the session, for links provided for advertisement.
function SetSource() {
	var url = location.href.toUpperCase();
	var srcindex = url.indexOf("SRC=");
	if (srcindex >= 0) {
		srcindex = srcindex + 4;
		var srcendindex = url.indexOf("&", srcindex);
		var src = (srcendindex >=0) ? url.substring(srcindex, srcendindex) : url.substring(srcindex);
		document.write("<script type='text/javascript' src='/setsource.asp?src=" + src + "'></script>" );
	}
}

SetSource();
