var x,y,zInterval,zTitle,zText, windowWidth, windowHeight, xScroll, yScroll,mx,my;

document.onmousemove = setMouseCoords;

function ietruebody(){

return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body

}

/*

function init() {

	for(i=0;i<document.getElementsByTagName("a").length;i++) {

		if(document.getElementsByTagName("a")[i].className == "toolLink") {

			document.getElementsByTagName("a")[i].onmouseout = hideToolTip;

		}

	}

}

*/

function setMouseCoords(e) {

	if(document.all) {

		x = event.clientX+ietruebody().scrollLeft;

		y = event.clientY+ietruebody().scrollTop;

		//x = window.event.clientX;

		//y = window.event.clientY;

	} else {

		x = e.pageX;

		y = e.pageY;

	}

}



function winopen(cat,category_name,subcat,subcategory_name,country,obj) {

var ht=getPageSize();

	var obj=document.getElementById(obj);

	var x=findPosX(obj);

	var y=findPosY(obj);

		if(y > 600 || y+100 > ht)

		{

			my=y-100;

		}

		else

		{

			my=y+10;

		}

		mx=x-95;

xmlHttp=GetXmlHttpObject_popup();

if (xmlHttp==null)

{

	alert ("Your browser does not support AJAX!");

	return;

} 

var url="popup-search.php";

url=url+"?subcategory_id="+subcat;

url=url+"&subcategory_name="+subcategory_name;

url=url+"&category_id="+cat;

url=url+"&category_name="+category_name;

url=url+"&country="+country;

xmlHttp.onreadystatechange=stateChanged_popup;

xmlHttp.open("GET",url,true);

xmlHttp.send(null);

//window.scrollBy(0,30);

}



function GetXmlHttpObject_popup()

{

  var xmlHttp=null;

  try

    {

    // Firefox, Opera 8.0+, Safari

    xmlHttp=new XMLHttpRequest();

    }

  catch (e)

    {

    // Internet Explorer

    try

      {

      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

      }

    catch (e)

      {

      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

      }

    }

  return xmlHttp;

}



function stateChanged_popup() 

{ 

	if (xmlHttp.readyState==4)

	{ 

		document.getElementById("PopUpCity").style.top = my + "px";

		document.getElementById("PopUpCity").style.left = mx + "px";

		document.getElementById("PopUpCity").innerHTML=xmlHttp.responseText;

		document.getElementById("PopUpCity").style.display = "block";		

	}

	else

	{

		document.getElementById('PopUpCity').innerHTML="";

	}

/*	<span id=\"\" valign=\"middle\" align=\"center\"><img src=\"/wedding-directory/imgs/loading.gif\" border=\"0\" alt=\"Loading...\"><span>*/

} 



function hidepopup() {

	document.getElementById("PopUpCity").style.display = "none";

}



 function submitcity(){ 

	 if(document.getElementById('city').value==''){

		 alert('Please select a city');

		 return false;

	}

	return true;

}



/*get size of page*/

 function getPageSize()

{



    if (window.innerHeight && window.scrollMaxY)

    {

        xScroll = document.body.scrollWidth;

        yScroll = window.innerHeight + window.scrollMaxY;

    }

    else if (document.body.scrollHeight > document.body.offsetHeight)

    {

        // all but Explorer Mac

        xScroll = document.body.scrollWidth;

        yScroll = document.body.scrollHeight;

    }

    else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight)

    {

        // Explorer 6 strict mode

        xScroll = document.documentElement.scrollWidth;

        yScroll = document.documentElement.scrollHeight;

    }

    else

    {

        // Explorer Mac...would also work in Mozilla and Safari

        xScroll = document.body.offsetWidth;

        yScroll = document.body.offsetHeight;

    }



    

    if (self.innerHeight)

    {

        // all except Explorer

        windowWidth = self.innerWidth;

        windowHeight = self.innerHeight;

    }

    else if (document.documentElement && document.documentElement.clientHeight)

    {

        // Explorer 6 Strict Mode

        windowWidth = document.documentElement.clientWidth;

        windowHeight = document.documentElement.clientHeight;

    }

    else if (document.body)

    {

        // other Explorers

        windowWidth = document.body.clientWidth;

        windowHeight = document.body.clientHeight;

    }



    // for small pages with total height less then height of the viewport

    if(yScroll < windowHeight)

    {

        pageHeight = windowHeight;

    }

    else

    {

        pageHeight = yScroll;

    }



    // for small pages with total width less then width of the viewport

    if(xScroll < windowWidth)

    {

        pageWidth = windowWidth;

    }

    else

    {

        pageWidth = xScroll;

    }



    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)

     return windowHeight;

}



//---Funation to get postion of text

function findPosX(obj)

  {

    var curleft = 0;

    if(obj.offsetParent)

        while(1) 

        {

          curleft += obj.offsetLeft;

          if(!obj.offsetParent)

            break;

          obj = obj.offsetParent;

        }

    else if(obj.x)

        curleft += obj.x;

    return curleft;

  }



  function findPosY(obj)

  {

    var curtop = 0;

    if(obj.offsetParent)

        while(1)

        {

          curtop += obj.offsetTop;

          if(!obj.offsetParent)

            break;

          obj = obj.offsetParent;

        }

    else if(obj.y)

        curtop += obj.y;

    return curtop;

  }
