function findMyDivPostion(){ 
	  var obj=document.getElementById("lnkHome"); 
	  var curleft = obj.offsetLeft; 
	  var curtop=obj.offsetTop; 

	  while(obj.offsetParent)   {
		   curleft=curleft + (obj.offsetParent.offsetLeft); 
		   curtop=curtop + (obj.offsetParent.offsetTop); 
		   obj=obj.offsetParent; 
	  } 
	return curleft;
} 

/*************************************************/
//CHANGE THE LINK HREF VALUE AS CURRENT PAGE CODE
/*************************************************/
var IE = document.all?true:false;
function checkie(){
if (!IE){  
   var curPage=window.location;
   //alert(document.getElementById("lnkLogo").innerHTML);
   document.getElementById("lnkLogo").innerHTML='<a title="GoogleKhoj - My Search Engine!"  style="width:61px;height:65px;font-size:0px;line-height:0px;top:10px;left:10px;display:block;position:absolute;background:url(googlekhoj_logo.gif);" href="'+ curPage +'"><strong>GoogleKhoj!</strong></a>';
}
}
/*************************************************/
//CHANGE THE LINK HREF VALUE AS CURRENT PAGE CODE
/*************************************************/

function adjustLink(){
	//checkie();	
	document.getElementById("dvHomePage").style.visibility="visible";
	document.getElementById("dvHomePage").style.display="inline";
	var curleft=findMyDivPostion();
	document.getElementById("dvHomePage").style.left=curleft-220;
}
         
function homePageSet(obj){
	obj.style.behavior='url(#default#homepage)';
	//obj.setHomePage('http://www.googlekhoj.com');
	url=window.location.href;
	obj.setHomePage(url);
}


/*************************************************/
//DVHOME HIDE CODE ... WHEN CLICK ON CLOSE X
/*************************************************/
function hideme(){
    if(document.getElementById("dvHomePage").style.visibility=="visible")    {
        document.getElementById("dvHomePage").style.visibility="hidden"; 
		document.getElementById("dvHomePage").style.display="none";
    }
}

/*************************************************/
//DVHOME HIDE CODE ... WHEN CLICK ON CLOSE X
/*************************************************/                                                  


function addq(el) {
  if(window.RegExp && window.encodeURIComponent) {
    var ue = el.href;
    var qe = encodeURIComponent(document.forms[0].q.value);
	if(qe != "")
	{
		if(ue.indexOf("q=")!=-1) {
		  el.href = ue.replace(new RegExp("q=[^&$]*"),"q="+qe);
		} else {
		  el.href = ue+"&q="+qe;
		}
	}
  }
  return 1;
}

/*************************************************/
//Adding query value to link
/*************************************************/

function fsearch(el) {
  if(window.RegExp && window.encodeURIComponent) {
    var ue = el.href;
    var qe = encodeURIComponent(document.forms[0].q.value);
	if(qe != "")
	{
		if(ue.indexOf("nm=")!=-1) {
		  el.href = ue.replace(new RegExp("nm=[^&$]*"),"q="+qe);
		} else {
		  el.href = ue+"?nm="+qe;
		}
	}
  }
  return 1;
}

/*************************************************/
//Facebook Search
/*************************************************/

function wiki(el) {
  if(window.RegExp && window.encodeURIComponent) {
    var ue = el.href;
    var qe = encodeURIComponent(document.forms[0].q.value);
	if(qe != "")
	{
		if(ue.indexOf("q=")!=-1) {
		  el.href = ue.replace(new RegExp("q=[^&$]*"),"q="+qe);
		} else {
		  el.href = ue+qe;
		}
	}
  }
  return 1;
}


/*************************************************/
//Returning wiki link
/*************************************************/

function yahoo(el) {
  if(window.RegExp && window.encodeURIComponent) {
    var ue = el.href;
    var qe = encodeURIComponent(document.forms[0].q.value);
	if (qe != ""){
		ue = "http://search.yahoo.com/search";
		if(ue.indexOf("?p=")!=-1) {
		  el.href = ue.replace(new RegExp("?p=[^&$]*"),"?p="+qe);
		} else {
		  el.href = ue+"?p="+qe;
		}
	}else{
		el.href = ue;
	}
  }
  return 1;
}




/*************************************************/
//Returning wiki link
/*************************************************/


