/*
IE workaround
*/
var g_PopupIFrame;
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}
function IsIE() {
  var ver = getInternetExplorerVersion();
  if ( ver > -1 )  {
    if ( ver < 7.0 ) {
    	return (true);
    }
  }
}
function HidePopupDiv(divID) {
											hideDirQuickLook(divID);
}

function ShowPopupDiv(divID) {
	returnObjPosition(divID,'');
}

function openQuickView(url,height,width,flag,effect1,effectFade)
{
	AX_Pop(600,750,'','',url,'','','','none');
}

 /****************************************
 MarketLive.com
 Biswa Jena
 ****************************************/
var iPop_imagePath='/includes/quickView/';//use this image path along with the IPop.js

 var AX_Width=0, AX_Height=0;
 var AX_ScrOfX=0, AX_ScrOfY=0;
 var pageW=960;
 var py=0;
 var dnsp=false;//Popup will remain static on the window when scrolled
 var t=".png";
 var popVisibleDivID = null;
 var laodingContent="Loading... One Moment Please";

  var browser = navigator.appName;//detecting browser IE 6 and below
    var version = navigator.appVersion;
    if ( browser== "Microsoft Internet Explorer" )
        {
        var version1 = version.substring(22,25);
        var sisop = version.substring(26,41);
		if (parseInt(version1)<7){
			t=".gif";
		}
    }
 function AX_Win_Prop() {
    AX_Width = document.body.clientWidth;
    AX_Height = document.body.clientHeight;
	AX_ScrOfY = document.body.scrollTop;
    AX_ScrOfX = document.body.scrollLeft;
}

function rLoad(x){
	document.getElementById("popLoad").style.display="none";
	x.style.visibility="visible";
}
function rRemove(){
	document.getElementById("popLoad").style.display="block";
}

 function AX_Pop_Create(objpop){
	var pPID="";
	py+=1;
	document.getElementById("popdiv").style.display="block";
	if (objpop.pID && typeof(objpop.pID) != "undefined") pPID = objpop.pID;
	var pBG=document.createElement("DIV");
	pBG.className="pBG";
	pBG.style.zIndex=1001+py;
	AX_Win_Prop();
	pBG.style.top=AX_ScrOfY+"px";
	pBG.style.left=AX_ScrOfX+"px";
	pBG.id="ipopbg"+pPID+py;
	popVisibleDivID = pPID+py;
	//document.body.appendChild(pBG);
	document.getElementById("popdiv").appendChild(pBG);

	var pP=document.createElement("DIV");
	var dHeight=parseInt(objpop.pHeight)+18, dWidth=parseInt(objpop.pWidth)+18;
	var iHeight=parseInt(objpop.pHeight)-22;
	var iWidth=parseInt(objpop.pWidth)-22;


	if (isNaN(objpop.pTop/objpop.pTop)){
		var dTop=((document.body.clientHeight-parseInt(objpop.pHeight))/2)+AX_ScrOfY;
	}
	else {
		var dTop=parseInt(AX_ScrOfY)+parseInt(objpop.pTop);
	}
	if (isNaN(objpop.pLeft/objpop.pLeft)){
		var dLeft=((document.body.clientWidth-parseInt(objpop.pWidth))/2)+AX_ScrOfX;
	}
	else {
		var dLeft=((document.body.clientWidth-pageW)/2)+parseInt(objpop.pLeft);
	}
	

	
	pP.style.position="absolute";
	pP.style.zIndex=1001+py;
	pP.style.height=dHeight+"px";
	pP.style.width=dWidth+"px";
	pP.style.top=dTop+"px";
	pP.style.left=dLeft+"px";
	pP.id="ipop"+pPID+py;
	var d=new Date();
	var fID="lPopFrame"+pPID+py;
	var scrl="no";
	if(objpop.pSC)scrl=objpop.pSC;

	pP.innerHTML='<table border="0" cellspacing="0" cellpadding="0"><tr><td style="height:16px;width:17px;"><img src="'+iPop_imagePath+'ds_corner_lftop'+t+'"  height="16" width="17"></td><td style="height:16px;background:url('+iPop_imagePath+'ds_1top'+t+') transparent;"></td><td style="height:16px;width:23px;"><img src="'+iPop_imagePath+'/ds_corner_rttop'+t+'" height="16" width="23"></td></tr><tr><td style="width:17px;background:url('+iPop_imagePath+'/ds_1left'+t+') transparent;"></td><td style="background-color:#5C5C5C;padding-top:'+objpop.tP+';padding-right:'+objpop.rP+';padding-bottom:'+objpop.bP+';padding-left:'+objpop.lP+';"><div id="popLoad" style="position:absolute;width:'+iWidth+'px;height:'+iHeight+'px;z-index:100;"><div>'+laodingContent+'</div></div><iframe scrolling="'+scrl+'" src="" frameborder="0" height="'+iHeight+'" width="'+iWidth+'" id="'+fID+'" name="'+fID+'" style="background-color: #FFFFFF" closeP="" onload="javascript:rLoad(this);"></iframe></td><td style="width:23px;background:url('+iPop_imagePath+'/ds_1right'+t+') transparent;"></td></tr><tr><td style="height:24px;width:17px;"><img src="'+iPop_imagePath+'/ds_corner_lfbottom'+t+'" height="24" width="17" ></td><td style="height:24px;background:url('+iPop_imagePath+'/ds_1bottom'+t+') transparent;"></td><td style="height:24px;width:23px;"><img src="'+iPop_imagePath+'/ds_corner_rtbottom'+t+'" height="24" width="23" ></td></tr></table>';
	pBG.pop=pP;
	
	document.getElementById("popdiv").appendChild(pP);
	document.getElementById(fID).src=objpop.source;
	document.getElementById(fID).contentWindow.pop=pBG;

	objpop.pBG=pBG;
	objpop.pF=document.getElementById(fID);
	objpop.close=function(){
		document.getElementById("popdiv").removeChild(pBG.pop);
		document.getElementById("popdiv").removeChild(pBG);
		py-=1;
		delete objpop;
		if(!py){
			document.getElementById("popdiv").style.display="none";
			//if($.browser.msie && ($.browser.version < 7))$("select").css("visibility","visible");
		}
	}
	if(objpop.pType!="modal"){pBG.onclick=objpop.close;}
	document.getElementById(fID).closeP=objpop.close;
	//if($.browser.msie && ($.browser.version < 7)){$("select").css("visibility","hidden");}
 }

  function AX_Pop(pH,pW,pT,pL,pS,pID,pST,pTP,pSC){
	this.pHeight=pH;							//Popup height
	this.pWidth=pW;								//Popup width
	this.pTop=pT;								//Popup top position*
	this.pLeft=pL;								//Popup left position*
	this.pType=pTP;								//Popup type Modal/Non-Modal*
	this.source=pS;								//Popup source URL
	this.pID=pID;								//Popup unique ID
	this.sourceType=pST;						//Popup source type URL/HTML*
	this.pSC=pSC;								//Popup scroll information
	AX_Pop_Create(this);
 }
