loadingSecs=4000;
var m = '../../virtual-mirror/bin/en/virtual-mirror-en'; // m = movie name
//var m = 'http://mirror.globaleyeglasses.com/virtual-mirror/bin/en/virtual-mirror-en';
function callAsFunc(arg0, arg1, arg2, arg3, icd, arg4) 
{
	theFrameId=arg3;theFramePath=arg0;theFrameName=arg1;theFrameLoc=arg2;theFrameNum=icd;
	
	
	for(ix=0;ix<6;ix++)
	{
		shame=eval('document.getElementById("frame_'+ix+'")')
		if(shame)
		{
			shame.style.border="1px #FFF solid";
			//1px #F00 solid
		}
	}
	shame=eval('document.getElementById("frame_'+icd+'")')
	if(shame)
	{
		shame.style.border="1px #F00 solid";
	}
	getFlashMovie(m).loadFrame(arg0, arg1, arg2, arg3); 
	
	//document.order_form.frameId.value=arg4;
} 
function getFlashMovie(movieName) 
{
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];
}
function callAsAddShot() 
{
	getFlashMovie(m).addShot(); 
	shame=eval('document.getElementById("faceLoader")')
	if(shame)
	{
		shame.style.display="block";
	}
	colorId=document.order_form.frameId.value;
	setTimeout("deva("+colorId+")", loadingSecs);	
}
function deva(colorId)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	//show();
	var url=refPath+"ajax_calls/loadFlashImages.php"
	url=url+"?refPath="+refPath
	url=url+"&colorId="+colorId
	url=url+"&sid="+Math.random()	
	
	xmlHttp.onreadystatechange=getThumbStatus
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function getThumbStatus()
{
	if (xmlHttp.readyState==4  && xmlHttp.status==200)
	{
		var pkk=xmlHttp.responseText;
		javs=eval('document.getElementById("shotComparer")')
		if(javs)
		{
			javs.innerHTML=pkk;
			SlideDown("divCompareShot");
		}
	}
}
function callAsLoadShot(arg0, arg1) 
{
 	if(arg1 && arg1>0)
	{
		document.order_form.frameId.value=arg1;
	}
	getFlashMovie(m).loadShot(arg0); 
}
function callAsRemoveLastShot() {
	getFlashMovie(m).removeLastShot(); 
}

