// JavaScript Documentvar xmlHttp
var xmlHttp

function do_import(){
	var importer=document.getElementById('importer').value;
	var login=document.getElementById('login').value;
	var password=document.getElementById('password').value;
	var icontact= document.getElementById('contact');	
	var xmlhttp = GetXmlHttpObject();
	  //xmlhttp = xmlhttp_init();
	  xmlhttp.open("GET", "tools.php?iact=clogin&id="+importer+"&login="+login+"&pass="+password,true);
	  xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) 
		{
			icontact.innerHTML=xmlhttp.responseText;
			alert(xmlhttp.responseText);
		}
	  }
	  xmlhttp.send(null)		
}

function showLoginForm(importer){
	
	var iform = document.getElementById('login_form_div');
	
	var xmlhttp = GetXmlHttpObject();
	  //xmlhttp = xmlhttp_init();
	  xmlhttp.open("GET", "tools.php?iact=cform&id="+importer,true);
	  xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) 
		{
			iform.innerHTML=xmlhttp.responseText;
			//alert(xmlhttp.responseText);
		}
	  }
	  xmlhttp.send(null)		
}

function setVisible(id,visible){
		
  //var xmlhttp = "";
	  var xmlhttp = GetXmlHttpObject();
	  //xmlhttp = xmlhttp_init();
	  xmlhttp.open("GET", "tools.php?iact=visible&id="+id+"&visible="+visible,true);
	  xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) 
		{
			window.location.reload();
	
		}
	  }
	  xmlhttp.send(null)		
}

function ihelp(id){
		var ihelp = document.getElementById('ihelp');	
  //var xmlhttp = "";
	  	var xmlhttp = GetXmlHttpObject();
	  //xmlhttp = xmlhttp_init();
	  xmlhttp.open("GET", "tools.php?iact=help&id="+id,true);
	  xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) 
		{
			ihelp.innerHTML="<p align=\"justify\">"+xmlhttp.responseText;+"</p>";
	
		}
	  }
	  xmlhttp.send(null)	
}

function purge_mail(){
	var xmlhttp = GetXmlHttpObject();
	  //xmlhttp = xmlhttp_init();
	  xmlhttp.open("GET", "tools.php?iact=purge",true);
	  xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) 
		{
			alert(xmlhttp.responseText);
	
		}
	  }
	  xmlhttp.send(null)	
}


function SetReadTag(id,memberid)
{
  //var xmlhttp = "";
  var xmlhttp = GetXmlHttpObject();
  //xmlhttp = xmlhttp_init();
  xmlhttp.open("GET", "readtag.php?id="+id+"&member="+memberid,true);
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4) 
    {
		window.location.reload();
    }
  }
  xmlhttp.send(null)
}



function squeeze(){

	
	var jsdiv = document.getElementById('js_div');
	id= document.getElementById('productID').value;
	memberid= document.getElementById('MemberID').value;
	email= document.getElementById('email').value;
	name= document.getElementById('name').value;
  	var xmlhttp = GetXmlHttpObject();
  //xmlhttp = xmlhttp_init();
  xmlhttp.open("GET", "squ3rdparty.php?id="+id+"&memberid="+memberid+"&email="+email+"&name="+name,true);
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4) 
    {
			
		var rt_split = 	xmlhttp.responseText;
		
		ar_temp=rt_split.split("[]");
		
		if (ar_temp[0]=='addnew'){	
			jsdiv.innerHTML=ar_temp[1];
			document.form_post.submit();
		} 
		
		if (ar_temp[0]=='postoto'){		
			window.location.href=ar_temp[1];
		}
		
    }
  }
  xmlhttp.send(null)

}


function register(id,memberid,oto,pname)
{

        var jsdiv = document.getElementById('js_div');
        var xmlhttp = GetXmlHttpObject();
  //xmlhttp = xmlhttp_init();
  xmlhttp.open("GET", "reg3rdparty.php?id="+id+"&member="+memberid,true);
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4)
    {

                var rt_split =  xmlhttp.responseText;

                ar_temp=rt_split.split("[]");

                if (ar_temp[0]=='addnew'){
                	alert('We have sent you an email to confirm your your registration of this product. Please look out for it in your inbox. In the meantime, please read the following page carefully.');
                        jsdiv.innerHTML=ar_temp[1];
                        document.form_post.submit();
			window.open(ar_temp[1],'','');
			window.location.reload();
                }

                if (ar_temp[0]=='postoto'){
//                        window.location.href=ar_temp[1];
                	alert('We have sent you an email to confirm your your registration of this product. Please look out for it in your inbox. In the meantime, please read the following page carefully..');
                        window.open(ar_temp[1],'','');
                        window.location.reload();
                }

    }
  }
  xmlhttp.send(null)

}


function showField(tp,id)
{
	var opdf = document.getElementById('onlinepdf');
	if (tp=='PDFONLINE'){	
  //var xmlhttp = "";
	  var xmlhttp = GetXmlHttpObject();
	  //xmlhttp = xmlhttp_init();
	  xmlhttp.open("GET", "showfield.php?id="+id,true);
	  xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) 
		{
			//window.location.reload();
			opdf.innerHTML=xmlhttp.responseText;
			//window.open(oto,'','');
			
			
			showDiv('PDFONLINE');
	
		}
	  }
	  xmlhttp.send(null)
	} else {
		opdf.innerHTML="";
		showDiv('REBRANDER');
	}
}

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;
}


