function showMenu(comId)
{
	x = document.getElementById(comId);
	chkmouseover(comId);
	for(i=0;i<document.forms.length;i++)
	{
		var theForm = document.forms[0];
		for(p=0;p<theForm.elements.length;p++)
		{
			if(theForm.elements[p].type == 'select-one')
				theForm.elements[p].style.display = 'none';
		}
	}
	return true;
}

function hideMenu(comId)
{
	x = document.getElementById(comId);

	chkmouseout(comId);
	for(i=0;i<document.forms.length;i++)
	{
		var theForm = document.forms[0];
		for(p=0;p<theForm.elements.length;p++)
		{
			if(theForm.elements[p].type == 'select-one')
				theForm.elements[p].style.display = '';
		}
	}
	return true;
}

function chkmouseover(passobj)
{
	x = document.getElementById(passobj);
	curX = findPosX(x);
	curY = findPosY(x);
	//alert("curX " + curX);
	//alert("curY " + curY);

	y = document.getElementById('menu' + passobj);

	y.style.display = '';

	if(passobj == 'catmenu' || passobj == 'supportmenu' || passobj == 'actcatmenu' || passobj == 'actsupportmenu')
	{
		if(navigator.appName == 'Microsoft Internet Explorer')
		{
			y.style.top = curY + 108;
			y.style.left = curX - 222;
		}
		else
		{
			y.style.top = (curY + 1) + "px";
			y.style.left = (curX - 222) + "px";
		}
	}
	else
	{
		if(navigator.appName == 'Microsoft Internet Explorer')
		{
			y.style.top = curY + 49;
			y.style.left = curX - 1;
		}
		else
		{
			y.style.top = (curY + 49) + "px";
			y.style.left = (curX + 0) + "px";
		}
	}
	//alert(y.style.top);
	//alert(y.style.left);
}

