
/* Any changes here must be made in all.js */

function ss(w){window.status=w;return true;}
function cs(){window.status='';}
function changeButtonPic(cmdButton, src) { 

//This is used in the rollover events to change one image to another on form buttons 
 cmdButton.src = src; }
//This leftalign() function positions Related Search 
var leftposition = 830;
function leftalign()
{
	if (document.all && document.all['RelatedSearchOutline'])
	{
		if (document.body.offsetWidth > (leftposition - (document.body.offsetWidth)*0.02))
		{
				
			if (navigator.appVersion.indexOf("Mac")!=-1)
				{document.all['RelatedSearchOutline'].style.left = (document.body.offsetWidth)*0.78;}
			else
				{document.all['RelatedSearchOutline'].style.left = (document.body.offsetWidth)*0.75;}
		}
		else
		{
			if (navigator.appVersion.indexOf("Mac")!=-1)
				{document.all['RelatedSearchOutline'].style.left = leftposition-200;}
			else
				{document.all['RelatedSearchOutline'].style.left = leftposition-230;}
		}
	}
	else
	{
		if (document.getElementById && document.getElementById("RelatedSearchOutline"))
		{
			if (window.innerWidth > (leftposition-(window.innerWidth)*0.02))
			{document.getElementById("RelatedSearchOutline").style.left = ""+((window.innerWidth)*0.75)+"px";}
			else
			{document.getElementById("RelatedSearchOutline").style.left = ""+(leftposition-235)+"px";}

		}
	}
}
function submitmamma()
{
	var mammaForm = document.mammaform;
	var selectedItem = mammaForm.url.selectedIndex;
	document.location.href = mammaForm.url[selectedItem].value;
}

function reloadme(){window.location.reload();}

// used with static page query boxes
function submitqboxtop()
{
	var query = "q=" + escape(document.questionbar.q.value);
	document.questionbar.submit();
}

function submitqboxbottom() {
	var query = "q=" + escape(document.questionbarbottom.q.value);
	document.questionbarbottom.submit();
}

function submitqboxbyval(strDest) {
	
	
	var qsrc = "";
	var o = "";
	if (document.questionbar.qsrc){
		qsrc = document.questionbar.qsrc.value;
	}
	if (document.questionbar.o){
		o= document.questionbar.o.value;
	}
	var query = "q=" + escape(document.questionbar.q.value);
	if (document.questionbar.q.value == '' && strDest == '3') {
		window.location.href = 'http://tm.ask.com/r?t=c&s=a&id=10315&sv=z6f6365e5&uid=20a00155a0a00155a&sid=30a00155a0a00155a&p=%2fweb&o='+o+'&u=http://ask2.pricegrabber.com';
	}
	else {
		query = "web?" + query + "&ste=" + strDest;
		query  = query + '&o=' + o;
		query = query + '&qsrc=' + qsrc;
		
		window.location.href = query;
	}
}

function submitqboxbyvalbottom(strDest) {
	var qsrc = "";
	var o = "";
	if (document.questionbarbottom.qsrc){
		qsrc = document.questionbarbottom.qsrc.value;
	}
	if (document.questionbarbottom.o)
	{
		o= document.questionbarbottom.o.value;
	}
	var query = "q=" + escape(document.questionbarbottom.q.value);
	if (document.questionbarbottom.q.value == '' && strDest == '3')
	{
	window.location.href = 'http://tm.ask.com/r?t=c&s=a&id=10315&sv=z6f6365e5&uid=20a00155a0a00155a&sid=30a00155a0a00155a&p=%2fweb&o='+o+'&u=http://ask2.pricegrabber.com';
	}
	else
	{
	query = "web?" + query + "&ste=" + strDest;
	query  = query + '&o=' + o;
	query = query + '&qsrc=' + qsrc;
	
	window.location.href = query;
	}
}

function submitqboxbyvaltopframe(strDest)
{
	var qsrc = "";
	var o = "";
	if (document.questionbar.qsrc){
		qsrc = document.questionbar.qsrc.value;
	}
	if (document.questionbar.o)
	{
		o= document.questionbar.o.value;
	}
	var query = "q=" + escape(document.questionbar.q.value);
	if (document.questionbar.q.value == '' && strDest == '3')
	{
		window.location.href = 'http://tm.ask.com/r?t=c&s=a&id=10315&sv=z6f6365e5&uid=20a00155a0a00155a&sid=30a00155a0a00155a&p=%2fweb&o='+o+'&u=http://ask2.pricegrabber.com';
	}
	else
	{
		query = "web?" + query + "&ste=" + strDest;
		query  = query + '&o=' + o;
		query = query + '&qsrc=' + qsrc;
		
		window.parent.location.href = query;
	}
}

