var http_request = false; function setCookie(CookieName,CookieValue)
{ var expireDate = new Date (); var offset = 1 / 1; expireDate.setYear(expireDate.getFullYear()+offset); document.cookie = escape(CookieName ) + "=" + escape(CookieValue) + "; expires=" + expireDate.toGMTString() + "; path=/";}
function makeRequest(url, parameters, message) { http_request = false; if (window.XMLHttpRequest) { http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/html');}
} else if (window.ActiveXObject) { try { http_request = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {}
}
}
if (!http_request) { alert('Cannot create XMLHTTP instance'); return false;}
http_request.onreadystatechange = function(){alertContents(message);};; http_request.open('GET', url + parameters, true); http_request.send(null);}
function alertContents(message) { if (http_request.readyState == 4) { if (http_request.status == 200) { document.getElementById('rate').innerHTML = message;} else { alert('Connection Failure - Please try after sometime');}
}
}
function getAndSetRateSearchParameter(obj, message) { var getstr = "?"; for (i=0; i<obj.childNodes.length; i++) { if (obj.childNodes[i].tagName == "INPUT") { if (obj.childNodes[i].type == "radio") { if (obj.childNodes[i].checked) { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";}
}
if (obj.childNodes[i].name == "q") { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";}
if (obj.childNodes[i].name == "type") { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";}
if (obj.childNodes[i].name == "hl") { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value;}
}
}
makeRequest('/ratesearch', getstr, message);}
function rpc(title,summary,tell,type)
{ var url=""; switch(type){ case "moreinfo":url="http://dir.guruji.com/local/detail?";break; case "vcard":url="http://dir.guruji.com/misc/vcard.php?";break; default:break;}
    var a=window.encodeURIComponent?encodeURIComponent:escape; var urlstr = url + "title="+ a(title) + "&desc="+ a(summary) + "&tel=" + a(tell) + ""; window.location.href = urlstr; return;}


function rpcnew(t,st,loc,city,pin,ph,site,email,q)
{ 
var url="http://dir.guruji.com/local/detail?";
//var url="http://demo.guruji.com/detail.php?";
var a=window.encodeURIComponent?encodeURIComponent:escape; 
summary = st + ",<BR>" + loc + ",<BR>" + city + " " + pin;
var urlstr = url + "title="+ a(t) + "&desc="+ a(summary) + "&tel=" + a(ph) + "&site=" + a(site) + "&email=" + a(email) + "&q=" + a(q);
window.location.href = urlstr; 
return;
}

function printIt(record)
{ var _ifrm = document.createElement("IFRAME"); document.body.appendChild(_ifrm); if (_ifrm.contentDocument) { _d = _ifrm.contentDocument;} else if (_ifrm.contentWindow) { _d = _ifrm.contentWindow.document;} else if (_ifrm.document) { _d = _ifrm.document;}
    _d.write(document.getElementById(record).innerHTML); _d.close(); _ifrm.contentWindow.focus(); _ifrm.contentWindow.print(); document.body.removeChild(_ifrm);}
function errorwin(title,desc,tel)
{ var windowleft = parseInt((screen.width/2) - 250); var windowtop = parseInt((screen.height/2) - 200); var a=window.encodeURIComponent?encodeURIComponent:escape; var URL = "http://dir.guruji.com/local/reporterror.php?title="+ a(title) + "&desc=" + a(desc) + "&tel=" + a(tel); try{ window.open(URL,'errorwindow','scrollbars=yes,width=500,height=400,left='+windowleft+',top='+windowtop+',screenX='+windowleft+',screenY='+windowtop+'');}
    catch(e){ alert(e);}
}

function initoggleCat(){setTimeout(toggleCat,300);}
function toggleCat(){o = obj('morecat');l = obj('mcl');if(o.style.display == "none"){o.style.display = "";l.style.display = "none";}}
function obj(o){r = document.getElementById(o) || document.all[o];return r;}


function showMore(obj,tempId){

pa = [];

for(i=0;i<phonesdivs.length;i++){
//console.log("%s",phonesdivs[i]);
if(phonesdivs[i]==tempId){
//console.log("pushing %s",phonesnums[i]);
pa.push(phonesnums[i]);
}
}

//console.log(pa);

/*
for(i in phones){
	console.log("%s => %s",i,phones[i]);
	}
*/
//	console.log();
	if(!document.getElementById(tempId)){
	pos =  findPos(obj);
	//console.log("%s",pos);
	obj.style.backgroundColor = "#F8FCF8";

	d = document.createElement('div');
	d.style.position = "absolute";
	d.style.top = parseInt(pos[1]+14)+"px";
	if(navigator.userAgent.indexOf("MSIE")>0){
	d.style.left = parseInt(pos[0]-94)+"px";
	d.style.width="105px";
	}else{
	d.style.left = parseInt(pos[0]-90)+"px";
	d.style.width="92px";
	}
	d.style.borderRight = "1px solid #999999";
	d.style.borderBottom = "1px solid #999999";
	d.style.borderTop = "1px solid #CCCCCC";
	d.style.borderLeft = "1px solid #CCCCCC";
	
	//d.style.height="50px";
	d.style.fontSize="0.8em";
	d.style.color="green";
	d.style.backgroundColor="#FFFFFF";
	d.style.zIndex = "1000";
	d.style.paddingLeft="8px";
	d.id = tempId;
	h = document.createElement('div');
	h.innerHTML = "<img src='/images/phone.gif'><B>&nbsp;More...</B>";
	h.style.color = "#000000";
	h.style.lineHeight = "30px";
	h.style.textAlign = "center";
//	h.style.background = "#666666";
	d.appendChild(h);
//	d.appendChild(document.createTextNode("-------------------- "));
	for(i=0;i<pa.length;i++){
	d.appendChild(document.createTextNode(pa[i]+" "));	
	//d.style.padding = "10px";
	}
	h1 = document.createElement('div');
	h1.innerHTML = "&nbsp;";
	h1.style.color = "#000000";
	h1.style.lineHeight = "10px";
	d.appendChild(h1);


	document.getElementsByTagName('body')[0].appendChild(d);
	obj.innerHTML = "&#9650;";
	}else{
	document.getElementsByTagName('body')[0].removeChild(document.getElementById(tempId));
	obj.innerHTML = "&#9660;";
	obj.style.backgroundColor = "#FFFFFF";
	}

}

function findPos(obj) {
// Help : quirksmode.org
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}


