// alert("photoevents1.js"); 
var jsReady = false; 
var swfReady = false; 

// set up our AJAX request 
function createRequest() {
  try {
    request = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        request = null;
      }
    }
  }

  if (request == null) {
    // alert("Error creating request object!");
  } else {
   // alert("Success in creating request object!"); 
  }
}


function isReady()
{ return jsReady; } 

function pageInit()
{ // alert("pageInit has been called"); 
  jsReady = true; } 


function setSWFIsReady()
{ // alert("setSWFisReady has been called"); 
  swfReady = true; 
 // updateStatus(); 
} 

// javascript for communication with SWF file 
function getSWF(movieName)
{ if(navigator.appName.indexOf("Microsoft") != -1)
 { return window[movieName]; }
 else 
 { return document[movieName]; } 
}


function addPhoto2CartResponse()
{ if(request.readyState == 4)
  { if(request.status == 200)
	{  var msg = request.responseText; // change response to XML to work in DOM
       
	//   alert("msg = "+msg); 
     
	  var thisswf = getSWF("mymovie"); 
      // alert("this.swf = "+thisswf.id);  
  
	/*  if(msg != "pass")
	  {  thisswf.addPhoto2CartFailResponse(msg);}  
	  else
	  { thisswf.addPhoto2CartPassResponse(msg);} */
	  
	  thisswf.addPhoto2CartPassResponse(msg);
	   
	} // end if status == 200
  }else
  { // alert("response from server failed"); 
    // results_box("Failed request");
	 // alert("response failed"); 
  }
}

function addPhoto2Cart(lineinfo)
{ // take info from FLASH and do and AJAX call to server to add this to shopping cart 
   // alert("called addPhoto2Cart"); 
   // alert("price = "+lineinfo.price+", photourl = "+lineinfo.photourl+", photopkg="+lineinfo.photopkg); 
   createRequest();
   
   var url = "photocart1.php?photourl="+lineinfo.photourl+"&photopkg="+lineinfo.photopkg+"&price="+lineinfo.price; 
   // alert("url called ="+url); 
   url = url + "&dummy=" + new Date().getTime();
   request.open("GET", url, true);
   request.onreadystatechange = addPhoto2CartResponse;  
   request.send(null); 
 //  addPhoto2CartResponse(); 
 
}