function submitqboxbyvalstatic(strDest)
{
	var o = "";
	if (document.questionbar.o)
	{
	o= document.questionbar.o.value;
	}
	var query = "q=" + escape(document.questionbar.q.value);
	if (document.questionbar.q.value == '' && strDest == '3')
	{
	window.location.href = 'http://tm.ask.com/r?t=c&s=a&id=10315&sv=z6f6365e5&uid=20a00155a0a00155a&sid=30a00155a0a00155a&p=%2fweb&o='+o+'&u=http://ask2.pricegrabber.com';
	}
	else
	{
	query = "http://web.ask.com/web?" + query + "&ste=" + strDest;
	query  = query + '&o=' + o;
	window.location.href = query;
	}
}

// Consolidated all submitqboxbyval[X] functions
// strDest 				1=pictures, 2=news, 3=products
// barID 				"questionbar" or "questionbarbottom" (or other <form> id)
// redirectDomain 	"http://www.ask.com/" (up to forward slash following domain. Can be null.)

// This version is being deprecated in lieu of submitQBox() due to the shorter name.
function submitQBoxByValAndLocation(strDest, barID, redirectDomain) {
	

	/* Find qsrc */
	var qsrc = "";
	if(document[barID].qsrc) {
		qsrc = document[barID].qsrc.value;
	}
	
	/* Localization */
	var currentDomain = "http://web.ask.com/";
	if(redirectDomain && ("" != redirectDomain)) {
		currentDomain = redirectDomain;
	}

	/* The o parameter */
	var o = "";
	if (document[barID].o) {
		o = document[barID].o.value;
	}


	/* Piece together the query */
	var query = "q=" + escape(document[barID].q.value);
	
	/* Product is a special case with a blank query.*/
	if (('' == document[barID].q.value) && ('3' == strDest)) {
		window.top.location.href = 'http://tm.ask.com/r?t=c&s=a&id=10315&sv=z6f6365e5&uid=20a00155a0a00155a&sid=30a00155a0a00155a&p=%2fweb&o='+o+'&u=http://ask2.pricegrabber.com';

	/* ste=1 is pictures, ste=2 is news */
	} else {
		query = currentDomain + "web?" + query;
		query = query + "&ste=" + strDest;
		query = query + '&o=' + o;
		query = query + '&qsrc=' + qsrc;
		window.top.location.href = query;
	}
	/* return true; */
}

// Once this version is referenced solely from Kite and Static pages, the other (submitQBoxByValAndLocation) will be deleted.
function submitQBox(strDest, barID, redirectDomain) {
	submitQBoxByValAndLocation(strDest, barID, redirectDomain);
}


/* This function appends the query onto the <a> href */
/* Except products - that is replaced altogether. */

