﻿
            
			var swfLoaded = false;
			var pendingProductID = -1;
			var pendingOrderItemID = -1;
			
            var swfVersionStr = "9.0.124";
            var xiSwfUrlStr = "${expressInstallSwf}";
            var flashvars = {};
            flashvars.sessionID = "7f3cdc29-c96e-4fe6-9863-56a6e78c3ab8";
            flashvars.channelID = "7f3cdc29-c96e-4fe6-9863-56a6e78c3aa8";
            flashvars.localizationCode = "en-US";
            flashvars.redirectURL = "http://www.expressionery.com/cart";
            flashvars.webServiceURL = "http://localhost/GreetingCardIntegrationServiceWeb/go_express.asmx";
            var params = {};
            params.quality = "high";
            params.bgcolor = "#000000";
            params.allowscriptaccess = "sameDomain";
            params.allowfullscreen = "true";
            params.wmode = "transparent";
            var attributes = {};
            attributes.id = "Configurator";
            attributes.name = "Configurator";
            attributes.align = "middle";
            
            function hideConfigurator()
			{
				// hide the flash content
				document.getElementById('Configurator').className = "hidden";

                if ( navigator.appName == 'Netscape' )
                {
				    document.getElementById('Configurator').style.visibility = "hidden";
				}

				window.onbeforeunload = '';
			}

			// show the configurator for a given product
			function showConfigurator( productID, strGuid, strOrderItemID , WServiceURL , RdirectUR, CID)
			{
                window.onbeforeunload = closeIt;

				// hide the button div
				// set the pending IDs
				flashvars.sessionID = strGuid ;
				pendingProductID = productID;
				pendingOrderItemID = strOrderItemID;
                flashvars.webServiceURL = WServiceURL;
                flashvars.redirectURL = RdirectUR;
                flashvars.channelID = CID;

				// if the swf has not been loaded, load it
				// once the swf has loaded, it will call loadPendingProduct()
				
				if( !swfLoaded )
				{
					swfobject.embedSWF(
		                "Configurator.swf", "flashContent", 
		                "100%", "100%", 
		                swfVersionStr, xiSwfUrlStr, 
		                flashvars, params, attributes);
					swfobject.createCSS("#flashContent", "display:block;text-align:left;");

					loadPendingProduct();
				}
				else
				{
    				// if the swf has been loaded, send it the product ID
					loadPendingProduct();
				}
			}

			// if there is a pending request to configure a product, pass it into the swf
			function loadPendingProduct()
			{	
				if( pendingProductID > 0 )
				{
					var swf = document.getElementById('Configurator');

					if ( swf )
					{
					    var posY = findPosY(swf);
					    var posX = findPosX(swf);
    					
                        swf.style.left = '0px';
                        swf.style.top = '0px';

                        if ( navigator.appName == 'Netscape' )
                        {
					        var width = GetDocumentWidth();

     					    swf.style.margin = '-' + posY + 'px 0px 0px 0px';

					        swf.style.width = width + 'px'
				            swf.style.visibility = 'visible';
                        }
                        else
                        {
       					    swf.style.margin = '-' + posY + 'px 0px 0px -' + posX + 'px';
                        }					
    					
       					swf.style.position = "absolute";
			            swf.style.height = GetDocumentHeight() + 'px';
					    swf.className = "visible";
					    swf.loadProduct( pendingProductID, pendingOrderItemID );
					}
				}

				pendingProductID = -1;
				pendingOrderItemID = 0;
				swfLoaded = true;
				
				window.scrollTo( 0, 0 );
			}

            function resize()
              {  
                      var myWidth = 0, myHeight = 0;
                        myWidth = document.body.clientWidth;
                        myHeight = document.body.clientHeight;

                        if ( window.innerHeight > myHeight)
                            myHeight = window.innerHeight;
                            else
                            if ( document.documentElement.clientHeight > myHeight )
                                myHeight = document.documentElement.clientHeight;

                    var swf = document.getElementById('Configurator');
                    
		            swf.width = myWidth ;
		            swf.height = myHeight;
                    swf.style.height = myHeight;
                    
		             var body_ele = document.getElementById( '' );
		             var html_ele = document.getElementById( 'html' );
//		             swf.setAttribute('position', 'absolute');
//		             swf.style.position = 'absolute';
//        		     left: 0px;
//                     top: 0px;
		             
		             
//		             body_ele.style.height = myHeight;
		             
		             //html_ele.setAttribute('visible', false);
 
              }
              
		function closeIt()
        {
        	var swf = document.getElementById('Configurator');
            if ( swf )
		    {
		         return "If you do the contents of your card will be lost";
		    }
        }

	
		function init(){
			window.onresize = resize;
            
            window.onbeforeunload = closeIt;
		}
		
		function bodyInit()
		{
		    window.onbeforeunload = "";
		}
 
