﻿var gname;

var price;

var action;
var hold;
var productID;
//====================================================================================




    

//=========================================================================================
  
   function buy()
   {
    
  top.window.location.href="OMInformation.aspx";
   var argument ="&action=" + encodeURI("buy");
   takeout(argument);
   
   }

//==================================================================================

 var xHRObject = false;
if (window.XMLHttpRequest)
{
xHRObject = new XMLHttpRequest();

}
else if (window.ActiveXObject)
{
xHRObject = new ActiveXObject("Microsoft.XMLHTTP");

}

//===================================================================================

function getData(){
          
    if ((xHRObject.readyState == 4)&& (xHRObject.status == 200))
    {
  
       
        if (window.ActiveXObject)
            {  
           
                var xml=xHRObject.responseXML;
            
             
                var xsl=new ActiveXObject("Microsoft.XMLDOM");
                xsl.async=false;
                xsl.load("CartOM.xsl");
               
                var transform=xml.transformNode(xsl);
               
               
        
                 var spanb=document.getElementById("cartstuff");
           
              spanb.innerHTML=transform;
            
             }
             else
             {   
               
                var xsltProcessor=new XSLTProcessor();
                var xslStylesheet=document.implementation.createDocument("","doc",null);
                xslStylesheet.async=false;
                
                xslStylesheet.load("CartOM.xsl");
                xsltProcessor.importStylesheet(xslStylesheet);
                var xmlDoc=xHRObject.responseXML;
                
                var fragment=xsltProcessor.transformToFragment(xmlDoc,document);
                
                document.getElementById("cartstuff").innerHTML=new XMLSerializer().serializeToString(fragment);
              
             }
            
          
     }}
//=============================================================================================

function add(action)
{
  
    
        var bodyform=getBody(action);
    
     
        
    


   
    xHRObject.open("POST","OMcart.aspx",true);
    xHRObject.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xHRObject.onreadystatechange=getData;

 
    xHRObject.send(bodyform);
  // window.scrollTo(0,0); 
  // return false;
}

//=============================================================================================

  function getBody(action)
{   

   
    var name = gname;
    var price =gprice;
    
     
     var argument ="OM="
     argument += encodeURI("OM");
     argument += "&name=";
     argument += encodeURI(name); 
    
     argument += "&price=";
     argument += encodeURI(price);
     argument += "&action=";
     argument += encodeURI(action);
     argument += "&productID="
     argument += encodeURI(productID); 
    
    alert("You have added " + gname + " to your shopping cart at a cost of " + gprice + " each");
     return argument;
     }
     
     //===================================================================================
      function getShow(action)
{   

  
     
     var argument ="OM="
     argument += encodeURI("OM");
     argument += "&name=";
     argument += encodeURI(""); 
    
     argument += "&price=";
     argument += encodeURI("");
     argument += "&action=";
     argument += encodeURI(action); 
     argument += "&productID="
     argument += encodeURI(productID); 
    
     return argument;
     }
     //====================================================================================

 function allgone()
   {
  
   var argument ="&action=" + encodeURI("all");
   takeout(argument);
   }
   
//==========================================================================================




function content1(){
   
  
  document.getElementById("content").innerHTML="<b>Select Row To Remove Bracelet From Shopping Cart</b>";
  
   
   }
   
   
   //======================================================================================




   function removal(x,y){
 
 var newPara=document.getElementById('content');
 newPara.style.color = "white";

   newPara.innerHTML="You Have Removed <br /><b><span class='s1'>" + x + " @ " + y + " </span></b><br />From You Cart";
   
 //  var info = message.split(" ");
// alert(info[0]);
   var  argument = "&name=";
     argument += encodeURI(x); 
     
     argument += "&price=";
     argument += encodeURI(y);
     argument += "&action=";
     argument += encodeURI("remove"); 
      argument += "&productID="
     argument += encodeURI(productID); 
     
       takeout(argument);
 
   
   }
   
 //================================================================================= 
 
 
   function show(){
 

   var  argument = "&name=";
     argument += encodeURI(""); 
     argument += "&style=";
     argument += encodeURI(""); 
     
     argument += "&action=";
     argument += encodeURI("show"); 
      argument += "&productID="
     argument += encodeURI(productID); 
   window.scrollTo(0,0);
       takeout(argument);
 
   
   }
 
 

   //======================================================================================

function takeout(argument)
   {
      
    var bodyform=argument;
  
    xHRObject.open("POST","OMcart.aspx",true);
    xHRObject.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xHRObject.onreadystatechange=getData;
   
    xHRObject.send(bodyform);
    
   // window.scrollTo(0,0); 
   return false;
  
   }



//=======================================================================================


 