// JavaScript global functions in pg_header.inc.php
function openpopup(url, width, height, sbar, rsize){winpops=window.open(url,"",+"'"+"scrollbars="+ sbar +", resizable="+ rsize +", width="+ width +", height="+ height +", left=350, top=200"+"'")} 
function confirmDelete(str, title){ if ((window.confirm('Are you sure you want to '+ str + ': \n"'+ title +'"?')) == true) return true; else return false; }
function validate(){ 
formObj = document.index; 
if (isValidEmail(formObj.email.value) == false){
	alert("Please enter valid email address. Thank You.");
	return false;
}else{
	return true; 
	}
} 
//return true if . and @ exist
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
function noexchange(){
	formObj = document.index;
	if(formObj.nocheck.checked == true){
		formObj.reclink.value = formObj.domainname.value;
	}else{
		formObj.reclink.value = "";
	}
}
function gethtmltitle(url,cat,email,reclink){
	formObj = document.index;
	if(url==""){
		alert("Website url field empty!");
	}else{
		if(formObj.reclink.value==""){
		reclink = url;
		}
		var attrbs ="&c="+cat+"&em="+email+"&rl="+reclink;
		if(url.indexOf('http://') ==-1){
			url = "http://"+url;
		}
		var geturl = "scr_gethtmltitle.php?remurl=";
		//location.href(geturl+url+attrbs);
		location.replace(geturl+url+attrbs);
		url="";
		cat="";
		email="";
		reclink="";
	}
}

function copylink(){
	var info = document.getElementById('linkinfo').innerText;
	if (window.clipboardData) {
		window.clipboardData.setData("Text", info);
		alert("Linking info copied to your clipboard");
	}else{
		alert("Works in IE only. Please highlight text and copy.");
	}
}

//AJAX functions
function getContent(page, params, elementid, waitmsg){
//params has to have following format
//i.e.: c=1&id=3....
//page is the server side script include full path 
//i.e. ../beseen/myscript.php
var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = page+params; //This is the path to the page
    xmlhttp.open('GET', file, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
    xmlhttp.onreadystatechange=function() {
		if(xmlhttp.readyState == 1){ 
		document.getElementById(elementid).innerHTML = "<p><img src='./images/waiting.gif' align='middle'> Please wait... <br />"+waitmsg+"</p>" ; 
		}else if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved ***
                if( content ){ //Make sure there is something in the content variable
                      document.getElementById(elementid).innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
                }
        }
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}