var count_time = 25;
var http_request;

function makeHttpRequest(url, callback_function, return_xml)
{
   var http_request = false;
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
       http_request = new XMLHttpRequest();
       if (http_request.overrideMimeType) {
           http_request.overrideMimeType('text/xml');
       }

   } else if (window.ActiveXObject) { // IE
       try {
           http_request = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
           try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (e) {}
       }
   }

   if (!http_request) {
       alert('Browser doesn\'t support Ajax');
       return false;
   }
   http_request.onreadystatechange = function() {
       if (http_request.readyState == 4) {
           if (http_request.status == 200) {
               if (return_xml) {
                   eval(callback_function + '(http_request.responseXML)');
               } else {
                   eval(callback_function + '(http_request.responseText)');
               }
           } else {
               //alert('There was a problem with the request.(Code: ' + http_request.status + ')');
			    showad();
				repeat();
           }
       }
   }
   hidead();
   http_request.open('GET', url, true);
   http_request.send(null);
}

function loadXML(xml)
{
	if(xml.getElementsByTagName('content01')){	
		var html_content01 = xml.getElementsByTagName('content01').item(0).firstChild.nodeValue;
	}else{
		var html_content01="";
	}
	document.getElementById('html_content').innerHTML = html_content01;
}


function loadDavit(xml)
{
	if(xml.getElementsByTagName('content01')){	
		var html_content01 = xml.getElementsByTagName('content01').item(0).firstChild.nodeValue;
	}else{
		var html_content01="";
	}
	document.getElementById('html_davit').innerHTML = html_content01;
}

function loadSub(xml)
{
	if(xml.getElementsByTagName('content01')){	
		var html_content01 = xml.getElementsByTagName('content01').item(0).firstChild.nodeValue;
	}else{
		var html_content01="";
	}
	document.getElementById('html_sub').innerHTML = html_content01;
}

function loadDavit01(xml)
{
	if(xml.getElementsByTagName('content01')){	
		var html_content01 = xml.getElementsByTagName('content01').item(0).firstChild.nodeValue;
	}else{
		var html_content01="";
	}
	document.getElementById('html_davit01').innerHTML = html_content01;
}

function loadSub01(xml)
{
	if(xml.getElementsByTagName('content01')){	
		var html_content01 = xml.getElementsByTagName('content01').item(0).firstChild.nodeValue;
	}else{
		var html_content01="";
	}
	document.getElementById('html_sub01').innerHTML = html_content01;
}

function hidead()
{
	if(document.getElementById("ad2")){
		document.getElementById("ad2").style.backgroundColor="#000000";
	}

	if (document.getElementById)
	{
		document.getElementById("ad2").style.display = "none";
	}
	else if (document.all)
	{
		document.all["ad2"].style.display = "none";
	}
	else if (document.layers)
	{
		document.layers["ad2"].style.display = "none";
	}
	
	if (document.getElementById)
	{
		document.getElementById("html_content").style.display = "none";
	}
	else if (document.all)
	{
		document.all["html_content"].style.display = "none";
	}
	else if (document.layers)
	{
		document.layers["html_content"].style.display = "none";
	}	
}



function ajax_send_a_friend(val)
{
	if(navigator.appName == "Netscape"){
		div_location(818,17);
	}else{
		div_location(818,7);
	}

	window.scroll(0,0);
	if(document.getElementById("ad2")){
		document.getElementById("ad2").style.backgroundColor="#000000";
	}	
	
	makeHttpRequest('ajax_gen_send.php?hRefer='+val, 'loadXML', true);

	if (document.getElementById)
	{
		document.getElementById("ad2").style.display = "block";
	}
	else if (document.all)
	{
		document.all["ad2"].style.display = "block";
	}
	else if (document.layers)
	{
		document.layers["ad2"].style.display = "block";
	}
	
	if (document.getElementById)
	{
		document.getElementById("html_content").style.display = "block";
	}
	else if (document.all)
	{
		document.all["html_content"].style.display = "block";
	}
	else if (document.layers)
	{
		document.layers["html_content"].style.display = "block";
	}	
	
	
}

