var xmlHttp


function subscribeToNewsletter(email){ 
    var url="http://ws.studio127.com/subscribe.aspx";
    url="/subscribe.aspx";
    url=url+"?Email="+email+"&Password=2009studio127";
    document.getElementById("Ul1").innerHTML = "<img src='"+url+"' width='1' height='1' style='visibility:hidden'/><span class='headerBlue'>Thank You</span>";
    xmlHttp=GetXmlHttpObject();
    xmlHttp.responseText;
    //url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=function(){
    if(xmlHttp.readyState==4){
        //window.location='/subscribe.aspx?Email='+ email;
        
      }
    }
    //xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
        
}

function getSubDeptFromDept(deptID,dependentID,selectedVal){ 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
        alert ("Your browser does not support AJAX!");
        return;
    }
  
    var url="/admin/includes/postResponse.asp";
    url=url+"?q="+deptID;
    url=url+"&q1="+dependentID;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=function(){
    if(xmlHttp.readyState==4){
        document.getElementById("Wrap"+dependentID).innerHTML=xmlHttp.responseText;
      }
    }
    //xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function sendToFriend(strPrice,strDeptId,strDeptSubId,strCatId,strCatName,strsendfriend,strsendfemail,strsendname,strsendform,sendmessage){ 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
        alert ("Your browser does not support AJAX!");
        return;
    }
    //alert(strPrice+','+strDeptId+','+strDeptSubId+','+strCatId+','+strCatName+','+strsendfriend+','+strsendfemail+','+strsendname+','+strsendform+','+sendmessage);
    var url="/sendToFriend_001.asp";
    url=url+"?strPrice="+strPrice;
    url=url+"&strDeptId="+strDeptId;
    url=url+"&strDeptSubId="+strDeptSubId;
    url=url+"&strCatId="+strCatId;
    url=url+"&strCatName="+strCatName;
    url=url+"&strsendfriend="+strsendfriend;
    url=url+"&strsendfemail="+strsendfemail;
    url=url+"&strsendname="+strsendname;
    url=url+"&strsendform="+strsendform;
    url=url+"&sendmessage="+sendmessage;
    url=url+"&sid="+Math.random();
    //xmlHttp.onreadystatechange=function(){
    //if(xmlHttp.readyState==4){alert('ff');
    //    alert(mlHttp.responseText);
   //   }
    //}
    
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function addNewPalette(item1,item2,item3,background,design,message,font,to,from,strfontSize,fontLeading){ 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
        alert ("Your browser does not support AJAX!");
        return;
    }
    var url="/addNewPalette.asp";
    url=url+"?item1="+item1;
    url=url+"&item2="+item2;
    url=url+"&item3="+item3;
    url=url+"&background="+background;
    url=url+"&design="+design;
    url=url+"&message="+escape(message);
    url=url+"&font="+font;
    url=url+"&to="+escape(to);
    url=url+"&from="+escape(from);
    url=url+"&fontSize="+strfontSize;
    url=url+"&fontLeading="+fontLeading;
    url=url+"&sid="+Math.random();
    //window.location = url;
   xmlHttp.onreadystatechange=function(){
    if(xmlHttp.readyState==4){
        window.location='/view_bag_001.asp?palette_id='+xmlHttp.responseText+'&add_item=90228';
      }
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function checkCaptchaAndGift(captchaValue,giftValue) {
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return;
    }
    var url = "/addGiftCard.asp";
    url = url + "?captchaValue=" + captchaValue;
    url = url + "&giftValue=" + giftValue;
    url = url + "&sid=" + Math.random();
    xmlHttp.onreadystatechange = function (){
        if (xmlHttp.readyState == 4) {
            var msg = xmlHttp.responseText;
            if (msg.length <= 10){
                giftCardDisplay(3);
                document.getElementById("giftCardBalancelbl").innerHTML='-$'+parseFloat(msg);
                var varTotal = document.getElementById("displayTotal").value.replace('$','')-msg;
                var giftBalance=0;
                if(varTotal<=0){
                    giftBalance = varTotal * -1; 
                    varTotal=0;
                    document.getElementById("gift_balance_001").innerHTML = 'YOUR GIFT CARD BALANCE IS $'+ parseFloat(giftBalance).toFixed(2);
                }
                document.getElementById("displayTotal2").innerHTML='$'+ parseFloat(varTotal).toFixed(2);
                document.getElementById("myShopBag").style.margin='0px 0px 10px 0px';
                document.getElementById("hiddenTotal").style.visibility='visible';
                document.getElementById("hiddenGCTot").value = varTotal;
                document.getElementById("hiddenGCBal").value = parseFloat(msg);
                
                //document.getElementById("x_amount").value=varTotal;
            } else {
                RefreshImage("imgCaptcha");document.getElementById('captchacode').value='';
                alert(msg);
            }
        }
    };
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}

function addGiftCardToCart(name,toEmail,msg,idmount,card,ani,tagline){ 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
        alert ("Your browser does not support AJAX!");
        return;
    }
    var url="/addNewGiftCard.asp";
    url=url+"?name="+escape(name);
    url=url+"&toEmail="+toEmail;
    url=url+"&msg="+escape(msg);
    url=url+"&idmount="+idmount;
    url=url+"&card="+card;
    url=url+"&ani="+ani;
    url=url+"&tagline="+tagline;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=function(){
    if(xmlHttp.readyState==4){
        window.location='/view_bag_001.asp?palette_id='+xmlHttp.responseText+'&add_item='+idmount;
      }
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function stfGetPass(strEmail){
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
        alert ("Your browser does not support AJAX!");
        return;
    }
    var url="/getPassword_001.asp";
    url=url+"?strEmail="+strEmail;
    
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=function(){
    if(xmlHttp.readyState==4){
        document.getElementById("msg").innerHTML=xmlHttp.responseText;
        }
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function stateChanged(){ 
    if (xmlHttp.readyState==4){
        //alert(xmlHttp.responseText);
        //document.getElementById("time").innerHTML=xmlHttp.responseText;
        if(xmlHttp.responseText.length>=1){win.close();}else{alert('There has been a problem');};
    }
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}