function chkmouseout(passobj)
{
	y = document.getElementById('menu' + passobj);

	y.style.display = 'none';
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function screenWidth()
{
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	return frameWidth;
}



function screenHeight()
{
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	return frameHeight;
}

function noOfRecChanged(frm)
{
	//alert(location.protocol + "://" + location.host + location.port + location.port + location.pathname);
	//var urlstr = location.protocol + "//" + location.host + location.port + location.port + location.pathname;
	//window.location = urlstr + '?recchange='+comval;
	frm.submit();
	return true;
}

function ChkUncheckBoxes(frm)
{
	var passtype = frm.chkAll.checked;
	var noof = frm.totalrec.value;
	var comobj;
	
	if(passtype == true)
	comclass = "checked";
	else
	comclass = "notchecked";
	
	for(i=0;i<noof;i++)
	{
		//alert(eval("frm.chk_" + i + ".checked"));
		eval("frm.chk_" + i + ".checked = " + passtype);
		x = document.getElementById("tr_" + i);
		//x.className = comclass;
	}
	return true;
}

function check_uncheck_boxes(frm)
{
	var passtype = frm.chkAll.checked;
	var noof = frm.totalrec.value;
	var comobj;
	
	for(i=0;i<noof;i++)
	{
		var x = document.getElementById("chk_domains_" + i);
		
		x.checked = passtype;
	}
	return true;
}

function ChkUncheckIndBoxes()
{
	return true;
}

function passCheckVariables(frm)
{
	var chkform = document.frmChange;
	var noof = chkform.totalrec.value;
	
	var tmpcnt = 0;
	for(i=0;i<noof;i++)
	{
		comcheckstatus = eval("chkform.chk_" + i + ".checked");
		
		if(comcheckstatus == true)
		{
			if(tmpcnt == 0)
				frm.hidSelectedIDs.value += eval("chkform.chk_" + i + ".value");
			else
				frm.hidSelectedIDs.value += "\r\n" + eval("chkform.chk_" + i + ".value");
			
			tmpcnt++;
		}
	}
	//alert(frm.hidGivenNames.value);
	return true;
}

function trOver(passid)
{
	obj = document.getElementById(passid);

	rows = document.getElementById(passid).getElementsByTagName("td");
	for(i=0;i<rows.length;i++)
	{
		tdobj = rows[i];
		tdobj.style.background='#D2DAFF';
	}
	return true;
}

function trOut(passid)
{
	obj = document.getElementById(passid);
	rows = document.getElementById(passid).getElementsByTagName("td");
	for(i=0;i<rows.length;i++)
	{
		tdobj = rows[i];
		if(tdobj.className == 'shortTD')
		tdobj.style.background='#F0F0F0';
		else
		tdobj.style.background='';
	}
	return true;
}


function chkmouseover(baseid,newid,selectid)
{
	x = document.getElementById(baseid);
	curX = findPosX(x);
	curY = findPosY(x);

	
	//for(i=0;i<document.forms.length;i++)
	//{
		//var theForm = document.forms[i];
		//var theForm = document.frmQuickUpdForm;
		if(selectid == 'txtIntStatusUpd')
		{
		document.getElementById('slLegalUpd').style.display = 'none';
		document.getElementById('slFlagUpd').style.display = 'none';
		document.getElementById('slGenericUpd').style.display = 'none';
		}
		else if(selectid == 'slGenericUpd')
		{
		document.getElementById('slLegalUpd').style.display = 'none';
		document.getElementById('slFlagUpd').style.display = 'none';
		}
		else if(selectid == 'slFlagUpd')
		{
		document.getElementById('slLegalUpd').style.display = 'none';
		}
		
		
	//}
	//alert("curX " + curX);
	//alert("curY " + curY);
	y = document.getElementById(newid);
	y.style.display = '';

	if(navigator.appName == 'Microsoft Internet Explorer')
	{
		y.style.top = curY + 20;
		y.style.left = curX;
	}
	else
	{
		y.style.top = (curY) + 20 + "px";
		y.style.left = (curX) + "px";
	}
	return true;
}

function chSelValue(divid,selectid,selind)
{
	var frm = document.frmQuickUpdForm;
	eval("frm." + selectid + ".options[" + selind + "].selected = true");
	return showHideSelDiv(divid,selectid);
}

function showHideSelDiv(divid,selectid)
{
	d = document.getElementById(divid);
	curdis = d.style.display;

	if(curdis == '')
	{
		d.style.display = 'none';
		var theForm = document.frmQuickUpdForm;
		for(p=0;p<theForm.elements.length;p++)
		{
			if(theForm.elements[p].type == 'select-one' && theForm.elements[p].name != selectid)
				theForm.elements[p].style.display = '';
		}
	}
	else
	{
		d.style.display = '';
		chkmouseover(selectid,divid,selectid);
	}
	return true;
}


function showHideAccountCurrency(rowid)
{
	x = document.getElementById(rowid);
	// checking the value of api key field and partner-id field
	var apikey = document.frmQuickAddForm.txtSedoApiKey.value;
	var partnerkey = document.frmQuickAddForm.txtSedoRegId.value;
	
	if (apikey || partnerkey)
	{
//		alert('y');
		x.style.display = '';
	}
	else
	{
		x.style.display = 'none';
//		alert('n');
	}
	return true;
}

function clickEventHand(evt)
{
	if(navigator.appName == 'Microsoft Internet Explorer')
	{
		var comid = evt.srcElement;
	}
	else
	{
		var comid = evt.target;
	}
	//alert(comid.parentNode);
	var nohidding = 0;
	//document.getElementById('IconsTable').style.display = 'none';
	if(comid.parentNode)
	{
		x = document.getElementById('IconsTable');
		if(comid.parentNode != 'javascript:void(0)' && comid.id != 'IconsTable' && x)
		document.getElementById('IconsTable').style.display = 'none';
		
		if(comid.parentNode.id == 'closedivlink')
		nohidding = 1;
	}
	//if(comid.id == 'GenStatusDiv' ||
	if(!nohidding)
	{
		a = document.getElementById('GenStatusDiv');
		b = document.getElementById('IntStatusDiv');
		c = document.getElementById('FlagDiv');
		d = document.getElementById('LegStatusDiv');
		
		if(a)
		document.getElementById('GenStatusDiv').style.display = 'none';
		if(b)
		document.getElementById('IntStatusDiv').style.display = 'none';
		if(c)
		document.getElementById('FlagDiv').style.display = 'none';
		if(d)
		document.getElementById('LegStatusDiv').style.display = 'none';
		
		var theForm = document.frmQuickUpdForm;
		if(theForm)
		{
			for(p=0;p<theForm.elements.length;p++)
			{
				if(theForm.elements[p].type == 'select-one')
					theForm.elements[p].style.display = '';
			}
		}
	}
	//document.getElementById('GenStatusDiv').style.display = 'none';
	
	//alert(comid.id + " --- " + comid.parentNode + " --- " + comid.name);
	/*for(property in comid)
    {
         // Show "property" and "type property"
         nodeName = "IMG"
         nodeValue = "null";
         nodeType = 1
         parentNode = "javascript:void(0)"
         childNoted = list
         firs
         localName = "IMG"
         tagName
         id = ""
         title = ""
         lang = ""
         dir = ""
         className = ""
         name = ""
         align = ""
         alt = ""
         src
          alert(property + " --- " + comid[property]);
     }*/
	return true;
}

function sedoUpdate()
{
	document.frmChange.submit();
	return true;
}

function periodPresetSet(frm,curdate,yestdate,last7date,firstdate,lastmonthstart,lastmonthend,last30days,last3mon)
{
	s = document.getElementById("period_preset");
	//f = document.getElementById(idFrom);
	//t = document.getElementById(idTo);
	
	selindex = parseInt(s.selectedIndex);
	selval = String(eval("frm.period_preset[" + selindex + "].value"));
	
	x = document.getElementById("qckSearchUpd");
	s = document.getElementById('slGroupBy');
//	alert(s.value);
	periodto = curdate;
	//alert(selval);
	if(selval == 'yesterday')
	{
		periodfrom = yestdate;
		periodto = yestdate;
		if (s) {
			if (s.value == 'domain' && x)
				x.style.display = '';
		}
		else if(x){
			x.style.display = '';
		}
	}
	if(selval == 'today')
	{
		periodfrom = curdate;
		if (s) {
			if (s.value == 'domain')
				x.style.display = '';
		}
		else if(x){
			x.style.display = '';
		}
	}
	if(selval == 'last7days')
	{
		periodfrom = last7date;
		if (s) {
			if (s.value == 'domain')
				x.style.display = '';
		}
		else if(x){
			x.style.display = '';
		}
	}
	if(selval == 'monthtodate')
	{
		periodfrom = firstdate;
		if (s) {
			if (s.value == 'domain') 
				x.style.display = '';
		}
		else if(x){
			x.style.display = '';
		}
	}
	if(selval == 'lastmonth')
	{
		periodfrom = lastmonthstart;
		periodto = lastmonthend;
		if (s) {
			if (s.value == 'domain') 
				x.style.display = '';
		}
		else if(x){
			x.style.display = '';
		}
	}
	if(selval == 'last30days')
	{
		periodfrom = last30days;
		if (s) {
			if (s.value == 'domain') 
				x.style.display = '';
		}
		else if(x){
			x.style.display = '';
		}
	}
	if(selval == 'last3months')
	{
		periodfrom = last3mon;
		if (s) {
			if (s.value == 'domain') 
				x.style.display = '';
		}
		else if(x){
			x.style.display = '';
		}
	}
	if(selval == 'alltime')
	{
		periodfrom = "";
		periodto = "";
		if (s) {
			if (s.value == 'domain') 
				x.style.display = '';
		}
		else if(x){
			x.style.display = '';
		}
	}
	if(selval == 'custom')
	{
		if (s) {
			if (s.value == 'domain') 
				x.style.display = 'none';
		}
		else if(x){
			x.style.display = 'none';
		}
	}
	//alert(periodfrom);
	frm.view_period_from.value = periodfrom;
	frm.view_period_to.value = periodto;
	return true;
}
function periodPresetSetOld(frm,date,month,year)
{
	s = document.getElementById("period_preset");
	//f = document.getElementById(idFrom);
	//t = document.getElementById(idTo);
	
	selindex = parseInt(s.selectedIndex);
	selval = String(eval("frm.period_preset[" + selindex + "].value"));
	
	myDate = new Date();
	myDate.setFullYear(year,month,date);
	curfulldate = myDate;
	
	curintdate = parseInt(myDate.getDate());
	curintmonth = parseInt(myDate.getMonth()) + 1;
	curintyear = parseInt(myDate.getYear()) + 0;
	
	var curyear = String(curintyear);
	if(String(curintdate).length == 1)
		var curdate = String("0" + curintdate);
	else
		var curdate = String(curintdate);
	
	if(String(curintmonth).length == 1)
		var curmonth = String("0" + curintmonth);
	else
		var curmonth = String(curintmonth);
	
	periodto = curyear + "-" + curmonth + "-" + curdate;
	//alert(selval);
	if(selval == 'yesterday')
	{
		fromintdate = parseInt(myDate.getDate()) - 1;
		fromintmonth = parseInt(myDate.getMonth()) + 1;
		fromintyear = parseInt(myDate.getYear()) + 0;
		
		if(s.value == 'domain')
		x.style.display = '';
	}
	if(selval == 'today')
	{
		fromintdate = parseInt(myDate.getDate()) + 0;
		fromintmonth = parseInt(myDate.getMonth()) + 1;
		fromintyear = parseInt(myDate.getYear()) + 0;
		if(s.value == 'domain')
		x.style.display = '';
	}
	if(selval == 'last7days')
	{
		fromintdate = parseInt(myDate.getDate()) - 6;
		fromintmonth = parseInt(myDate.getMonth()) + 1;
		fromintyear = parseInt(myDate.getYear()) + 0;
		if(s.value == 'domain')
		x.style.display = '';
	}
	if(selval == 'monthtodate')
	{
		fromintdate = parseInt(1);
		fromintmonth = parseInt(myDate.getMonth()) + 1;
		fromintyear = parseInt(myDate.getYear()) + 0;
		if(s.value == 'domain')
		x.style.display = '';
	}
	if(selval == 'lastmonth')
	{
		fromintdate = parseInt(myDate.getDate()) + 0;
		fromintmonth = parseInt(myDate.getMonth()) + 0;
		fromintyear = parseInt(myDate.getYear()) + 0;
		if(s.value == 'domain')
		x.style.display = '';
	}
	if(selval == 'last30days')
	{
		fromintdate = parseInt(myDate.getDate());
		fromintmonth = parseInt(myDate.getMonth()) + 0;
		fromintyear = parseInt(myDate.getYear()) + 0;
		if(s.value == 'domain')
		x.style.display = '';
	}
	if(selval == 'last3months')
	{
		fromintdate = parseInt(myDate.getDate()) + 0;
		fromintmonth = parseInt(myDate.getMonth()) - 2;
		fromintyear = parseInt(myDate.getYear()) + 0;
		if(s.value == 'domain')
		x.style.display = '';
	}
	
	var fromyear = String(fromintyear);
//	alert(fromintdate);
	if(String(fromintdate).length == 1)
		var fromdate = String("0" + fromintdate);
	else
		var fromdate = String(fromintdate);
	
	if(String(fromintmonth).length == 1)
		var frommonth = String("0" + fromintmonth);
	else
		var frommonth = String(fromintmonth);

	periodfrom = fromyear + "-" + frommonth + "-" + fromdate;
	
	if(selval == 'alltime')
	{
		periodfrom = "";
		periodto = "";
		if(s.value == 'domain')
		x.style.display = '';
	}
	
	//alert(periodfrom);
	frm.view_period_from.value = periodfrom;
	frm.view_period_to.value = periodto;
	return true;
}

function periodPresetUnset(idSelect) {
	
	s = document.getElementById(idSelect);
	s.selectedIndex = 0;
	x = document.getElementById("qckSearchUpd");
	x.style.display = 'none';
}

function ShowHidFolder(frm)
{
	x = document.getElementById('FolderRow');
	y = frm.chkAddOpt.checked;
	curstat = x.style.display;
	if(y == false)
		x.style.display = 'none';
	else
		x.style.display = '';
	return true;
}

function ChangeFlagIcon(colid,comind,linkid)
{
	x = document.getElementById(linkid);
	y = document.getElementById("IconsTable");
	
	curX = findPosX(x);
	curY = findPosY(x);
	
	if(navigator.appName == 'Microsoft Internet Explorer')
	{
		y.style.top = curY - 110;
		y.style.left = curX;
	}
	else
	{
		y.style.top = (curY - 110) + "px";
		y.style.left = (curX - 0) + "px";
	}
	y.style.display = '';
	var varPre;
	
	if(colid == 1)
		varPre = "slIntStatus_";
	else if(colid == 2)
		varPre = "slGenStatus_";
	else if(colid == 3)
		varPre = "slFlag_";
	else if(colid == 4)
		varPre = "slLegStatus_";

	eval("document.frmChange.SelectedFlagId.value = '" + varPre + comind + "'");
	eval("document.frmChange.SelectedStatusId.value = '" + colid + "'");
	eval("document.frmChange.SelectedFlagInd.value = '" + comind + "'");
	
//	alert(colid);
//	alert(comind);
//	alert(linkid);
	return true;
}

function chkReportsSubmit(frm)
{
	if(frm.txtNames.value)
	{
//		frm.view_period_preset.options[0].selected = true;
	}
	return true;
}

function FlagIconSelected(iconid)
{
	var selflagid = document.frmChange.SelectedFlagId.value;
	var selstatusid = document.frmChange.SelectedStatusId.value;
	var selflagind = document.frmChange.SelectedFlagInd.value;
	
	if(selstatusid == 1)
		varPre = "imgIntStatus_";
	else if(selstatusid == 2)
		varPre = "imgGenStatus_";
	else if(selstatusid == 3)
		varPre = "imgFlag_";
	else if(selstatusid == 4)
		varPre = "imgLegStatus_";
	
	var imgpath = eval("document.frmChange.FlagImgPath_" + iconid + ".value");
	eval("document.frmChange." + varPre + selflagind + ".src = '" + imgpath + "'");
	eval("document.frmChange." + selflagid + ".value = '" + iconid + "'");
	eval("document.frmChange." + selflagid + ".value = '" + iconid + "'");
	document.getElementById('IconsTable').style.display = 'none';
	return true;
}


function ContinueRefresh(SesId)
{
	var curstat = document.frmQuickSearch.ImportStatus.value;
	//alert(curstat);
	if(curstat == 'f')
	{
		intervalid = setInterval('CheckImportStatus(\''+ SesId + '\')',3000);
	}
	else
	{
		clearInterval(intervalid);
		return true;
	}
}

function ContRefCustomReport(GroupBy, SortOn, SortType, CurPage)
{
//	var curstat = document.frmQuickSearch.ImportStatus.value;
	//alert(curstat);
//	if(curstat == 'f')
//	{
//		intervalid = setInterval('ChkCustomReport(\''+ GroupBy + '\', \''+ SortOn+ '\', \''+ SortType+ '\', \''+ CurPage+ '\')',10000);
//	}
//	else
//	{
//		clearInterval(intervalid);
//		return true;
//	}
//	ChkCustomReport(\''+ GroupBy + '\', \''+ SortOn+ '\', \''+ SortType+ '\', \''+ CurPage+ '\'
}

var curstat = 'f';
function ContRefCustomStatistics(CurPage, DomCols, StatCols, ListingType, SortOn, SortType)
{
	var intervalid;
	alert(curstat + " first function");
	if(curstat == 'f')
	{
		alert("Colling from first function");
		intervalid = setInterval('ChkCustomStatistics(\''+ CurPage + '\', \''+ DomCols+ '\', \''+ StatCols+ '\', \''+ ListingType+ '\', \''+ SortOn+ '\', \''+ SortType+ '\')',20000);
	}
	else
	{
		alert("Exiting from first function");
		clearInterval(intervalid);
		return true;
	}
}

function CheckExportStatus()
{
	clearInterval();
}

////////////////////////////////////////////////////////////////////
// XML functions and AJAX things
////////////////////////////////////////////////////////////////////

var xmlHttp;

function CheckImportStatus(SesId)
{
	//	var curstat = document.frmQuickSearch.ImportStatus.value;
//	if(curstat == 't')
//	{
//		ContRefCustomReport(GroupBy, SortOn, SortType, CurPage);
//		return true;
//	}
	
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp==null)
	{
		alert("Browser does not support HTTP Request");
		return false;
	}
	var GroupBy = GroupBy;
	var SortOn = SortOn;
	var SortType = SortType;
	var urlPass = "chk_import_status.php";
	urlPass = urlPass + "?sid=" + SesId;
	urlPass = urlPass + "&randid="+Math.random();
//	alert(urlPass);
	xmlHttp.onreadystatechange = fillImportMessage;
	urlPass = new String(urlPass);
	xmlHttp.open("GET",urlPass);
	xmlHttp.send(null);
	return true;
}

