

//Global Var
var searchTxt = "";
var searchMethod = "web"
//document.onkeypress = DisplayMsg;

function DisplayMsg(key_event)
{
    searchTxt = document.aspnetForm.text1.value;
}


function Trim(str)
{  
	str = str.substring(0,str.length-1)
	return str;
}

function searchNow() {
	txtQuery = document.aspnetForm.text1.value;
	
	if (searchMethod == "web") {
		url="http://www.google.com/search?hl=ar&q=" + txtQuery.replace(/ /g,"+");
		popitup(url);
	}
	else if (searchMethod == "picture") {
		url="http://images.google.com/images?hl=ar&q=" + txtQuery.replace(/ /g,"+");
		popitup(url);
	}
	else if (searchMethod == "map") {
		url="http://maps.google.com/maps?hl=ar&tab=wl&q=" + txtQuery.replace(/ /g,"+");
		popitup(url);
	}
	else if (searchMethod == "news") {
		url="http://news.google.com/news?pz=1&ned=ar_me&hl=ar&q=" + txtQuery.replace(/ /g,"+");
		popitup(url);
	}
	else {
	url="http://www.google.com/search?hl=ar&q=" + txtQuery.replace(/ /g,"+");
	popitup(url);
	}
}

function updateSearchMethod(x){
	searchMethod = x;
	if (searchMethod == "web") {
		resetYamliColor();
		document.getElementById("yamlisearchoption_web").style.color="#ffffff";
		document.getElementById("yamlisearchoption_web").style.background="#800000";
	}
	else if (searchMethod == "picture") {
		resetYamliColor();
		document.getElementById("yamlisearchoption_images").style.color="#ffffff";
		document.getElementById("yamlisearchoption_images").style.background="#800000";
	}
	else if (searchMethod == "map") {
		resetYamliColor();
		document.getElementById("yamlisearchoption_video").style.color="#ffffff";
		document.getElementById("yamlisearchoption_video").style.background="#800000";
	}
	else {
	resetYamliColor();
	document.getElementById("yamlisearchoption_web").style.color="#ffffff";
	document.getElementById("yamlisearchoption_web").style.background="#800000";
	}
}

function resetYamliColor() {
	document.getElementById("yamlisearchoption_web").style.color="#333333";
	document.getElementById("yamlisearchoption_images").style.color="#333333";
	document.getElementById("yamlisearchoption_video").style.color="#333333";
	document.getElementById("yamlisearchoption_web").style.background="";
	document.getElementById("yamlisearchoption_images").style.background="";
	document.getElementById("yamlisearchoption_video").style.background="";
}


function popitup(url) {
	newwindow=window.open(url,'name','height=600,width=800,scrollbars=1,resizable=1');
	if (window.focus) {newwindow.focus()}
	return false;
}