function wf(){
	if(py>0){
		for(i=1;i<=py;i++){
				if(dnsp){
					document.getElementById("ipopbg" + i).style.top=document.body.scrollTop+"px";
					document.getElementById("ipopbg" + i).style.left=document.body.scrollLeft+"px";
				}
				else{
					document.getElementById("ipopbg" + i).style.top=document.body.scrollTop+"px";
					document.getElementById("ipopbg" + i).style.left=document.body.scrollLeft+"px";
					document.getElementById("ipop"  + i).style.top=((document.body.clientHeight-parseInt(document.getElementById("ipop" + i).style.height))/2)+document.body.scrollTop+"px";
					document.getElementById("ipop" + i).style.left=((document.body.clientWidth-parseInt(document.getElementById("ipop" + i).style.width))/2)+document.body.scrollLeft+"px";
				}
			}
		}
}
window.onscroll=wf;
window.onresize=wf;


 function returnObjPosition(target,code){
	 if(code=='GIFTCARD'){
	 return;
	 }
	var x = 0;
	var y = 0;
	var tempObj = document.getElementById(target);
	//var obj = (typeof target == "object" ? target : returnObjById(target));
	obj = document.getElementById("img_"+target);

	while (obj.offsetParent != null) {
	x += obj.offsetLeft;
	y += obj.offsetTop;
	obj = obj.offsetParent;
	}
	x += obj.offsetLeft;
	y += obj.offsetTop;
	tempObj.style.left= x;
   //Added For Checking whether this request coming from the quick look page or not
	try
	{
	   	document.getElementById('forthumb').value;
		tempObj.style.top = y+5;
	}
	catch (error)
	{
			tempObj.style.top = y+50;
	}
	tempObj.style.display = "block";
	//return tempObj;
}
		
function hideDirQuickLook(target)
{
		
document.getElementById(target).style.display="none";
}