function CheckBlackDomainsExportStatus(SesId)
{
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp==null)
	{
		alert("Browser does not support HTTP Request");
		return false;
	}
	var GroupBy = GroupBy;
	var SortOn = SortOn;
	var SortType = SortType;
	var urlPass = "chk_import_status.php";
	urlPass = urlPass + "?sid=" + SesId;
	urlPass = urlPass + "&randid="+Math.random();
//	alert(urlPass);
	xmlHttp.onreadystatechange = fillBlackDomainsExportStatus;
	urlPass = new String(urlPass);
	xmlHttp.open("GET",urlPass);
	xmlHttp.send(null);
	return true;
}

var gCurPage = '';
var gDomCols = '';
var gStatCols = '';
var gListingType = '';
var gSortOn = '';
var gSortType = '';

function ChkCustomStatistics(aCurPage, aDomCols, aStatCols, aListingType, aSortOn, aSortType)
{
//	var curstat = document.frmQuickSearch.ImportStatus.value;
//	alert(curstat + " in second function");
//	if(curstat == 't')
//	{
//		alert("Colling from second function");
//		ContRefCustomStatistics(CurPage, DomCols, StatCols, ListingType, SortOn, SortType)
//		return true;
//	}
	if(aCurPage)
	gCurPage = aCurPage;
	if(aDomCols)
	gDomCols = aDomCols;
	if(aStatCols)
	gStatCols = aStatCols;
	if(aListingType)
	gListingType = aListingType;
	if(aSortOn)
	gSortOn = aSortOn;
	if(aSortType)
	gSortType = aSortType;

	xmlHttp = GetXmlHttpObject()
	if(xmlHttp==null)
	{
		alert("Browser does not support HTTP Request");
		return false;
	}
	var GroupBy = GroupBy;
	var SortOn = SortOn;
	var SortType = SortType;
	var urlPass = "display_statistics.php";
	urlPass = urlPass + "?CurPage=" + gCurPage;
	urlPass = urlPass + "&DomCol=" + gDomCols;
	urlPass = urlPass + "&StatColumn=" + gStatCols;
	urlPass = urlPass + "&ListingType=" + gListingType;
	urlPass = urlPass + "&SortType=" + gSortType;
	urlPass = urlPass + "&SortOn=" + gSortOn;
	urlPass = urlPass + "&randid="+Math.random();
//	alert(urlPass);
	xmlHttp.onreadystatechange = fillCustomStatistics;
	urlPass = new String(urlPass);
	xmlHttp.open("GET",urlPass);
	xmlHttp.send(null);
	return true;
}

