function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
  {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
    // Internet Explorer
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}


function update_ads_hits(str)
{
  if (str.length==0)
  { 
    return;
  }
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
    alert ("Your browser does not support AJAX! Some function will not be running!");
    return;
  } 
  var url="includes/update_hits.php";
  url=url+"?ads="+str;
  url=url+"&sid="+Math.random();
  xmlHttp.onreadystatechange = function() {
				if (xmlHttp.readyState == 4) {
					// only if "OK"
					if (xmlHttp.status == 200) {					
						document.getElementById ('hits'+str).value= xmlHttp.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
					}
				}};	
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}


function poll_result (id, divId)
{
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
    alert ("Your browser does not support AJAX! Some function will not be running!");
    return;
  } 
  var url="includes/polling_result.php";
  url=url+"?id="+id;
  url=url+"&sid="+Math.random();
  xmlHttp.onreadystatechange = function() {
				if (xmlHttp.readyState == 4) {
					// only if "OK"
					if (xmlHttp.status == 200) {					
						document.getElementById (divId).innerHTML= xmlHttp.responseText;	
						document.getElementById (divId).style.visibility='visible';
					} else {
						alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
					}
				}};	
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}

function get_subscription (menu,trans_id)
{
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
    alert ("Your browser does not support AJAX! Some function will not be running!");
    return;
  } 

  var url="includes/subscription.php";
  url=url+"?m="+menu+"&d="+trans_id;
  url=url+"&sid="+Math.random();
  xmlHttp.onreadystatechange = function() {
				if (xmlHttp.readyState == 4) {
					// only if "OK"
					if (xmlHttp.status == 200) {				
						document.getElementById ('print_area').innerHTML= xmlHttp.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
					}
				}};	
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);

}

function change_video (src,vid_width,vid_height)
{
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
    alert ("Your browser does not support AJAX! Some function will not be running!");
    return;
  } 

  var phpfile="includes/get_video.php";
  phpfile=phpfile+"?v="+src+"&w="+vid_width+"&h="+vid_height;
  phpfile=phpfile+"&sid="+Math.random();
  xmlHttp.onreadystatechange = function() {
				if (xmlHttp.readyState == 4) {
					// only if "OK"
					if (xmlHttp.status == 200) {				
						document.getElementById ('video_player').innerHTML= xmlHttp.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" +  xmlHttp.statusText);
					}
				}};	
  xmlHttp.open("GET",phpfile,true);
  xmlHttp.send(null);
}

function password_recovery(divId)
{
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
    alert ("Your browser does not support AJAX! Some function will not be running!");
    return;
  } 
  document.getElementById (divId).style.visibility="visible";
  var url="includes/password_recovery.php";
  url=url+"?sid="+Math.random();
  xmlHttp.onreadystatechange = function() {
				if (xmlHttp.readyState == 4) {
					// only if "OK"
					if (xmlHttp.status == 200) {				
						document.getElementById (divId).innerHTML= xmlHttp.responseText;					
					} else {
						alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
					}
				}};	
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);	
}

function hidediv(divId)
{
  document.getElementById(divId).style.visibility="hidden";
}

function showdiv(divId)
{
  document.getElementById(divId).style.visibility="visible";
}

function autoclosediv(divId, delay)
{
  setTimeout (function (){},delay);
  document.getElementById(divId).style.visibility="hidden";
}



function convert(txtfield_id)
{
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
    alert ("Your browser does not support AJAX! Some function will not be running!");
    return;
  } 
  var amt=document.getElementById ('curr1amt').value;
  var curr1=document.getElementById ('curr1').value;
  var curr2=document.getElementById ('curr2').value;
  var url="includes/currency_calc.php";
  url=url+"?amt="+amt;
  url=url+"&curr1="+curr1;
  url=url+"&curr2="+curr2;
  url=url+"&sid="+Math.random();
  xmlHttp.onreadystatechange = function() {
				if (xmlHttp.readyState == 4) {
					// only if "OK"
					if (xmlHttp.status == 200) {					
						document.getElementById(txtfield_id).innerHTML= xmlHttp.responseText;
					} else {
						alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
					}
				}};	
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}

function switch_tab(active_tab, tabs_count, category) 
{
	var tabs_prefix= 'tab';

	for (var i=1; i < tabs_count+1; i++) 
	{
		document.getElementById(tabs_prefix+i).className = '';
	}
	document.getElementById(tabs_prefix+active_tab).className = 'active';	

	xmlHttp= GetXmlHttpObject();
	if (xmlHttp==null)
  	{
        	alert ("Your browser does not support AJAX! Some function will not be running!");
          	return;
  	} 

        var url="includes/get_product.php";
        url = url + "?pd="+ category + "&t=" + active_tab +"&sid="+Math.random();;
        xmlHttp.onreadystatechange = function () {
                                      	if (xmlHttp.readyState == 4) {
					// only if "OK"
					if (xmlHttp.status == 200) {				
						document.getElementById('tab_content').innerHTML= xmlHttp.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				     }};

       	xmlHttp.open("GET",url,true);
  	xmlHttp.send(null);
}

function switch_hm_tab(active_tab, tabs_count, menu) 
{
	var tabs_prefix= 'hm_menu_tabs';

	for (var i=1; i < tabs_count+1; i++) 
	{
		document.getElementById(tabs_prefix+i).className = '';
	}
	document.getElementById(tabs_prefix+active_tab).className = 'active';	

	xmlHttp= GetXmlHttpObject();
	if (xmlHttp==null)
  	{
        	alert ("Your browser does not support AJAX! Some function will not be running!");
          	return;
  	} 

        var url="includes/get_home_item.php";
        url = url + "?m="+ menu + "&sid="+Math.random();;
        xmlHttp.onreadystatechange = function () {
                                      	if (xmlHttp.readyState == 4) {
					// only if "OK"
					if (xmlHttp.status == 200) {				
						 document.getElementById('hm_tab_content').innerHTML= xmlHttp.responseText;
						//alert (xmlHttp.responseText);						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				     }};

       	xmlHttp.open("GET",url,true);
  	xmlHttp.send(null);
}