1
function redirect()
{
 location.href="../../bag.asp?add=true&basket_cookie="+getCookie("basket_cookie")
}


function round_amount2(amount)
{
 amount=Math.round(amount*100)/100
 return(amount==Math.floor(amount))? amount + '.00' :((amount*10 == Math.floor(amount*10)) ? amount + '0' :amount);
}

function PopupPic(sPicURL,product) 
{ 
	sPicURL=sPicURL+"&product="+escape(product)
   window.open( "../../poptofit.html?"+sPicURL, "",  "resizable=1,left=50,top=50,HEIGHT=200,WIDTH=200"); 
}

function getCookie(name)
{
 cname=name+"="
 dc=document.cookie
 if(dc.length>0)
 {
  begin=dc.indexOf(cname)
  if(begin!=-1)
  {
   begin+=cname.length
   end=dc.indexOf(";",begin)
   if(end==-1)end=dc.length
   return unescape(dc.substring(begin,end));
  }
 }
 return ""
}

function setCookie(cv)
{  
 document.cookie=cv+"; path=/;"
}

if(!getCookie("basket_cookie"))
{
 setCookie("basket_cookie=")
}


function write_array(arr)
{
 nc=""
 for(x in arr)
 {
  if(x!="")if(arr[x]!=0)nc+=x+"|"+arr[x]+":"
 }
 setCookie("basket_cookie="+nc)
}

function make_arrays(cook)
{
 cook_arr=cook.split(":")
 new_cook_arr=new Array()
 for(i=0;i<cook_arr.length;i++)
 {
   n=cook_arr[i].split("|")[0]
   v=cook_arr[i].split("|")[1]
   eval("new_cook_arr['"+n+"']='"+v+"'")
 }
}

// use this one where you are selecting from dropdowns
function add_to_basket()
{
  it=document.f1.s1.options[document.f1.s1.selectedIndex].value
  qty=document.f1.quantity.options[document.f1.quantity.selectedIndex].text
  make_arrays(getCookie("basket_cookie"))
  eval("new_cook_arr['"+it+"']='"+qty+"'")
  write_array(new_cook_arr)
}

//use this one for single item

//add_to_basket3()
//{
//  it=document.f1.s1.value
//  qty=document.f1.quantity.options[document.f1.quantity.selectedIndex].value
//  make_arrays(getCookie("basket_cookie"))
//  eval("new_cook_arr['"+it+"']='"+qty+"'")
//  write_array(new_cook_arr)
//  alert(new_cook_arr)
//}

function add_to_basket3(i)
{
 add_to_basket_checkout(i)
 document.location.href='../../dtat_shop_checkout2.asp'+getCookie("basket_cookie")
}


// use this one where a number of items are on one page

function add_to_basket_checkout(i)
{
 if(document.f1.stock_key.length+""!="undefined")
 {
  it=document.f1.stock_key[i].value
  qty=eval("document.f1.quantity["+i+"].options[document.f1.quantity["+i+"].selectedIndex].value")
 }
 else
 {
  it=document.f1.stock_key.value
  qty=eval("document.f1.quantity.options[document.f1.quantity.selectedIndex].value")
 }
 make_arrays(getCookie("basket_cookie"))
 eval("new_cook_arr['"+it+"']='"+qty+"'")
 write_array(new_cook_arr)
}


//use this one for the checkoutpage
function add_to_basket2(i,p,d)
{
 add_to_basket_checkout(i)
 location.href='bag.asp?add=true&basket_cookie='+getCookie("basket_cookie")+'&pc='+p+'&disc='+d
}



function check_contents2()
{ 
 selwrd=document.f1.s1.options[document.f1.s1.selectedIndex].value
 seltext=document.f1.s1.options[document.f1.s1.selectedIndex].text
 if(seltext.indexOf("sold out")!=-1)
 {
  alert("Sorry - this size is out of stock")
  return False
 }
 else
 {
  qty=document.f1.quantity.options[document.f1.quantity.selectedIndex].value
  if(selwrd=='x')
  {
   alert("Please select garment size")
  }
  else
  if(selwrd=='y')
  {
   alert("Please select swing easy motif option")
  }
  else
  {
   if(selwrd.indexOf("out of stock")!=-1)
   {
    alert("This item is out of stock, please choose another")
    return false
   }
   if(!(document.f1.s1.options.selectedIndex==0))
   {
    it=document.f1.s1.options[document.f1.s1.selectedIndex].value
    make_arrays(getCookie("basket_cookie"))
    eval("new_cook_arr['"+it+"']='"+qty+"'")
    write_array(new_cook_arr)
   }
   else
   {
    it=document.f1.s1.options[0].value
    make_arrays(getCookie("basket_cookie"))
    eval("new_cook_arr['"+it+"']='"+qty+"'")
    write_array(new_cook_arr)
   }
   location.href="../../bag.asp?add=true&basket_cookie="+getCookie("basket_cookie")+"&pc="+getCookie("pc_cookie")+"&disc="+getCookie("disc_cookie")
  }
 }
}

function redirect()
{
 location.href='../../bag.asp?add=true&basket_cookie='+getCookie("basket_cookie")
}

function gobasket()
{
 bc=getCookie("basket_cookie")
 pc=getCookie("pc_cookie")
 d=getCookie("disc_cookie")
 u='http://www.dressedtoatee.co.uk/bag.asp?basket_cookie='+bc+'&pc='+pc+'&disc='+d
// u='http://localhost/dtat/draft/bag.asp?basket_cookie='+bc+'&pc='+pc+'&disc='+d
// alert(u)
 location.href=u
}

function itemcount()
{
  bc=getCookie("basket_cookie")
  bca=bc.split(":")
  bcl=bca.length
  ic=0
  for(i=0;i<bcl-1;i++)
  {
   ic+=bca[i].split("|")[1]/1
  }
  t=' items'
  if(ic==1)t=' item'
  document.write(ic+t)
}

var xmlHttp

var inht=""

function getdata(q)
{
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)
 {
  alert ("Browser does not support HTTP Request")
  return
 } 
 url='../../get_stock.asp?q='+q
 xmlHttp.onreadystatechange=stateChanged 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
 document.getElementById("inht").innerHTML=xmlHttp.responseText
} 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}

function pop_open()
{
   window.open( "../../pop_up.html","","resizable=1,left=50,top=50,HEIGHT=600,WIDTH=566"); 
}

function change_main(m)
{
 if(m=="n")
 { 
  m=start_pic+1
  if(m>4)m=1
 }
 if(m=="p")
 { 
  m=start_pic-1
  if(m<1)m=4
 }
 start_pic=m
 document.getElementById("main").src=main_images[m-1]
}


exp=new Date();
exp.setTime(exp.getTime()+(1000*60*60*24*365)); 
function getCookie(name)
{
 cname=name+"="
 dc=document.cookie
 if(dc.length>0)
 {
  begin=dc.indexOf(cname)
  if(begin!=-1)
  {
   begin+=cname.length
   end=dc.indexOf(";",begin)
   if(end==-1)end=dc.length
   return unescape(dc.substring(begin,end));
  }
 }
 return ""
}

function setCookie(cv)
{  
 document.cookie=cv+"; path=/"+((exp==null)?"":";expires=" +exp.toGMTString());
}
if(!getCookie("dtat_cookie"))
{
 setCookie("dtat_cookie="+Math.round(Math.random(1)*100000000))
}