// This is used by add_domains.php, and is related to display_bulkdomadd.php
function ChkBulkDomAdd(rcnt)
{
	xmlHttp = GetXmlHttpObject()
	if(xmlHttp==null)
	{
		alert("Browser does not support HTTP Request");
		return false;
	}
	var GroupBy = GroupBy;
	var SortOn = SortOn;
	var SortType = SortType;
	var urlPass = "display_bulkdomadd.php";
	urlPass = urlPass + "?randid="+Math.random();
	urlPass = urlPass + "&rcnt="+rcnt;
//	alert(urlPass);
	xmlHttp.onreadystatechange = fillBulkDomAddition;
	urlPass = new String(urlPass);
	xmlHttp.open("GET",urlPass);
	xmlHttp.send(null);
	return true;
}

function ChkBulkEmailsSending(auto_id)
{
	$.ajax(
			{
				url: "display_send_emails.php?id=" + auto_id, 
				timeout: 600,
				error: function(request,error)
				{
					if(error=='timeout')
					{
						alert('time out - couldn\t send emails');
					}
				},
				cache:false,
				success:function(msg)
				{
					x = document.getElementById("send_emails_div");
					if (msg == '123') {
						window.location = 'send_emails.php';
					}
					else {
						x.innerHTML = msg;
					}
				}
			}
		);
	return true;
}


