function viewFlashPlayer(contextPath, url, popUrl) {	
	var objBody = document.getElementsByTagName("body").item(0);
	var objHtml = document.getElementsByTagName("html").item(0);
	createPopupDivs(contextPath,objBody,url,popUrl);
	var windowSizeY = document.body.clientHeight;
	document.getElementById('storeWrapper').style.height = windowSizeY + 'px';
	document.getElementById('storeWrapper').style.display = 'block';
	fadePopupWindow('in',0);
}

function createPopupDivs(contextPath, objBody,url, popUrl) {
	if (document.getElementById) {
		 var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
	}
	if (x) {
		 x.onreadystatechange = function() {
			if (x.readyState == 4 && x.status == 200) {
			  objLogindiv.innerHTML = x.responseText;
			  objBody.appendChild(objLogindiv);
			  var browserVersion = navigator.userAgent;
			  browserVersion.indexOf('MSIE ')>=0 ? initTabs_UFO('flashPopupTabs') :  initTabs('flashPopupTabs');
			  getFlashWidget(url,'idWidgetContainer_flashPopup');
			  document.getElementById('storePopupShadow').style.width = divWidth + 'px';
			  //scroll(0,0);
			}
		 }
		 
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','storeWrapper');
		objOverlay.setAttribute('class','contentBgColour');
		objOverlay.setAttribute('className','contentBgColour');
		objOverlay.style.display = 'none';
		objBody.appendChild(objOverlay);
		var objLogindiv = document.createElement("div");
		objLogindiv.setAttribute('id','storePopup');
		var divWidth;
		if( (url.indexOf('/video')>=0) || (url.indexOf('/photos')>=0) ) divWidth = 536;
		else divWidth = 446;
		var divHeight = 560;
		var windowSizeX = document.documentElement.clientWidth;
		var windowSizeY = document.documentElement.clientHeight;
		var currentScrollPos = window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop;
		objLogindiv.style.top = (currentScrollPos+40) + 'px';
		objLogindiv.style.left = (windowSizeX/2)-(divWidth/2)+'px'; 
		
		 x.open("GET", contextPath + '/misc/flashPopup.do?' + popUrl, true);
		 x.send(null);
	  }	
}

function fadePopupWindow(fadeType,fader) {
	fadeWindow('storeWrapper',fadeType,fader,20);
	 /* if (fadeType=='out') {
		fader=fader-20;
		faderOpacity = fader/100;
		document.getElementById('storeWrapper').style.filter = 'alpha(opacity='+fader+')';
		document.getElementById('storeWrapper').style.opacity = faderOpacity;
		setTimeout(function(){ if(fader==0) { var objBody = document.getElementsByTagName("body").item(0); objBody.removeChild(document.getElementById('storeWrapper')) } else fadePopupWindow('out',fader); }, 2);
	}
	else {
		fader=fader+20;
		faderOpacity = fader/100;
		document.getElementById('storeWrapper').style.filter = 'alpha(opacity='+fader+')';
		document.getElementById('storeWrapper').style.opacity = faderOpacity;
		setTimeout(function(){ fader==80 ? showDiv() : fadePopupWindow('in',fader) }, 2);
	} */
}

function closePopupWindow() {
	if(UFO.uaHas("ieWin")){
		UFO.cleanupIELeaks();
	}
	var objBody = document.getElementsByTagName("body").item(0);
	var objPopup = document.getElementById("storePopupBg");
	document.getElementById('storePopup').innerHTML = '';
	objBody.removeChild(document.getElementById('storePopup'));
	fadePopupWindow('out',80);
}


function togglePopupWidth(clickedLabel) { // IE had issues with getting the label from innerHTML, so now passing this
	/* var expandAmount = 95;
	var widthThreshold = 500;
	var popupShadowWidth = document.getElementById('storePopupShadow');
	if(clickedLabel=='video'||clickedLabel=='photos') {
		if(popupShadowWidth.offsetWidth < widthThreshold) {
		document.getElementById('idWidgetContainer_flashPopup').style.display = 'none';
			setTimeout(function() { slideWidth(popupShadowWidth,expandAmount,1,300); 
									slidePopupPos(document.getElementById('storePopup'),expandAmount/2,0,300); },150);
			setTimeout(function() { document.getElementById('idWidgetContainer_flashPopup').style.display = ''; },600);
		}
	} else if(popupShadowWidth.offsetWidth > widthThreshold) {
		document.getElementById('idWidgetContainer_flashPopup').style.visibility = 'hidden';
		setTimeout(function() { slideWidth(popupShadowWidth,expandAmount,0,300); 
								slidePopupPos(document.getElementById('storePopup'),expandAmount/2,1,300); },150);
		setTimeout(function() { document.getElementById('idWidgetContainer_flashPopup').style.visibility = 'visible'; },600);
	} */
}


/* SIMILIAR TO MOVER.JS */
function updatePopupPos(toExpandObject,initSize,size,startTime,direction,timelength) {
	var elapsed=new Date().getTime()-startTime //get time animation has run
	timelength = timelength*1;
	
	if (elapsed<timelength){ //if time run is less than specified length
		var distancepercent = curveincrement(elapsed/timelength);
		var newSizeValue   = (direction==1)? distancepercent * size + initSize + "px" : initSize - (distancepercent * size) + "px";
		toExpandObject.style.left = newSizeValue;
		runtimer=setTimeout(function(){updatePopupPos(toExpandObject,initSize,size,startTime,direction,timelength)}, 10);
		} else{ //if animation finished
			//toExpandObject.style.marginLeft=(direction==1)? size+initSize+"px" : initSize-size+"px";
			runtimer=null;
	} 
}

function slidePopupPos(toExpandObject,size,direction,timelength) {
	this.startTime=new Date().getTime() //Set animation start time
	var initPos = toExpandObject.offsetLeft;
	updatePopupPos(toExpandObject,initPos,size,startTime,direction,timelength);
}