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 readCookie(n){var nEQ=n+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nEQ)==0)return unescape(c.substring(nEQ.length,c.length))}return null}
function saveCookie(Name,Value){var expiryDate=new Date();var offset=1/1;expiryDate.setYear(expiryDate.getFullYear()+offset);
    document.cookie=escape(Name)+"="+escape(Value)+"; expires="+expiryDate.toGMTString()+"; domain=guruji.com; path=/;"}
function addClass(ele,cls){ele=_$(ele);if(!this.hasClass(ele,cls)){ele.className += " "+cls;}}
function removeClass(ele,cls){ele=_$(ele);if(hasClass(ele,cls)){var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');ele.className=ele.className.replace(reg,' ');}}
function getImageForAlbum(album){var lang = "Hindi";if(readCookie("lang"))lang=readCookie("lang");var a=album.toLowerCase().replace(/ +/ig,"_"); imgPath = "http://music.guruji.com/mnav/images/movies/"+lang.toLowerCase()+"/"+a+".jpg"; return imgPath;}
function ce(el){return document.createElement(el);}
function createNRStuff(div)
{
    try{maxCount = Math.floor(node.clientWidth/110);}catch(e){maxCount=6;}
    var t = ce("table");t.setAttribute("width","700");t.setAttribute("height","140");t.setAttribute("border","0");
    t.setAttribute("bgcolor","#F4FAFC");t.setAttribute("style","margin:auto;");t.setAttribute("cellpadding","3");var tr = t.insertRow(-1);
    var colSize = Math.floor(10000/maxCount)/100;
    for(var i=0,len=(newReleases.length>maxCount?maxCount:newReleases.length);i<len;i++){
    var l = tr.insertCell(-1);l.setAttribute("valign","top");
    var html=[];html.push("<a href='/music?q=");html.push(newReleases[i]);html.push("&src=mkt&src1=nrpimage&src2=nrpimage1&landing=1'>");
    html.push("<img border=\"0\" src=\"");html.push(getImageForAlbum(newReleases[i]));
    html.push("\" /></a><br/><div style=\"text-align:center;\"><a href='/music?q="); html.push(newReleases[i]);html.push("&src=mkt&src1=nrpimage&src2=nrpimage1&landing=1' style=\"font-size:8pt;\">");html.push(newReleases[i]); html.push("</a>");
    html.push("</a></div>");l.innerHTML=html.join('');
    }
    var node = document.getElementById(div);
    node.innerHTML = "";node.appendChild(t);var clear=ce("div");clear.setAttribute("style","clear:both;");node.appendChild(clear);
}
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];
}