function GetWhoisInformation(page_no, ssid, isad)
{
	var page_no = page_no;
	$.ajax(
			{
				url: "queue_whois.php?page_no=" + page_no + "&ssi=" + ssid, 
				//timeout: 600,
				error: function(request,error)
				{
					//if(error=='timeout')
					//{
					//	alert('Couldn\'t fetched the whois information');
					//}
				},
				cache:false,
				success:function(msg)
				{
					x = document.getElementById("html_table");
					y = document.getElementById("img_box");
//					z = document.getElementById("");
					x.innerHTML = msg;
					
					if(isad == 1)
					y.innerHTML = '<input type="button" name="but_refresh" value="Fetch Whois" onclick="document.location=\'ownership.php?admf=1\'">';
					else
					y.innerHTML = '';
				}
			}
		);
	return true;
}

function ChkCustomReportAndStats(JobId)
{
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp==null)
	{
		alert("Browser does not support HTTP Request");
		return false;
	}
	var urlPass = "display_reports.php";
	urlPass = urlPass + "?JobId=" + JobId;
	urlPass = urlPass + "&randid="+Math.random();
//	alert(urlPass);
	xmlHttp.onreadystatechange = fillCustomReportAndStats;
	urlPass = new String(urlPass);
	xmlHttp.open("GET",urlPass);
	xmlHttp.send(null);
	return true;
}

