// Checkquery
// Determines whether form has proper submission criterion
// RETURNS: false if no value given for query param
function CheckMT(objMT, strID,qform)
{
	if (strID == "") {
		window.alert(notextalert);
		SetFocus(objMT);
		return false;
	}else{
		return true;
	}
}	

// SetFocus()
// Given an element, it will set the focus
function SetFocus(objMT)
{
	objMT.focus();
}

// rollover code for Info trans gifs...
//sniffs for ie3 or 4 and delivers the goods :)  image swaps for IE3 on Mac browser only)
//ignores netscape browsers
function toggleInfoGifs(p_obj)
{
	if((navigator.appVersion.charAt(0) >= 3) && (navigator.appName.indexOf("Explorer") > -1)){
		if(p_obj.src.indexOf("/images/infotransOFF.gif") > -1){
			p_obj.src="/images/infoTransON.gif"
		}else{
			p_obj.src="/images/infotransOFF.gif"
		}
	}
}
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
function changeImages() {  
	if (document.images ) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

if( navigator.appVersion.indexOf("4.")>=0) bScreen=true;

// Wrapper function to allow me to modify the variables in the Help call and not have to set global variables to do so
// fWrapHelp( IN v_bSearch, IN v_H_KEY, IN v_L_H_TEXT )
// WHERE
// v_bSearch = boolean value identifying whether this is a search in help or a topic
// v_H_KEY = if v_bSearch is false, then this is a topic, else it is a secret keyword
// v_L_H_TEXT = if v_bSearch is false, then it's ignored, else it is a localized string displayed in UI
function fWrapHelp(v_OptNoResize, v_bSearch, v_H_KEY, v_L_H_TEXT )
{
	//Set each var and then call DoHelp()
	//If a Search in enabled, then we need a KEY and TEXT values, otherwise it's a topic and we just need TOPIC
	var old_H_KEY = H_KEY;
	var old_L_H_TEXT = L_H_TEXT;
	if( v_bSearch.toString().toUpperCase() == "TRUE" )
	{
		bSearch = v_bSearch;
		H_KEY = v_H_KEY;
		if (v_L_H_TEXT != "")
			L_H_TEXT = v_L_H_TEXT;
		bSearch = true;
	} else {
		H_TOPIC = unescape(v_H_KEY);
		bSearch = false;
	}
	if (v_OptNoResize == "off")
	{
		bOptNoResize = 1;
	}
	DoHelp();
	H_KEY = old_H_KEY;
	L_H_TEXT = old_L_H_TEXT;
	bSearch = true;
}

// ChangePage( obj )
// Modifies anchor to include query string
function ChangePage(objAnchor)
{
	var strQuery, intLoc, strPath;
	//Sanity check to be sure the value passed is an object
	if (typeof(objAnchor) == "object")
	{
		var strAnchor = objAnchor.href;
		strPath = window.location.pathname.substring( window.location.pathname.lastIndexOf( '/' ) + 1, window.location.pathname.length );
		//determine if this page has valid controls to pass forward or not
		if( strPath == "contactus.asp" || strPath == "contactusthanks.asp" || strPath == "default.asp" || strPath == "advanced.asp" || strPath == "results.asp" || strPath == "Preference.asp" || strPath== "searchclip.asp" || strPath == "searchclipCode.asp" || strPath == "searchclipTerms.asp" || strPath == "worldwide.asp" || strPath == "category.asp" || strPath == "" )
		{
			if (strAnchor.indexOf("Preference.asp") < 0)
			{
				if (document.STWF){
					if( typeof(document.STWF.q ) == "object" )
					{
						document.STWF.cfg.value = "ADVANCED";
						document.STWF.submit();
					}
				} else {
					self.location = "advanced.asp";
				}
			} else {
				window.top.location.href = strAnchor + "&newURL=" + escape(self.location);
			}
		}
		else 
		{
			//write query string to originating anchor
			if(navigator.appVersion.lastIndexOf("MSIE 3.") > -1 || navigator.appVersion.lastIndexOf("WebTV") > -1) // For all MSIE 3.0 versions
			{
				window.top.location.href = objAnchor.href + window.location.search;
			} else {
				if( objAnchor.search.length > 0 ) {
					//do nothing
				} else {
					window.top.location.href = objAnchor.href;
				}
			}
		}
	}
}

function main()
{
	if (window.comppopup != null)
		comppopup();
}

function newUrl()
{
	var strID = document.all.item("q").value;
	if(strID == "") {
		window.alert(notextalert);
		SetFocus();
	}else{
		if (strID.indexOf("://") < 1)
			strID = "http://" + strID;
		self.location = strID;
	}
}

function tooltip()
{
	document.all.item("tips").style.display = "";
}

function GoMediaElem( oAnchor, sForm )
{
	var sURL = "redir.aspx?target=" + escape(oAnchor.href) + "&FORM=" + sForm;
	window.location.href = sURL;
	return false;
}

//hide or show element oElm. Also toggle the associated image oImg.
function hideshow(elmId, imgId){
	oElm = document.getElementById(elmId);
	oImg = document.getElementById(imgId);
	if (oElm.style.display == ""){
		oElm.style.display = "none";
		oImg.src = "/static/up.gif"
	} else {
		oElm.style.display = "";
		oImg.src = "/static/down.jpg"
	}
}

function FixHosts()
{
        window.open("/static/fixhosts.exe", "_self");
}

