
var xmlHttp_headline
var xmlHttp_news
var xmlHttp_search
var xmlHttp_travel

function GetXmlHttpObject(){ 
  var objXMLHttp=null
  if (window.XMLHttpRequest){
    objXMLHttp=new XMLHttpRequest()
  }
  else if (window.ActiveXObject) {
    objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
  return objXMLHttp
}

function GetContentHeadline(type, contentID){
var linkclass="newslinks"

  xmlHttp_headline=GetXmlHttpObject()
  if (type=="mostpop")url="./mostpop.php?headlinelinkclass="+linkclass+"&new="+Math.random()
  else if(type=="entertainment")url="./entertainment.php?headlinelinkclass="+linkclass+"&new="+Math.random()
  else if(type=="sports")url="./sports.php?headlinelinkclass="+linkclass+"&new="+Math.random()
  else if(type=="health")url="./health.php?headlinelinkclass="+linkclass+"&new="+Math.random()

  if (xmlHttp_headline==null){
    alert ("Browser does not support HTTP Request");
    return;
  }

if (contentID=="Headlineform") xmlHttp_headline.onreadystatechange=stateChangedheadline
else xmlHttp_headline.onreadystatechange=stateChangednews
  xmlHttp_headline.open("GET",url,true)
  xmlHttp_headline.send(null)


}
//this is for the mobile search
function SetAction(SelectObject, BasePath){
	var ThisValue = String(SelectObject.value);
	if(ThisValue.length){
		document.getElementById('MobileSearchForm').action = BasePath+ThisValue+".php";
	} else {
		document.getElementById('MobileSearchForm').action = "";
	}
}
// end mobilesearch


function GetContentNews(type, contentID){

var linkclass="newslinks"

  xmlHttp_news=GetXmlHttpObject()
  if (type=="topstories")url="./topstories.php?headlinelinkclass="+linkclass+"&new="+Math.random()
  else if(type=="us")url="./us.php?headlinelinkclass="+linkclass+"&new="+Math.random()
  else if(type=="world")url="./world.php?headlinelinkclass="+linkclass+"&new="+Math.random()
  else if(type=="tech")url="./tech.php?headlinelinkclass="+linkclass+"&new="+Math.random()

  if (xmlHttp_news==null){
    alert ("Browser does not support HTTP Request");
    return;
  }

if (contentID=="Headlineform") xmlHttp_news.onreadystatechange=stateChangedheadline
else xmlHttp_news.onreadystatechange=stateChangednews
  xmlHttp_news.open("GET",url,true)
  xmlHttp_news.send(null)


}

function GetSearchBar(type, contentID){



  xmlHttp_search=GetXmlHttpObject()
  if (type=="web")url="./search_web.php?new="+Math.random()
  else if(type=="svideo")url="./search_video.php?new="+Math.random()
  else if(type=="shopping")url="./search_shopping.php?new="+Math.random()
  else if(type=="jobs")url="./search_jobs.php?new="+Math.random()
  else if(type=="weather")url="./search_weather.php?new="+Math.random()
  else if(type=="classifieds")url="./search_classifieds.php?new="+Math.random()
  else if(type=="realestate")url="./search_realestate.php?new="+Math.random()
  if (xmlHttp_search==null){
    alert ("Browser does not support HTTP Request");
    return;
  }
  xmlHttp_search.onreadystatechange=stateChangedsearch
  xmlHttp_search.open("GET",url,true)
  xmlHttp_search.send(null)


}


function stateChangedheadline() {  

  if (xmlHttp_headline.readyState==4 || xmlHttp_headline.readyState=="complete"){document.getElementById("Headlineform").innerHTML=xmlHttp_headline.responseText
  } 
}



function stateChangednews() {  

  if (xmlHttp_news.readyState==4 || xmlHttp_news.readyState=="complete"){document.getElementById("Newsform").innerHTML=xmlHttp_news.responseText
  } 
}


function stateChangedsearch() {  

  if (xmlHttp_search.readyState==4 || xmlHttp_search.readyState=="complete"){document.getElementById("Searchform").innerHTML=xmlHttp_search.responseText
  } 
}
function stateChangedtravel() {  
  if (xmlHttp_travel.readyState==4 || xmlHttp_travel.readyState=="complete"){document.getElementById("Travelform").innerHTML=xmlHttp_travel.responseText
  } 
}


function ChooseTab(LIElement,bGetPanelContent){
	var bGetPanelContent = (bGetPanelContent==null) ? 1 : bGetPanelContent;
	aAllTagsToDeselect = LIElement.parentNode.getElementsByTagName("LI");
	bAlsoFirst = 0;
	for(i=0;i<aAllTagsToDeselect.length;i++){
		if(i){
			aAllTagsToDeselect[i].className='';
		} else {
			if(aAllTagsToDeselect[i]==LIElement) bAlsoFirst = 1;
			aAllTagsToDeselect[i].className='first';
		}
	}
		if(bAlsoFirst){
			LIElement.className = 'selected first';
		} else {
			LIElement.className = 'selected';
		}
	RequestedContent = LIElement.getAttribute('id');
	aAllDivs = LIElement.parentNode.parentNode.getElementsByTagName("DIV");
	DivToInsertContentInto = aAllDivs[0].getAttribute('id');
	if(bGetPanelContent){
		GetPanelContent(RequestedContent,DivToInsertContentInto);
	}
}

var aURLVariables
function SetURLVariables(){
	QueryString = document.location.search.substr(1);
	aParts = QueryString.split('&');
	aURLVariables = new Array();
	for(i=0;i<aParts.length;i++){
		ThisVariablePart = aParts[i];
		ThisVariable=ThisVariablePart.split('=');
		aURLVariables[ThisVariable[0]]=ThisVariable[1];
	}
}


function GetBaseDir(){
	URL = String(window.location);
	ThisURL = (URL.indexOf('?')>=0) ? URL.substr(0,URL.indexOf('?')) : URL;

	if(ThisURL.indexOf('~')<0){
		iSlashes = 4;
	} else {
		iSlashes = 6;
	}
	aURL = ThisURL.split('/');
	iNumToRepeat = aURL.length - iSlashes;
	ReturnThis = '';
	if(iNumToRepeat){
		for(i=0;i<iNumToRepeat;i++){
			ReturnThis += '../';
		}
	}
	return ReturnThis;
}

function GetPanelContent(ContentToGet,contentID){
	var linkclass="newslinks"
	switch(contentID){
		case 'Headlineform':
		ThisXML = 'xmlHttp_headline';
		break;
		case 'Newsform':
		ThisXML = 'xmlHttp_news';
		break;
		case 'Searchform':
		ThisXML = 'xmlHttp_search';
		break;
		case 'Travelform':
		ThisXML = 'xmlHttp_travel';
		break;
	}
	BaseDir = GetBaseDir();

	this[ThisXML]=GetXmlHttpObject()
	switch(ContentToGet){
	case "topstories":
		url= BaseDir+"/ehw_v3/topstories.php?headlinelinkclass="+linkclass+"&new="+Math.random();
	break;
	case "us":
		url= BaseDir+"/ehw_v3/us.php?headlinelinkclass="+linkclass+"&new="+Math.random();
	break;
	case "world":
		url= BaseDir+"/ehw_v3/world.php?headlinelinkclass="+linkclass+"&new="+Math.random();
	break;
	case "tech":
		url= BaseDir+"/ehw_v3/tech.php?headlinelinkclass="+linkclass+"&new="+Math.random();
	break;
	case "mostpop":
		url= BaseDir+"/ehw_v3/mostpop.php?headlinelinkclass="+linkclass+"&new="+Math.random();
	break;
	case "entertainment":
		url= BaseDir+"/ehw_v3/entertainment.php?headlinelinkclass="+linkclass+"&new="+Math.random();
	break;
	case "sports":
		url= BaseDir+"/ehw_v3/sports.php?headlinelinkclass="+linkclass+"&new="+Math.random();
	break;
	case "health":
		url= "health.php?headlinelinkclass="+linkclass+"&new="+Math.random();
	break;
	
	case "airfare":
		url = BaseDir+"/ehw_v3/travel/form_airfare.php?new="+Math.random();
	break;
	
	case "hotel":
		url = BaseDir+"/ehw_v3/travel/form_hotel.php?new="+Math.random();
	break;
	
	case "car":
		url = BaseDir+"/ehw_v3/travel/form_cars.php?new="+Math.random();
	break;
	
	
	case "web":
		url= BaseDir+"/ehw_v3/search_web.php?new="+Math.random();
	break;
	case "svideo":
		url= BaseDir+"/ehw_v3/search_video.php"+document.location.search;
	break;
	case "shopping":
		url= BaseDir+"/ehw_v3/search_shopping.php"+document.location.search;
	break;
	case "jobs":
		url= BaseDir+"/ehw_v3/search_jobs.php"+document.location.search;
	break;
	case "weather":
		url= BaseDir+"/ehw_v3/search_weather.php"+document.location.search;
	break;
	case "classifieds":
		url= BaseDir+"/ehw_v3/search_classifieds.php"+document.location.search;
	break;
	case "realestate":
		url= BaseDir+"/ehw_v3/search_realestate.php"+document.location.search;
	break;
	
	default:
		url= BaseDir+"/ehw_v3/search_"+ContentToGet+".php"+document.location.search;
	break;
	}

	if (this[ThisXML]==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	switch(contentID){
		case 'Headlineform':
		this[ThisXML].onreadystatechange=stateChangedheadline
		break;
		case 'Newsform':
		this[ThisXML].onreadystatechange=stateChangednews
		break;
		case 'Searchform':
		this[ThisXML].onreadystatechange=stateChangedsearch
		break;
		case 'Travelform':
		this[ThisXML].onreadystatechange=stateChangedtravel
		break;
	}
	
	this[ThisXML].open("GET",url,true)
	this[ThisXML].send(null)
	

}

function SelectTab(text, tab, is_on){
var activeclass="tab_active"
var inactiveclass="tab_inactive"
var tabheight="20"
var tabwidth="100%"

  if (is_on=='1'){
    document.getElementById(""+tab+"").innerHTML="<table width="+tabwidth+" cellpadding=0 cellspacing=0 border=0 height="+tabheight+"><tr><td bgcolor='#E8E8E8' width=1></td><td align=center class="+activeclass+"><b>"+text+"</b></td><td bgcolor='#E8E8E8' width=1></td></tr></table>"
  }
  else document.getElementById(""+tab+"").innerHTML="<table width="+tabwidth+" cellpadding=0 cellspacing=0 border=0 height="+tabheight+"><tr><td bgcolor='#E8E8E8' width=1></td><td align=center class="+inactiveclass+">"+text+"</td><td bgcolor='#E8E8E8' width=1></td></tr></table>"

}

function SelectInteriorTab(text, tab, is_on){
	var activeclass="tab_interior_active"
	var inactiveclass="tab_interior_inactive"
	if (is_on=='1'){
		document.getElementById(""+tab+"").innerHTML="<div class="+activeclass+">"+text+"</div>";
	} else {
		document.getElementById(""+tab+"").innerHTML="<div class="+inactiveclass+">"+text+"</div>";
	}
	
}


function SelectSearch(text, tab, is_on){
var activeclass="tab_active"
var inactiveclass="tab_inactive"
var tabheight="20"
var tabwidth="100%"

  if (is_on=='1'){
    document.getElementById(""+tab+"").innerHTML="<table width="+tabwidth+" cellpadding=0 cellspacing=0 border=0 height="+tabheight+"><tr><td bgcolor='#E8E8E8' width=1></td><td align=center class="+activeclass+"><b>"+text+"</b></td><td bgcolor='#E8E8E8' width=1></td></tr></table>"
  }
  else document.getElementById(""+tab+"").innerHTML="<table width="+tabwidth+" cellpadding=0 cellspacing=0 border=0 height="+tabheight+"><tr><td bgcolor='#E8E8E8' width=1></td><td align=center class="+inactiveclass+">"+text+"</td><td bgcolor='#E8E8E8' width=1></td></tr></table>"

}


function wopen(url, name, w, h){
// Fudge factors for window decoration space.
 // In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
 var win = window.open(url,
  name, 
  'width=' + w + ', height=' + h + ', ' +
  'location=no, menubar=no, ' +
  'status=no, toolbar=no, scrollbars=yes, resizable=no');
 win.resizeTo(w, h);
 win.focus();
}

