/////// For Pop up box ////////////////
var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

//drag drop function for NS 4////
/////////////////////////////////

var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for ie4+ and NS6////
/////////////////////////////////

function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
return false
}
}

function initializedrag(e){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}

if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmouseup=new Function("dragapproved=false")

////drag drop functions end here//////

function hidebox(){
	//alert("you are in hidebox ");
	var pagename=GetPage();
	
	if(pagename=="composemail.php")
	{
//		//var totval=document.getElementById("frmcontact").value;
//		
//		//var id=document.getElementById("frmcontact").value;
//		// For Total Comments on Shoprs' Choice/
//		var xmlHttpReq_SCommnet = false;
//		var self = this;
//		// Mozilla/Safari
//		if (window.XMLHttpRequest) {
//			//alert("You are in 2nd if condition");
//			self.xmlHttpReq_SCommnet = new XMLHttpRequest();
//		}
//		// IE
//		else if (window.ActiveXObject) {
//			//alert("You are in 2nd else if condition");
//			self.xmlHttpReq_SCommnet = new ActiveXObject("Microsoft.XMLHTTP");
//		}
//		//alert("view_totalcomment.php?scid="+scid);
//		//alert(self.xmlHttpReq_SComment.open('post','profile.php',true));
//		self.xmlHttpReq_SCommnet.open('POST',"profile.php?id=1", true);
//		self.xmlHttpReq_SCommnet.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//		
//		/*self.xmlHttpReq_SCommnet.onreadystatechange = function() 
//		{	
//			if (self.xmlHttpReq_SCommnet.readyState == 4) {
//				updatepage_SCommnet(self.xmlHttpReq_SCommnet.responseText,totval);
//			}
//		}*/
//		self.xmlHttpReq_SCommnet.send(null);
//		// End of Comments
//		
//		// Get All Comments
//			//GetShopChoiceAllComments(scid,totval);
		crossobj=ns6? document.getElementById("showimage") : document.all.showimage
		if (ie4||ns6)
			document.getElementById("showimage").visibility="hidden"
		else if (ns4)
			document.showimage.visibility="hide"
	}
	//alert("you are in out of if condition");
	else if(pagename=="promotion.php" || pagename=="promotion_listing.php"  || pagename=="shopchoice_listing.php" || pagename=="promotion_details.php" || pagename=="search_result.php" || pagename=="marketplace.php" || pagename=="marketplace_listing.php" || pagename=="marketplace_details.php" || pagename=="shoplist.php" || pagename=="shoplist_listing.php" || pagename=="shoplist_details.php" || pagename=="shoplist_details_map.php" || pagename=="review_details.php" || pagename=="shopchoice_details.php")
	{
		document.getElementById("ifmTest").src="blank.php";	
	}
	else
	{
		crossobj=ns6? document.getElementById("showimage") : document.all.showimage
		
		if (ie4||ns6)
			crossobj.style.visibility="hidden"
		else if (ns4)
			document.showimage.visibility="hide"
	}
	
}

function frmShow()
{
	document.getElementById("showimage").style.display="inline";
}

function frmShow_promo(val,ptype,pagename_new,inputObj)
{	
//alert("This is testing purpose");
	var newtoppos=0;
	var pagename=GetPage();
	if(pagename=="composemail.php")
	{
		newtoppos=getTopPos(inputObj)-375;
	}
	if(pagename=="composemail.php")
	{
		newtoppos=getTopPos(inputObj)-375;
	}
	else
	{
		newtoppos=getTopPos(inputObj)-200;
	}
	
	var LeftPosition = (screen.width/2)-(470/2);
	//alert(document.getElementById("showimage").value);
	document.getElementById("showimage").style.left = LeftPosition + 'px';
	document.getElementById("showimage").style.top = newtoppos + 'px';
	
	crossobj=ns6? document.getElementById("showimage") : document.all.showimage
	
	//alert("this is testing 2");
	if (ie4||ns6)
		crossobj.style.visibility="visible"
	else if (ns4)
		document.showimage.visibility="visible"

	
	document.getElementById("ifmTest").src="blank.php";
	
	if(ptype=="M")//M=mail button
	{
		document.getElementById("ifmTest").src="composemail.php?id="+val+"&pgname="+pagename_new;
		//document.getElementById("spTitle").innerHTML="Send to Friend";
	}
	else if(ptype=="R")//R=report button
	{
		document.getElementById("ifmTest").src="small_report.php?pid="+val+"&pgname="+pagename_new;
		//document.getElementById("spTitle").innerHTML="Report";
	}
	else if(ptype=="C")//C=Shop Choice Commments
	{
		document.getElementById("ifmTest").src="shopchoice_comment.php?nid="+val+"&pgname="+pagename_new;
		//document.getElementById("spTitle").innerHTML="Report";
	}
	else if(ptype=="G")//C=Shop Choice Commments
	{
		document.getElementById("ifmTest").src="add_guestbook.php?gid="+val+"&pgname="+pagename_new;
		//document.getElementById("spTitle").innerHTML="Report";
	}
	else if(ptype=="RP")//C=Shop Choice Commments
	{
		document.getElementById("ifmTest").src="report_problem.php?id="+val+"&pgname="+pagename_new;
		//document.getElementById("spTitle").innerHTML="Report";
	}
	document.getElementById("showimage").style.display="inline";

}

// Get Page Name//
function GetPage()
{
	var sPath = window.location.pathname;
	//var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	return sPage ;
}

function getTopPos(inputObj)
{
  var returnValue = inputObj.offsetTop + inputObj.offsetHeight;
  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
  return returnValue;
}

/*function getTopPos(inputObj)
{
  var returnValue = inputObj.offsetTop + inputObj.offsetHeight;
  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
  return returnValue;
}*/