function subEmailForm(frm,optval)
{
//	alert(frm);
	/*.get("test.cgi", { name: "John", time: "2pm" }, 
   function(data){ 
     alert("Data Loaded: " + data); 
   });
	*/
	$.ajax(
			{
				url: "get_emails.php?type=" + optval, 
				timeout: 40000,
				error: function(request,error)
				{
					if(error=='timeout')
					{
						alert('time out - couldn\t fetch the result');
					}
				},
				cache:false,
				success:function(msg)
				{
					frm.txt_emails.value = msg;
				}
			}
		);
	return true;
}

function edit_annoucement()
{
	  var msg_edit = document.getElementById('msg_edit');
	   var msg_div = document.getElementById('announcement_msg');
	  var msgs = msg_div.innerHTML.replace(/<br>/g,'\n');
	  msgs = msgs.replace(/<BR>/g,'\n');
      if(!msg_edit) {
	     document.getElementById('edit_button').innerHTML = 'Update'
	     msg_div.innerHTML = "<textarea id='msg_edit'  rows='10' cols='50'>"+msgs+"</textarea>";
	  }
	  else {
	     update_announcement(msg_edit.value.replace(/\n/g,'<br>'));
	     document.getElementById('edit_button').innerHTML = 'Edit';
	     msg_div.innerHTML = msg_edit.value.replace(/\n/g,'<br>');
	  }
   }