function ajax_gen_video(val)
{
	if(navigator.appName == "Netscape"){
		div_location(948,17);
	}else{
		div_location(948,7);
	}

	window.scroll(0,0);
	if(document.getElementById("ad2")){
		document.getElementById("ad2").style.backgroundColor="#000000";
	}	
	
	makeHttpRequest('ajax_gen_video.php?hRefer='+val, 'loadXML', true);

	if (document.getElementById)
	{
		document.getElementById("ad2").style.display = "block";
	}
	else if (document.all)
	{
		document.all["ad2"].style.display = "block";
	}
	else if (document.layers)
	{
		document.layers["ad2"].style.display = "block";
	}
	
	if (document.getElementById)
	{
		document.getElementById("html_content").style.display = "block";
	}
	else if (document.all)
	{
		document.all["html_content"].style.display = "block";
	}
	else if (document.layers)
	{
		document.layers["html_content"].style.display = "block";
	}	
	
	
}


function ajax_gen_annual(val)
{
	if(navigator.appName == "Netscape"){
		div_location(559,17);
	}else{
		div_location(559,7);
	}

	window.scroll(0,0);
	if(document.getElementById("ad2")){
		document.getElementById("ad2").style.backgroundColor="#000000";
	}	
	
	makeHttpRequest('ajax_gen_annual.php?hId='+val, 'loadXML', true);

	if (document.getElementById)
	{
		document.getElementById("ad2").style.display = "block";
	}
	else if (document.all)
	{
		document.all["ad2"].style.display = "block";
	}
	else if (document.layers)
	{
		document.layers["ad2"].style.display = "block";
	}
	
	if (document.getElementById)
	{
		document.getElementById("html_content").style.display = "block";
	}
	else if (document.all)
	{
		document.all["html_content"].style.display = "block";
	}
	else if (document.layers)
	{
		document.layers["html_content"].style.display = "block";
	}	
	
	
}


function ajax_gen_annual01(val)
{
	alert("ddd");

	if(navigator.appName == "Netscape"){
		div_location(559,17);
	}else{
		div_location(559,7);
	}

	window.scroll(0,0);
	if(document.getElementById("ad2")){
		document.getElementById("ad2").style.backgroundColor="#000000";
	}	
	
	makeHttpRequest('ajax_gen_annual.php?hId='+val, 'loadXML', true);

	if (document.getElementById)
	{
		document.getElementById("ad2").style.display = "block";
	}
	else if (document.all)
	{
		document.all["ad2"].style.display = "block";
	}
	else if (document.layers)
	{
		document.layers["ad2"].style.display = "block";
	}
	
	if (document.getElementById)
	{
		document.getElementById("html_content").style.display = "block";
	}
	else if (document.all)
	{
		document.all["html_content"].style.display = "block";
	}
	else if (document.layers)
	{
		document.layers["html_content"].style.display = "block";
	}	
	
	
}

	
function search_davit(val)
{	
	makeHttpRequest('ajax_gen_davit.php?val='+val, 'loadDavit', true);	
}

function search_sub(val)
{	
	makeHttpRequest('ajax_gen_sub.php?val='+val, 'loadSub', true);	
}

function search_davit01(val)
{	
	makeHttpRequest('ajax_gen_davit.php?val='+val, 'loadDavit01', true);	
}

function search_sub01(val)
{	
	makeHttpRequest('ajax_gen_sub.php?val='+val, 'loadSub01', true);	
}

function div_location(var_x,var_y) { 
	w = pageWidth();
	h = pageHeight();
	
	
    var winl = ((w- var_x) / 2)-var_y;

	eval('document.getElementById("html_content").style.top="20px"');
	eval('document.getElementById("html_content").style.left="'+winl+'px"');

	//alert(winl);
	//document.getElementById("html_content").style.top=wint;
	
  } 		  
 function pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null; }
 function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}		