function gotohome() {
  if(document.forms[0].q.value == "") {
    window.location.href="http://www.googlekhoj.com/";
  } else {
	setCookie("newhome", 1 , 1);
	//if(urlRedirection == 1)
	{
		var str = document.forms[0].q.value;
		str = str.replace("#", " ");
		str = str.replace("%", "%25");
		window.location.href="/"+ str ;// encodeURIComponent(document.forms[0].q.value);
	}
	//else
	//{
	//	window.location.href="/"+encodeURIComponent(document.forms[0].q.value);
	    //window.location.href="mySearchEngine.php?logo="+encodeURIComponent(document.forms[0].q.value)+"&imgId="+encodeURIComponent(document.forms[0].imgId.value);
	//}
  }
}

function search()
{
	if(document.forms[0].q.value == "")
		return false;
	for (var i=0; i < document.forms[0].searchEngine.length; i++)
    {
		if (document.forms[0].searchEngine[i].checked)
		{
			var rad_val = document.forms[0].searchEngine[i].value;
			if(rad_val == "b")
			{
				searchbing();
				return false;
			}
			else if(rad_val == "y")
			{
				searchyahoo();
				return false;
			}
		}
    }
//	document.forms[0].submit();
return true;
}

function searchbing() {
    window.location.href="http://www.bing.com/search?q="+encodeURIComponent(document.forms[0].q.value);
}

function searchyahoo() {
    window.location.href="http://search.yahoo.com/search?p="+encodeURIComponent(document.forms[0].q.value);
}

function open_wish_window(logo, imgId)
{
window.open("/tellfriends/wish.php?logo="+logo+"&wish=1"+"&imgId="+imgId,"GoogleKhoj", "height=420,width=440,status=1,scrollbars=1,resizable=1,screenX=330,screenY=150,left=330,top=150");
}

function open_invite_window(logo, imgId)
{
window.open("/tellfriends/invite.php?logo="+logo+"&imgId="+imgId,"GoogleKhoj", "height=420,width=440,status=1,scrollbars=1,resizable=1,screenX=330,screenY=150,left=330,top=150");
}

/*************************************************/
//Go to homepage, create new logo
/*************************************************/

function open_window(logo)
{
window.open("/tellfriends/invite.php?logo="+logo,"GoogleKhoj", "height=420,width=440,status=1,scrollbars=1,resizable=1,screenX=330,screenY=150,left=330,top=150");
}

/*************************************************/
//Open new window for invite friends
/*************************************************/


function open_tips()
{
window.open("/Tips.php","GoogleKhoj", "height=520,width=650,status=1,screenX=330,screenY=50,left=170,top=55");
}

/*************************************************/
//Open new window for Tips
/*************************************************/


function sf(){document.f.q.focus()}
window.clk=function(b,c,d,e,f,g){if(document.images){var a=encodeURIComponent||escape;(new Image).src="/url?sa=T"+(c?"&oi="+a(c):"")+(d?"&cad="+a(d):"")+"&ct="+a(e)+"&cd="+a(f)+(b?"&url="+a(b.replace(/#.*/,"")).replace(/\+/g,"%2B"):"")+"&ei=OQ8aSN_NLIvc6gPk7oSgDA"+g}return true};
window.gbar={};(function(){var c=window.gbar,e,g,h;c.qs=function(a){var d=window.encodeURIComponent&&(document.forms[0].q||"").value;if(d)a.href=a.href.replace(/([?&])q=[^&]*|$/,function(f,b){return(b||"&")+"q="+encodeURIComponent(d)})};function l(a,d,f){a.display=h?"none":"block";a.left=d+"px";a.top=f+"px"}c.tg=function(a){var d=0,f=0,b,m=0,n,j=window.navExtra,k,i=document;g=g||i.getElementById("gbar").getElementsByTagName("span");(a||window.event).cancelBubble=!m;if(!e){e=i.createElement(Array.every||window.createPopup?"iframe":"DIV");e.frameBorder="0";e.scrolling="no";e.src="#";g[7].parentNode.appendChild(e).id="gbi";if(j&&g[7])for(n in j){k=i.createElement("span");k.appendChild(j[n]);g[7].parentNode.insertBefore(k,g[7]).className="gb2"}i.onclick=c.close}while(b=g[++m]){if(f){l(b.style,f+1,d+25);d+=b.firstChild.tagName=="DIV"?9:20}if(b.className=="gb3"){do f+=b.offsetLeft;while(b=b.offsetParent)}}e.style.height=d+"px";l(e.style,f,24);h=!h};c.close=function(a){h&&c.tg(a)}})();