function swap_announcement_divs(swap_ind)
{
	x = document.getElementById("sub_buttons");
	y = document.getElementById("edit_button");
	z = document.getElementById("announcement_msg");
	if (swap_ind == 2)
	{
		y.style.display = '';
		x.style.display = 'none';
		z.style.display = '';
	}
	else
	{
		y.style.display = 'none';
		x.style.display = '';
		z.style.display = 'none';
	}
	return true;
}
function update_announcement(msg)
{
   	xmlHttp = GetXmlHttpObject()
	if(xmlHttp==null)
	{
		alert("Browser does not support HTTP Request");
		return false;
	}
	var urlPass = "update_announcement.php?dont_render_template=1&a_id=1&msg="+msg;
	xmlHttp.onreadystatechange = update_announcement_result;
	xmlHttp.open("GET",urlPass);
	xmlHttp.send(null);
	return true;
}

function update_announcement_result()
{
	 
	
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		if(xmlHttp.responseText == 'f')
		{
 
			 alert('Erro while updating Announcement Content');
		}
	}
}

// Called by ChkBulkDomAdd(), from add_domains.php.  
function fillBulkDomAddition()
{
	var comp;
	comp = 'f';
	
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
//		alert("complete");
		y = document.getElementById('add_domains_div');

		var textresponse = xmlHttp.responseText;
		var xmlresponse;
		var response_status;
		try {
			xmlresponse = xmlHttp.responseXML.documentElement;
			response_status = xmlresponse.getElementsByTagName('status')[0].getAttribute('value'); 
		} catch (err) {
			xmlresponse = null;
			response_status = null;
		}
		
		if (response_status == 'debug')
		{
			alert("Debug response received from display_bulkdomadd.php");
		}
		else if (response_status == 'success')
		{
			var url = xmlresponse.getElementsByTagName('url')[0].getAttribute("value");
			window.location = url;
		}
		else if (response_status == 'retry')
		{
			var rcnt = xmlresponse.getElementsByTagName('rcnt')[0].getAttribute("value");
			ChkBulkDomAdd(rcnt);
		}
		else if (response_status == 'error')
		{
			var errmsg = xmlresponse.getElementsByTagName('errmsg')[0].getAttribute("value");
			// Ren requirement of displaying no message in case of error
//			alert("here");
			window.location = 'add_domains.php?red=1';
		}
		else if (textresponse.indexOf('lock_folder_conf JS') != -1)
		{
			// Important - the above tag is set in lock_folder_conf.html and must not be removed.
			y.innerHTML = textresponse;
		}
		else
		{
			// No valid reponse received!  Uh oh.
		}
		return true;
	}
}

