/*
	******************************************************************************
	Author: Suresh Babu S.M
	Description:
		This is AJAX Script page.

	Modification History
	******************************************************************************
	Version				Date				Author					Remarks
	******************************************************************************
	(0.1				22/05/2007			Suresh Babu S.M		Initial version)
	******************************************************************************
*/
var http_request = false;
// This is the function used to get the Host(Wedsite) Name
function getServerName()
{
    var str = window.location.protocol + '//' + window.location.hostname;
	if(str == "http://bmser.bharatmatrimony.com") {
		str = str + "/weddingdirectory/";
	}
	else {
	str = str + "/";
	}
	//str = str + "/weddingdirectory/";
    return str;
}


// This is the function used to show/hidden the AJAX and Default Content and Banner Tag
function ShowHidden() {
	document.getElementById("content1").style.display = "none";
	document.getElementById("bannerContent").style.display = "none";
	document.getElementById("AJAXBanner").innerHTML = '<div><div style="float:left;width:140px;"><p style="padding-left:10px;padding-top:5px;padding-right:10px;" align="center"><font class="headText"><b>Loading... </b><br><br><img src="http://imgs.bharatmatrimony.com/bmimages/wd/wd_ajaxloader.gif" border="0" alt="" ></font></p></div></div>';
	document.getElementById("AJAXContent").innerHTML = '<div style="height:450px;float:left;padding:12px;"><div style="float:left;width:430px;"><p style="padding-left:10px;padding-top:5px;padding-right:10px;" align="center"><font class="headText"><b>Loading...</b><br><br><img src="http://imgs.bharatmatrimony.com/bmimages/wd/wd_ajaxloader.gif" border="0" alt="" ></font></p></div></div>';
}
// Initialise the AJAX Object
function AJAXRequest() {
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
	} 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('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
}
// This function is used to send the category information to server
function showCategoryList(catid) {
	ShowHidden();
    hideall_div();
	url = getServerName() + "wdprocess.php?CatId=" + catid;
	AJAXRequest();
	http_request.onreadystatechange = writeCategoryList;
	http_request.open('GET', url, true);
	http_request.send(null);
	document.getElementById("categoryopt").value = 0;
	document.getElementById("cityopt").value = 0;
	}
// This function is used to send the search options to server
function showDirectoryList() {
	if(!checkSearch()) {
		return false;
	}
	ShowHidden();
	url = getServerName() + "wdprocess.php?categoryopt=" + catid + "&cityopt=" + cityid;
	//alert(url);
	AJAXRequest();
	http_request.onreadystatechange = writeCategoryList;
	http_request.open('GET', url, true);
	http_request.send(null);
}
// This function is used to get the result from AJAX Request page
function writeCategoryList() 
{
	if (http_request.readyState == 4) 
	{
		if (http_request.status == 200) 
		{
			httpContent = http_request.responseText;
			httpContent = httpContent.split("|Banner|");
			document.getElementById("AJAXContent").innerHTML = httpContent[0];
			document.getElementById("AJAXBanner").innerHTML = httpContent[1];
		} else {
			alert('There is a problem with the request.');
		}
	}
}
// This function is used to send the Paging Information to server
function showPagingList(PageType,pageno,catid,catname,cityname,adtype) {
	if(PageType==0) {
		ShowHidden();
		if(catid==0) catid='';
		url = getServerName() + "wdprocess.php?page=" + pageno + "&CatId=" + catid + "&categoryopt=" + catname + "&cityopt=" + cityname+ "&adtype=" + adtype;
		AJAXRequest();
		http_request.onreadystatechange = writeCategoryList;
		http_request.open('GET', url, true);
		http_request.send(null);
	}
	else if(PageType==1) {
		document.searchlistfrm.action = "wdadminviewlisting.php?page=" + pageno;
		document.searchlistfrm.submit();
	}
	else if(PageType==2) {
		document.reportfrm.action = "wdadminreport.php?page=" + pageno;
		document.reportfrm.submit();
	}
	else if(PageType==3) {
		document.detailedreportfrm.action = "wdadmindetailedreport.php?page=" + pageno;
		document.detailedreportfrm.submit();
	}
	else if(PageType==4) {
		window.location.href="wdadminexpiryreport.php?page=" + pageno;
	}
	else if(PageType==5) {
		window.location.href="wdadminpaymentpending.php?page=" + pageno;
	}
	else if(PageType==6) {
		document.searchlistfrm.action = "wdadminviewfreelisting.php?page=" + pageno;
		document.searchlistfrm.submit();
	}
	else if(PageType==7) {
		window.location.href="wdadminonlinepayment.php?page=" + pageno;
	}


}
// This is to show the popup for Read Full Link
function descPopup(AdId) {
	window.open('wdpopupdescription.php?adID=' + AdId,'','width=585,height=300,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
}