var Ajax = new sack();
function findPos(obj) {

            var curleft = curtop = 0;

            if (obj.offsetParent) {

                        curleft = obj.offsetLeft

                        curtop = obj.offsetTop

                        while (obj = obj.offsetParent) {

                                    curleft += obj.offsetLeft

                                    curtop += obj.offsetTop
                        }
            }
            return [curleft,curtop];
}

// first param implies to align the popup div to left or right of  the cursor pointer / page_option == 0 implies for search page else this id is used for fetching the package discription // 3 page_option will be the package id for membership optoins // pack_type defines the type of packaage 1 free camp owner, 2 enhanced camp owner , 3 hot camp owner, 4 advertiser and 5 retailer 6th parameter for number pagination for sending the page type whether its the search results page or the remaining pages like search category sub categoty and continent search etc....
function getPopup(divPos,site_url,id,page_option,pack_type,searchPage) 
{
	/*alert('DIV POS '+divPos);
	alert('site uto '+site_url);
	alert('id  '+id);
	alert('pack  type  '+pack_type);
	alert('ser Page '+searchPage);
	alert('page opt '+page_option);	*/
	//alert(searchPage);
	
	var anchor_id = 'anchor_'+id 
	var oAnchor = document.getElementById(anchor_id);
	var pos = findPos(oAnchor);
	var oDiv = document.getElementById("popupdata");
	oDiv.style.visibility = 'visible';
//alert(divPos);
	if(divPos == 'left') // for setting the position to align to right side to the pointer
	{
		oDiv.style.left = pos[0] - 450 + oAnchor.offsetWidth+'px';
		document.getElementById('PointerBox').className = 'pointer-box-left';
	}
	if(divPos == 'right') // for setting the position to align to left side to the pointer
	{
		oDiv.style.left = pos[0] +- 10 + oAnchor.offsetWidth+'px';	
		document.getElementById('PointerBox').className = 'pointer-box';		
	}
	oDiv.style.top = pos[1] - 44 +oAnchor.offsetHeight+ 'px';
	oDiv.style.zIndex = 100;
	
	if(page_option == 0)  // for search results page 'id' will be the category-id to fetch subcats
	{
		
	/*//	alert('ddd '+document.addEventListener); 
		alert(Ajax.requestFile);*/
		/*if(document.body.addEventListener)
		{	*/
			
			Ajax.requestFile = site_url+'/controllers/ajax_controller/middle-content.php?categoryID='+id+'&serPage='+searchPage;
			Ajax.onCompletion = AjaxResponse;
			Ajax.runAJAX();
		
			document.body.addEventListener("mouseup", hidePopupDiv,true)
			oDiv.addEventListener("mouseup", function(){oDiv.style.visibility="visible"},true)
		/*}
		else
		{*/
			if(!document.body.addEventListener)
			{
				document.body.attachEvent("onmouseup",hidePopupDiv); 
				oDiv.attachEvent("onmouseup", function(){event.cancelBubble = true;oDiv.style.visibility="visible"}); 
			}
		//}
			
	}
	else // id page_options is not equals 0 then pack type 
	{
		if(document.body.addEventListener)
		{	
			Ajax.requestFile = site_url+'/controllers/ajax_controller/middle-content.php?packageID='+page_option+'&pack_type='+pack_type;
			Ajax.onCompletion = AjaxResponse;
			Ajax.runAJAX();
		
			document.body.addEventListener("mouseup", hidePopupDiv,true)
			oDiv.addEventListener("mouseup", function(){oDiv.style.visibility="visible"},true)
		}
		else
		{
			document.body.attachEvent("onmouseup",hidePopupDiv); 
			oDiv.attachEvent("onmouseup", function(){event.cancelBubble = true;oDiv.style.visibility="visible"}); 
		}
			
	}
 }
function hidePopupDiv()
{
	var oDiv = document.getElementById("popupdata");
	oDiv.style.visibility = 'hidden';
}
//*********************
function subCatArray(site_url,sub_cid,serPage)
{
//	alert(sub_cid);
	
	if(document.getElementById('subCatId_'+sub_cid).checked==true)
	  var sub_url='?Sub_Cat_Id='+sub_cid;
	if(document.getElementById('subCatId_'+sub_cid).checked==false)
	     var sub_url='?Sub_Cat_Id='+sub_cid+'&del=T';
		 
	Ajax.requestFile = site_url+'/controllers/ajax_controller/middle-content.php'+sub_url;
	Ajax.onCompletion = AjaxResponse;
	Ajax.runAJAX();
	num_pagination_ajax(site_url,serPage,0,0,0); // for firing sub category searching ,  2nd param to denote the search page option ie serach results page or the remaining search serults like categoty, continent categoty and ...etc 
}
function AjaxResponse()
{
	//alert(Ajax.response);
	eval(Ajax.response);
}



	