function fillCustomReportAndStats()
{
	var comp;
	comp = 'f';
	
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
        var reponse = xmlHttp.responseText;
		return process_custom_report_reponse(reponse);
	}
}

function process_custom_report_reponse(response)
{
    y = document.getElementById('cust_report');
    var response_arr = response.split("_");
    var job_type = response_arr[0];
    var job_id = response_arr[1];
    var header_loc;
    // we got a reponse with job type and job it
    if(job_id)
    {
        if(job_type == 'CR')
        {
            y.innerHTML = "<div class='sucmsg2'>You are being redirected... Please wait...</div>";
            header_loc = "reports.php?jobid=" + job_id;
        }
        else if(job_type == 'CS')
        {
            y.innerHTML = "<div class='sucmsg2'>You are being redirected... Please wait...</div>";
            header_loc = "statistics.php?jobid=" + job_id;
        }
        else if(job_type == 'ES')
        {
            y.innerHTML = "";
            header_loc = "tasks.php?jobid=" + job_id + "&download=1";
        }
        else if(job_type == 'ER')
        {
            y.innerHTML = "";
            header_loc = "tasks.php?jobid=" + job_id + "&download=1";
        }
        document.location = header_loc;
    }
    else
    {
        y.innerHTML = "<div class='sucmsg2'>" + xmlHttp.responseText + "</div>";
    }
    return true;
}

function fillBlackDomainsExportStatus()
{
	var comp;
	comp = 'f';
	
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		x = document.getElementById('cust_report');
		if(xmlHttp.responseText == 't')
		{
			if(x)
			x.innerHTML = "<div id='imp_msg'><a href='export.php?file=black_domains'>Click here</a> to download the file</div>";
			comp = 't';
		}
		else if (xmlHttp.responseText != 't') {
			if(x)
			x.innerHTML = xmlHttp.responseText;
			comp = 't';
		}
		else
		{
			//x.innerHTML = "The data is being processed.<br>Please wait for few minutes...";
		}
		document.frmQuickSearch.ImportStatus.value = comp;
		return true;
	}
}

function fillImportMessage()
{
	var comp;
	comp = 'f';
	
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		x = document.getElementById('cust_report');
		if(xmlHttp.responseText == 't')
		{
			x.innerHTML = "<div id='imp_msg'><a href='export_stats.php'>Click here</a> to download the file</div>";
			comp = 't';
		}
		else if (xmlHttp.responseText != 't') {
			x.innerHTML = xmlHttp.responseText;
			comp = 't';
		}
		else
		{
			//x.innerHTML = "The data is being processed.<br>Please wait for few minutes...";
		}
		document.frmQuickSearch.ImportStatus.value = comp;
		return true;
	}
}

function GetXmlHttpObject()
{ 
	var objXMLHttp=null;
	if(window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}

function ShowHideUpdateButton(selval)
{
	var selval;
	x = document.getElementById('qckSearchUpd');
	s = document.getElementById('period_preset');
	
	if(selval == 'domain' && s.selectedIndex != '0')
		x.style.display = '';
	else
		x.style.display = 'none';
}

function ShowHideObject(obj)
{
    var selval;
    x = document.getElementById(obj);
    
    if(x.style.display == 'none')
        x.style.display = '';
    else
        x.style.display = 'none';
    return true;
}