function callAsRemoveShot(arg0, arg0x) 
{
	shame=eval('document.getElementById("faceLoader")')
	if(shame)
	{
		shame.style.display="block";
	}

	
	getFlashMovie(m).removeShot(arg0); 
	setTimeout("deva()", loadingSecs);
}
function SlideDown(a)
{
	$("#"+a).slideDown("slow");
}
function SlideUp(a)
{
	$("#"+a).slideUp("slow");
}
function showIt(a)
{
	$("#"+a).show("slow");
}
function hideIt(a)
{
	$("#"+a).hide("slow");
}
function callAsLoadModel(arg0, arg1) {
    getFlashMovie(m).loadModel(arg0, arg1);
	//callAsFunc(FramePath, theFrameName, theFrameLoc, theFrameId, theFrameNum);
}
function callAsShareOnFacebook() {
    getFlashMovie(m).shareOnFacebook(); 
	shame=eval('document.getElementById("faceLoader")')
	if(shame)
	{
		shame.style.display="block";
	}
	colorId=document.order_form.frameId.value;
	setTimeout("deva("+colorId+")", loadingSecs);	
}
function callAsLoadModel2(arg0, arg1) {
    getFlashMovie(m).loadModel(arg0, arg1); 
	callAsFunc('', theFrameName, theFrameLoc, theFrameId, theFrameNum);
}
function getCookieVal()
{
	if($cookieVal==0)
	{
		$cookieValSet=1;
	}
	if($cookieValSet==0)
	{
		theValue2 = $cookieVal;
		$cookieValSet=1;
	}
	else
	{
		theValue2 = theValue=getCookie('v_shot');
	}
	return theValue2;
}
function putInWishListAjax(ids, names, prices, pic, divId)
{
	//alert("id="+ids)
	shameDiv=eval("document.getElementById('"+divId+"')");
	theValue=getCookie('g_wish');
	if (theValue==null)
	{
		theValue="";
	}
	//alert("thevalue="+theValue);
	matchId=0;
	if(theValue=="")
	{
		theValue=ids+"^^"+pic;
		//document.getElementById("ulWishList2").innerHTML = '<span id="li'+ids+'"><img src="'+pic+'" width=100 height=40></span>';
		setCookie('g_wish', theValue, 15);
	}
	else
	{
		theValue2=theValue.split("~~");
		for(ix=0;ix<theValue2.length;ix++)
		{
			idVal=theValue2[ix].split("^^");
			//alert(idVal"")
			
			if(idVal[1]==pic)
			{
				//alert("This frame already in wish list");
				//return false;
				matchId=1;
				ix=theValue2.length;
			}
		}
		if(matchId==0)
		{
			//alert("its 0");
			theValue=theValue+"~~"+ids+"^^"+pic;
			if(shameDiv)
			{
				//newImage = "url(images-test/wish-list-icon-aft.jpg)";
				//shameDiv.style.backgroundImage=newImage;
				shameDiv.src=refPath+"images-test/wish-list-icon-aft.jpg";
			}
		}
		else if(matchId==1)
		{
			if(shameDiv)
			{
				//shameDiv.style.background-image="url('images-test/wish-list-icon-aft.jpg')";
				//newImage = "url(images-test/wish-list-icon-bfr.jpg)";
				shameDiv.src=refPath+"images-test/wish-list-icon-bfr.jpg";
			}
			
			
			theValuex1="~~"+ids+"^^"+pic;	
			theValuex2=ids+"^^"+pic+"~~";
			theValuex3=ids+"^^"+pic;		
			//alert(theValuex3+"    "+theValue)
			
			theValue = theValue.replace(theValuex1, "");
			theValue = theValue.replace(theValuex2, "");
			theValue = theValue.replace(theValuex3, "");
		}

		/*
		theWishContent="";
		theValue2=theValue.split("~~");
		for(ix=0;ix<theValue2.length;ix++)
		{
			idVal=theValue2[ix].split("^^");
			theWishContent+='<span id="li'+idVal[0]+'"><img src="'+idVal[1]+'" width=100 height=40></span>';
		}
		document.getElementById("ulWishList2").innerHTML = theWishContent;
		*/
		setCookie('g_wish', theValue, 15);
	}
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		//show();
		
		var url="php/cookieVals.php"
		url=url+"?pack="+theValue
		url=url+"&sid="+Math.random()	
		//alert(url);
		xmlHttp.onreadystatechange=getCookieVals
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)	
}
function getCookieVals()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		var pkk=xmlHttp.responseText;
		//alert(pkk)
		document.getElementById("ulWishList22").innerHTML=pkk;
		theValue=getCookie('g_wish');
		if(theValue.length>6)
		{
			document.getElementById("ulWishList2XX").style.display="block";
		}
		else
		{
			document.getElementById("ulWishList2XX").style.display="none";
		}
	} 
}
function miniPopUp(prod_id, the_value)
{
	showIt('popx');
	//showIt('popx');return false;
	shame=eval('document.getElementById("theResults2")');
	if(shame)
	{
		shame.style.display='block';
	}
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	//alert(par);
	//show();
	var url=refPath+"ajax_calls/changeMiniImage.php"
	url=url+"?prodId="+prod_id
	url=url+"&color="+the_value
	url=url+"&refPath="+refPath
	url=url+"&sid="+Math.random()
	//alert("url="+url);
	xmlHttp.onreadystatechange=changeMiniImage
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function changeMiniImage()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		
		
		var pkk=xmlHttp.responseText;
		//alert("pkk="+pkk);
		document.getElementById("popx").innerHTML=pkk;	
	}
}
function changeOption(a,b)
{
	$("#"+a).slideToggle('slow');
	//search options
	if(b.value=='Show Search Option')
	{
		b.value='Hide Search Option';
	}
	else if(b.value=='Hide Search Option')
	{
		b.value='Show Search Option';
	}
	//shots
	else if(b.value=='Show Compare Shot')
	{
		b.value='Hide Compare Shot';
	}
	else if(b.value=='Hide Compare Shot')
	{
		b.value='Show Compare Shot';
	}
	//favorites
	else if(b.value=='Show Recent Favorites')
	{
		b.value='Hide Recent Favorites';
	}
	else if(b.value=='Hide Recent Favorites')
	{
		b.value='Show Recent Favorites';
	}
};