function appendQ(strDest, barID, el) {
	/* Find qsrc */
	var qsrc = "";
	if(document[barID].qsrc) {
		qsrc = document[barID].qsrc.value;
	}

	/* The o parameter */
	var o = "";
	if (document[barID].o) {
		o = document[barID].o.value;
	}

	/* Get user's value from input box */
	var q = document[barID].q.value;
	if(q) {
		q = escape(q);
		/* Piece together the query */
		var query = "q=" + q;
		var href = "";
		/* Pricegrabber is special as the url with no query is http://products.ask.com, but
		   if there is a query it's http://ask2.pricegrabber.com/....*/
		if(strDest == 4) {
			var productURL = "http://ask2.pricegrabber.com/search_gen_top.php?topcat_search=1&form_keyword="+q+"&qsrc="+qsrc+"&o="+o;
			el.href = el.href.replace(/http:\/\/Products.ask.com\//i, productURL); /* special url for pricegrabber */
		}
		else {
			var script = "web?";
			if(strDest == 1) { script = "pictures?"; }
			if(strDest == 2) { script = "news?"; }
			if(strDest == 3) { script = "local?"; }
			
			//* web?q=test&o=0&qsrc=0 */
			if(strDest == 2)
			{
				if (q == "")
				{
					href = script + query + '&o=' + o + '&qsrc=' + qsrc;
				}
				else
				{href = script + query + '&o=' + o + '&qsrc=' + qsrc + '&news=true';}
			}
			else
			{href = script + query + '&o=' + o + '&qsrc=' + qsrc;}
			
			el.href += href;
		}
	} else {
			return true;
	}
}

function Redir(thisform) 
{
	var logurl = document.Feedbackform.action;
	var amt = 0;	
	var logstr = "";

	for (var k=1; k<20; k++ )
	{
		if (eval("document.Feedbackform.svop"+k)){amt++;}
		else{break;}
	}

		for (var j=1; j<=amt; j++)
		{
			eval("var question_"+j+" = false;");
			for (var i=0; i < eval("document.Feedbackform.svop"+j+".length"); i++)
			{
				if (eval("document.Feedbackform.svop"+j+"["+i+"].checked"))
				{
					eval("question_"+j+" = true;");
					break;
				}
			}
			if(eval("question_"+j))
			{
				eval("var svop"+j+" = "+"document.Feedbackform.svop"+j+"["+i+"].value");
			}
			else
			{
				alert("Please fill in question "+j);
				return false;
			}
			logstr += "&svop"+j+"="+eval("svop"+j);
			// alert(logstr);
		}

			var svtb = escape(document.Feedbackform.svtb.value);
			var svid = escape(document.Feedbackform.svid.value);
			var svtq = escape(document.Feedbackform.svtq.value);

			logurl = logurl + logstr + '&svtb=' + svtb + '&svid=' + svid + '&svtq=' + svtq + '&u=http://sp.ask.com/docs/feedback/Feedback_Thank_You.html';
			// alert(logurl);
			count_change(document.Feedbackform, logurl);
}
function count_change(form, url)
	{
		Msg = form.svtb.value;
		Msglen= Msg.length;
		//maximum length
		MaxLen=250;
		if (Msglen > MaxLen )
			{
				form.svtb.value=Msg.substring(0,MaxLen);
				alert(MaxLen+" symbols allowed only!!")
			} 
		else{window.location.href = url;}
	}
function valbutton(thisform) 
{
	myOption = -1;
	for (i=0; i<thisform.svop1.length; i++) 
	{
		if (thisform.svop1[i].checked) 
		{
			myOption = i;
		}
	}
	
	if (myOption == -1) 
	{
		alert("Please tell me which area of Ask Jeeves you'd like to provide feedback for");
		return false;
	}

	// place any other field validations that you require here
	thisform.submit(); // this line submits the form after validation
}
var browser4 = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4 )) || ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 )));
var ie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4));
var nn4 = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4 ));

function monthSelector(month, logUrl, seltext) { 
	month++;
	for (var i=1;i<13;i++) {
		if (browser4) {
			if (ie4) {
				viewerObj = eval("document.all.weatherDiv" + i + ".style");
			}
			else if (nn4) {
				viewerObj = eval("document.layers['relDiv'].document.layers['weatherDiv" + i + "']");
			}
			else {
				viewerObj = eval("document.getElementById('weatherDiv" + i + "').style");
			}
			if (i==month) {
				viewerObj.display = "block" ;
				if (logUrl != "") { 
					var logImage = new Image();
					logString = new String(logUrl); 
					logUrl = logString.replace("pt=", ("pt=" + seltext)); 
					logUrl = logUrl + "http://sp.ask.com/i/pixl.gif" ;
					logImage.src = logUrl;
				}
			}
			else {
				viewerObj.display = "none" ;
			}
		}
	}
} 

function getAboutHref() {
	var da = document.getElementById("DA1");
	if(!da) {
		da = document.getElementById("DA2");
		if(!da) { return; } else {
			/* DA2 */
			document.getElementById("aboutLink").href = "http://sp.ask.com/docs/about/ps_mpp.html";
		}
	} else {
		/* DA1 */
		document.getElementById("aboutLink").href = "http://sp.ask.com/docs/about/ps_csa.html";
	}
	
}

function setValue (item, value) {
	if(item && value) {
		item.value = value;
	}
	return;
}

/**
 * this function checks if the answer should be opened
 * in new window. If yes, it opens a new window with the
 * answer and returns false; otherwise returns true.
 */
function submitKAForm(form)
{
	if (form) {
		newWin = false;
		cook = document.cookie;
		if (cook) {
			pos = cook.indexOf("newwin=");
			if (pos != -1) {
				value = cook.substring(pos+7, pos+11);
				newWin = ("True" == value) ? true : false;
			}
		}
		fullUrl = form.action + "?";
		if (form.elements) for (k=0; k<form.elements.length; k++) {
			elem = form.elements[k];
			fullUrl = fullUrl + "&" + elem.name + "=" + escape(elem.value);
		}
		if (newWin) { window.open(fullUrl); return false; }
	}
	return true;
}


