var http = false;

if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
   http = new XMLHttpRequest();
}

function CatBox(div, id, val) {
  http.open("GET", "ajax-loads/load-catbox-content.php?cID="+id+"&stop="+val, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById(div).innerHTML = http.responseText;
    }
  }
  http.send(null);
}

function NmzBox(div, id) {
  http.open("GET", "/namaz-vakitleri.php?q="+id, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById(div).innerHTML = http.responseText;
    }
  }
  http.send(null);
}

function TopNewsBox(div, day) {
  http.open("GET", "/ajax-loads/mostly-content.php?q="+day, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById(div).innerHTML = http.responseText;
    }
  }
  http.send(null);
}

function MainTopNewsBox(div, day) {
  http.open("GET", "/ajax-loads/mainpage-mostly-content.php?q="+day, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById(div).innerHTML = http.responseText;
    }
  }
  http.send(null);
}

function MansetMenu(div,con) {
	if(document.getElementById(div).innerHTML == ''){
		http.open("GET", "/ajax-loads/load-manset-bar-content.php", true);
		http.onreadystatechange=function() {
			if(http.readyState == 4) {
				document.getElementById(div).innerHTML = http.responseText;
				document.getElementById(con).style.height = 380+"px";
				document.getElementById("trigger").innerHTML = '<img src="http://image.haber7.com/v3/images2/mansetsubbarup.png" border="0" alt="Manşeti Gizle">';
				crawlhide();showhl('spot0');showit('image0');showhl('title0');showit('hour0');
			}
		}
		http.send(null);
	}else{
		document.getElementById(div).innerHTML = '';
		document.getElementById(con).style.height = 20+"px";
		document.getElementById("trigger").innerHTML = '<img src="http://image.haber7.com/v3/images2/mansetsubbar.png" border="0" alt="Manşeti Göster">';
	}
}

function selectAjax(address, str)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url = address
	url=url+"?q="+str
	//url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET", url, true)
	xmlHttp.send(null)
}

function stateChanged(divID)
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   	{
   		document.getElementById("divID").innerHTML=xmlHttp.responseText
   	}
}

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

function FavNews(div, id, author) {
	var suffix = '';
  if(author == 1) suffix = '&a=1';
  http.open("GET", "/ajax-loads/news-favourite.php?q="+id+suffix, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById(div).innerHTML = http.responseText;
    }
  }
  http.send(null);
}
