//====================  [ GLOBAL VARIABLEs]  =====================================//
var meinterval=0;
var wishlistid=0;

var wishlistid_for_bag;
var variid_for_bag;
var pro_quantity;
var noofQuantity;
//=========================  [END]  =================================================//
function setID(select,quanselect)
{


document.getElementById('selectquantity_up').style.visibility="visible";

document.getElementById('uidpk').value=select.options[select.selectedIndex].value;
document.view_bag_popup.itemid.value=select.options[select.selectedIndex].value;
var getQuantity=quanselect.options[select.selectedIndex].value;
var quantity_up = new Array();
var selectquantityup=document.getElementById("selectquantity_up");
selectquantityup.options[0]=new Option("1","1");
//alert(getQuantity);
//if(getQuantity<10){
var count_option=1;

for(var i=2; i<=5; i++)
{
selectquantityup.options[count_option]=new Option(i,i);
count_option=count_option+1;
}
selectquantityup.options[5]=new Option(10,10);
selectquantityup.options[6]=new Option(20,20);
selectquantityup.options[7]=new Option(30,30);
selectquantityup.options[8]=new Option(40,40);
selectquantityup.options[9]=new Option(50,50);
/*
}else if(getQuantity<11)
for(var i=1; i<=5; i++)
{
selectquantityup.options[i]=new Option(i,i);
}
selectquantityup.options[6]=new Option(10,10);
}else if(getQuantity<21){
for(var i=1; i<=5; i++)
{
selectquantityup.options[i]=new Option(i,i);
}
selectquantityup.options[6]=new Option(10,10);
selectquantityup.options[7]=new Option(20,20);
}else if(getQuantity<31){
for(var i=1; i<=5; i++)
{
selectquantityup.options[i]=new Option(i,i);
}
selectquantityup.options[6]=new Option(10,10);
selectquantityup.options[7]=new Option(20,20);
selectquantityup.options[8]=new Option(30,30);
}else if(getQuantity<41){
for(var i=1; i<=5; i++)
{
selectquantityup.options[i]=new Option(i,i);
}
selectquantityup.options[6]=new Option(10,10);
selectquantityup.options[7]=new Option(20,20);
selectquantityup.options[8]=new Option(30,30);
selectquantityup.options[9]=new Option(40,40);

}else{
for(var i=1; i<=5; i++)
{
selectquantityup.options[i]=new Option(i,i);
}
selectquantityup.options[6]=new Option(10,10);
selectquantityup.options[7]=new Option(20,20);
selectquantityup.options[8]=new Option(30,30);
selectquantityup.options[9]=new Option(40,40);
selectquantityup.options[10]=new Option(50,50);
}

*/

}

function setQuantity(quanselect)
{
document.getElementById('quantity').value=quanselect.options[quanselect.selectedIndex].value;

}

//====================  [ checkoutchange Image rolling ]  =============================//
function checkoutchange1()
{
document.getElementById('chkchang').src=contextpath+"images/general_images/checkout_on.gif";
}
function checkoutchange2()
{
document.getElementById('chkchang').src=contextpath+"images/general_images/addtobag_redltrs.gif";
}
//=========================  [END]  ====================================================//


//====================  [ MY Bag Containt Popup ]  =====================================//
/***************************************************************************************/
//this function is calling from productdisplay.vm page (when we click on ADD TO BAG image 
/***************************************************************************************/

var itemid="";
var itemname="";
var itemcolor="";
var itemsize="";
var itemprice="";
var itemimage="";
var select="";
var sizename="";
var product_name_forpopup="";
var old_bagid="";

function clearfunc()
{
//alert("nav");
}

function adddata(addbut,selectme,quanselect,itemno)
{
document.view_bag_popup.prodisplay_url.value=product_nameURL;
var getTblId=document.getElementById('mainTblID');
getTblId.onmouseover=clear_actionpop;

select=selectme;


if(select.selectedIndex==0)
{}else{

noofQuantity=quanselect.options[quanselect.selectedIndex].value;
document.view_bag_popup.pro_quantity.value=noofQuantity;

}
var selectsizename=document.getElementById("selectsizename");
itemid=document.view_bag_popup.itemid.value;
itemname=document.view_bag_popup.itemname.value;
itemcolor=document.view_bag_popup.itemcolor.value;
itemsize=document.view_bag_popup.itemsize.value;
itemprice=document.view_bag_popup.itemprice.value;
itemimage=document.view_bag_popup.itemimage.value;
pro_quantity=document.view_bag_popup.pro_quantity.value;
pro_disURL=document.view_bag_popup.prodisplay_url.value;
//alert(pro_disURL+" now==>");
setCookie("variNO",document.view_bag_popup.prodvarino.value);

product_name_forpopup=document.view_bag_popup.productname.value;

addbut.src=contextpath+"images/image/adding.gif";
var data=getCookie("cart");
//alert("from prodDisplay ==>"+data);
var cartcontent;
var xmlobject;
if(navigator.appName=="Netscape" || navigator.appName=="Opera")
{
xmlobject=document.implementation.createDocument('','',null);
var xmlp=new DOMParser();
//xmlobject.load("Tests.xml","text/xml");
xmlobject=xmlp.parseFromString(data,"text/xml");
}
else{
xmlobject = new ActiveXObject("Microsoft.XMLDOM");
xmlobject.async=false;
xmlobject.loadXML(data);
}




/*
if(noofQuantity=="Select quantity")
{
alert("Please select a quantity");
document.getElementById('addtobag').src="image/add_to_bag.gif";
return;
}
*/
if(select.selectedIndex==0)
{
//lock.src=contextpath+"image/bagbangbus_off.gif";
alert("Please select a size");
document.getElementById('addtobag').src=contextpath+"images/image/add_to_bag.gif";
}else{
var fi=xmlobject.getElementsByTagName("itemid");
var fi1=xmlobject.getElementsByTagName("itemname");
var fi2=xmlobject.getElementsByTagName("itemcolor");
//var fi3=xmlobject.getElementsByTagName("itemsize");
var fi4=xmlobject.getElementsByTagName("itemprice");
var fi5=xmlobject.getElementsByTagName("quantity");
var fi6=xmlobject.getElementsByTagName("proURL");
var fi7=xmlobject.getElementsByTagName("proNO");




cartcontent="<cart>";
var ii;
for(ii=0;ii<fi.length;++ii)
{
cartcontent=cartcontent+"<item>";
cartcontent=cartcontent+"<itemid>"+fi[ii].firstChild.nodeValue+"</itemid>";
cartcontent=cartcontent+"<itemname>"+fi1[ii].firstChild.nodeValue+"</itemname>";
//cartcontent=cartcontent+"<itemsize>"+fi3[ii].firstChild.nodeValue+"</itemsize>";
cartcontent=cartcontent+"<itemprice>"+fi4[ii].firstChild.nodeValue+"</itemprice>";
cartcontent=cartcontent+"<quantity>"+fi5[ii].firstChild.nodeValue+"</quantity>";
cartcontent=cartcontent+"<proURL>"+fi6[ii].firstChild.nodeValue+"</proURL>";
cartcontent=cartcontent+"<proNO>"+fi7[ii].firstChild.nodeValue+"</proNO>";
cartcontent=cartcontent+"</item>";
}
cartcontent=cartcontent+"<item>";
cartcontent=cartcontent+"<itemid>"+itemid+"</itemid>";
cartcontent=cartcontent+"<itemname>"+document.view_bag_popup.productname.value+"</itemname>";
//cartcontent=cartcontent+"<itemsize>"+selectsizename.options[select.selectedIndex].value+"</itemsize>";
cartcontent=cartcontent+"<itemprice>"+itemprice+"</itemprice>";
cartcontent=cartcontent+"<quantity>"+pro_quantity+"</quantity>";
cartcontent=cartcontent+"<proURL>"+pro_disURL+"</proURL>";
cartcontent=cartcontent+"<proNO>"+itemno+"</proNO>";
cartcontent=cartcontent+"</item>";
cartcontent=cartcontent+"</cart>";
//            this function set XML String into cookie       (-!-)                        
//            setCookie() function is define into cookie.js  (-!-)                       
setCookie("cart",cartcontent);
//var mytemp = getCookie("cart");
//alert(mytemp);
//            asynchGet() is  AJAX CALL           
asynchGet();

//       this function generate time interval for my bag containt Popup   (-!-)
sizename=selectsizename.options[select.selectedIndex].value;
morehidetime_atb();

}
}

function loadCart(itemimg,proname,sizeme)
{
var cartviewobject=document.getElementById("cartslide");
cartviewobject.style.display="block";
//alert(itemimg+ " "+proname+" "+sizeme);
if(navigator.appName=="Netscape" || navigator.appName=="Opera")
{
var cartcont="<table  border='0px'  width=238px cellspacing='0px' cellpadding='0px'><tr width=100% height=100%  ><td width=100% height=100% valign=bottom bgcolor='#939A9F' ><table style='border:3px solid #939A9F'   width=99% height=95% valign=center align=center bgcolor='#ffffff' >";
}
else
{
var cartcont="<table  border='0px'  width=238px cellspacing='0px' cellpadding='0px'><tr width=100% height=100%  ><td width=100% height=100% valign=bottom bgcolor='#939A9F' ><table style='border:3px solid #939A9F'   width=99% height=95% valign=center align=center bgcolor='#ffffff' >";
}
carttop=document.getElementById("cart");
carttop2=document.getElementById("cart2");
carttop3=document.getElementById("cart3");



carttop.className="popupdisplaybg";
//carttop2.className="popupdisplaybg";
carttop3.className="popupdisplaybg";


cartimage=itemimg;
var ii;
var pric=0;
cartcont=cartcont+"<tr width=100% ><td colspan=2 height=6px></td></tr>"
cartcont=cartcont+"<tr width=100%><td  align='center' colspan=2 class='popupdisplayfont'><b>THIS ITEM HAS BEEN</b></td></tr>";
cartcont=cartcont+"<tr width=100%><td  align='center' colspan=2 class='popupdisplayfont'><b>ADDED TO YOUR CART.</b></td></tr>";
cartcont=cartcont+"<tr width=90% ><td colspan=2 height=6px></td></tr>"
cartcont=cartcont+"<tr width=90% bgcolor=#999999 ><td colspan=2 height=1px></td></tr>";
cartcont=cartcont+"<tr  valign='top'><td><img src="+cartimage+" width='105'  style='border:0px double #e5e5e5;'></td><td ><table  width=100% height=100%  align=left ><tr width=100% valign='top'><td valign='top'>";
if(product_name_forpopup.length>17)//eany
cartcont=cartcont+"<span class='popupdisplayfont'><b>"+product_name_forpopup.substring(0,15)+"<BR>"+product_name_forpopup.substring(15,product_name_forpopup.length)+"</b></span></td></tr>";
else
cartcont=cartcont+"<span class='popupdisplayfont'><b>"+product_name_forpopup.substring(0,17)+"</b></span></td></tr>";
if(proname.length>17)
cartcont=cartcont+"<tr width=100% valign='top'><td valign='top'><span class='popupdisplayfont'><i>"+proname.substring(0,15)+"..</i></span></td></tr>";
else
cartcont=cartcont+"<tr width=100% valign='top'><td valign='top'><span class='popupdisplayfont'><i>"+proname.substring(0,17)+"</i></span></td></tr>";
cartcont=cartcont+"<tr width=100% valign='top'><td valign='top'><span class='popupdisplayfont'><i>"+sizeme+"</i></span></td></tr>";
cartcont=cartcont+"<tr width=100% valign='bottom'><td valign='bottom'><span class='popupdisplayfont'>$"+parseFloat(cartprice).toFixed(0)+"</span><br><br>";
cartcont=cartcont+"</td></tr></table></td></tr>";
cartcont=cartcont+"<tr width=90% bgcolor=#ffffff><td width=70% height=1px colspan=2></td></tr>"
//eany
cartcont=cartcont+"<tr width=90% ><td width=70% height=4px><span class='carttext'><a href='"+contextpath+"view-bag.do'><b><span class='popupdisplayfont'><u>View Bag</u></span></b></a></span></td><td height=4px width=30%><a href='"+contextpath+"view-bag.do'><img src="+contextpath+"images/general_images/checkout_on.gif></a></td></tr>"
cartcont=cartcont+"</table></td></tr></table>";
cartviewobject.innerHTML=cartcont;
flag=1;

//           displaycart() function is define into home_attech.js   (-!-)


var chkoutUD=document.getElementById('cngimgID');
var string_for_chkout="<img src='"+contextpath+"images/general_images/checkout_on.gif' id='chkchang' style='cursor:pointer;cursor:hand' onclick='checkoutme()'>";
chkoutUD.innerHTML=string_for_chkout;


displaycart();
}

function morehidetime_atb()
{
meinterval=setInterval("morehide_atb()",1000);
}

function morehide_atb()
{

//lock.src=contextpath+"image/bagbangbus_off.gif";
loadCart(itemimage,itemname,sizename);
document.getElementById('addtobag').src=contextpath+"images/image/add_to_bag.gif";

setTimeout("morehide_pop()", 4000)
clearInterval(meinterval);
}

function morehidetime_cross()
{
meinterval=setInterval("morehide_cross()",1000);
}

function morehide_cross()
{
//  Himu
//lock.src=contextpath+"image/bagbangbus_off.gif";
loadCart(itemimage,itemname,itemsize);
//clearCart('cart');
//clearInterval(meinterval);
document.getElementById('addtobag').src=contextpath+"images/image/add_to_bag.gif";
setTimeout("morehide_pop()", 3000)
clearInterval(meinterval);
asynchGet();
changecolor(0);



//document.addPVToCartForm.submit();
//====  ajax call for 
}

function morehidetime()
{
meinterval=setInterval("morehide()",1000);
}

function morehide()
{lock.src=contextpath+"images/general_images/lock.gif";
loadCart(itemimage,itemname,sizename);
//clearCart('cart');
//clearInterval(meinterval);
document.getElementById('addtobag').src=contextpath+"image/add_to_bag.gif";
setTimeout("morehide_pop()", 2000)
clearInterval(meinterval);
}

function morehide_pop()
{clearCart('cart');
var getTblId=document.getElementById('mainTblID');
getTblId.onmouseover=morehide_pop;
}

function clear_actionpop()
{}

function control_fun()
{
var getTblId=document.getElementById('mainTblID');
getTblId.onmouseover=morehide_pop;
}


//=======================  AJAX  CALL FOR ADD TO BAG  =======================-=============//
var portletReq;
function asynchGet(){

var updateURL=contextpath+"add-to-cart.do?cartItem[0].uidPk="+document.getElementById('uidpk').value+"&cartType=''&cartItem[0].quantity="+document.view_bag_popup.pro_quantity.value; 
 	
    if (window.XMLHttpRequest) {
        portletReq = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        portletReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //alert(updateURL);
    portletReq.onreadystatechange = processReqChange;
    portletReq.open("GET", updateURL, true);
    portletReq.send(null);

}
function processReqChange() {
    if (portletReq.readyState == 4) {
        if (portletReq.status == 200) {
      //  alert("reponse is "+portletReq.responseText);
        }
    }
   }
//=========================  [END]  ===================================================//

//====================  [ ADD TO BAG  from wishlist page ]  ============================//
/***************************************************************************************/
//this function is calling from shopingcart.vm page (when we click on ADD TO BAG image 
/***************************************************************************************/
var wishlistID;

function addwishlistdata(addbut,variprice,varinamemy,imgvari,variid,wishid)
{
wishlistID=wishid;
var itemid=variid;
var itemname=varinamemy;
var itemcolor=varinamemy;
var itemsize="===";
var itemprice=variprice;
var itemimage=contextpath+"store/assets/"+imgvari;
wishlistid_for_bag=wishid;
variid_for_bag=itemid;
lock.src=contextpath+"images/general_images/lock.gif";
addbut.src=contextpath+"image/adding.gif";
var data=getCookie("cart");
var cartcontent;
var xmlobject;
if(navigator.appName=="Netscape" || navigator.appName=="Opera")
{
xmlobject=document.implementation.createDocument('','',null);
var xmlp=new DOMParser();
//xmlobject.load("Tests.xml","text/xml");
xmlobject=xmlp.parseFromString(data,"text/xml");
}
else{
xmlobject = new ActiveXObject("Microsoft.XMLDOM");
xmlobject.async=false;
xmlobject.loadXML(data);
}


var fi=xmlobject.getElementsByTagName("itemid");
var fi1=xmlobject.getElementsByTagName("itemname");
var fi2=xmlobject.getElementsByTagName("itemcolor");
var fi3=xmlobject.getElementsByTagName("itemsize");
var fi4=xmlobject.getElementsByTagName("itemprice");
cartcontent="<cart>";
var ii;
for(ii=0;ii<fi.length;++ii)
{
cartcontent=cartcontent+"<item>";
cartcontent=cartcontent+"<itemid>"+fi[ii].firstChild.nodeValue+"</itemid>";
cartcontent=cartcontent+"<itemname>"+fi1[ii].firstChild.nodeValue+"</itemname>";

cartcontent=cartcontent+"<itemsize></itemsize>";
cartcontent=cartcontent+"<itemprice>"+fi4[ii].firstChild.nodeValue+"</itemprice>";
cartcontent=cartcontent+"</item>";
}
cartcontent=cartcontent+"<item>";
cartcontent=cartcontent+"<itemid>"+itemid+"</itemid>";
cartcontent=cartcontent+"<itemname>"+itemname+"</itemname>";
cartcontent=cartcontent+"<itemsize></itemsize>";
cartcontent=cartcontent+"<itemprice>"+itemprice+"</itemprice>";
cartcontent=cartcontent+"</item>";
cartcontent=cartcontent+"</cart>";
setCookie("cart",cartcontent);
loadCart_wishlist(itemimage,itemname,itemprice);
addbut.src=contextpath+"image/add_to_bag.gif";
document.location=contextpath+"move-saved-cart-item.do?cikey="+wishlistID+"&cartType=''";
}

function loadCart_wishlist(itemimg,proname,itemprice)
{	
var cartviewobject=document.getElementById("cartslide");
cartviewobject.style.display="block";
var cartcont="<table id='cartdisplay' width=237px bgcolor=#B4B4B4><tr width=100% height=100%><td width=100% height=100% valign=bottom><table  width=98% height=95% valign=center align=center bgcolor=#ffffff>";
carttop=document.getElementById("cart");
carttop.className="minicartdisp";

carttop2=document.getElementById("cart2");
//carttop2.className="minicartdisp";

carttop3=document.getElementById("cart3");
carttop3.className="minicartdisp";

cartimage=itemimg;
var ii;
var pric=0;

cartcont=cartcont+"<tr width=100% ><td colspan=2 height=6px></td></tr>"
cartcont=cartcont+"<tr width=100%><td  align='center' colspan=2><b>THIS ITEM HAS BEEN</b></td></tr>";
cartcont=cartcont+"<tr width=100%><td  align='center' colspan=2><b>ADDED TO YOUR CART</b></td></tr>";
cartcont=cartcont+"<tr width=90% ><td colspan=2 height=6px></td></tr>"
cartcont=cartcont+"<tr width=90% bgcolor=#999999 ><td colspan=2 height=1px></td></tr>";
cartcont=cartcont+"<tr width=90%><td width=50%><img src="+cartimage+" width='120' height='100' border=0px></td><td width=50%><table  width=100% height=100%  align=center bgcolor=white><tr width=100% valign='top'><td valign='top'>";
cartcont=cartcont+"<span class='carttext'><b>"+proname+"</b></span></td></tr>";
cartcont=cartcont+"<tr width=100% valign='top'><td valign='top'><span class='carttext3'><i></i></span></td></tr>";
cartcont=cartcont+"<tr width=100% valign='top'><td valign='top'><span class='carttext3'><i></i></span></td></tr>";
cartcont=cartcont+"<tr width=100% valign='bottom' height=50><td valign='bottom'><span class='carttext3'></span>";
cartcont=cartcont+"<tr width=100% valign='bottom'><td valign='bottom'><span class='carttext3'>$"+parseFloat(itemprice).toFixed(0)+"</span>";
cartcont=cartcont+"</td></tr></table></td></tr>";
cartcont=cartcont+"<tr width=90% bgcolor=#999999><td colspan=2 height=1px></td></tr>";
cartcont=cartcont+"<tr width=90% ><td width=70% height=4px><span class='carttext'><u>View Bag</u></span></td><td height=4px width=30%><img src="+contextpath+"image/checkout_on.gif></td></tr>"
cartcont=cartcont+"</table></td></tr></table>";
cartviewobject.innerHTML=cartcont;
flag=1;
displaycart();
}

/***************************************************************************************/
//=========================  [END]  ===================================================//
/***************************************************************************************/

//====================  [ ADD TO WISHLIST LINK  ]  ============================//
/***************************************************************************************/
//this function is calling from productdispaly page (when we click on ADD TO WISHLIST LINK 
/***************************************************************************************/

function mywishlist(select)
{
if(select.selectedIndex==0)
{
select.options[select.selectedIndex].value
alert("Please select a size");
document.getElementById('addtobag').src=contextpath+"image/add_to_bag.gif";
}
else
{
wishlistid=document.getElementById('uidpk').value;
document.addPVToCartForm.action=contextpath+"ad-cart.do";
document.getElementById('ctype').value="savedShoppingCart";
document.addPVToCartForm.submit();
}
}

/***************************************************************************************/
//=========================  [END]  ===================================================//
/***************************************************************************************/

//=====================  [ Complete The Look Section ]  ==============================//
/***************************************************************************************/
/***************************************************************************************/
function adddata_for_crossselling(select,select_name,selectQuantity,itemno)
{
//alert("himu");
if(select.selectedIndex==0)
{ alert("Please select a size"); }else{
noofQuantity=selectQuantity.options[selectQuantity.selectedIndex].value;
document.view_bag_popup.pro_quantity.value=noofQuantity;
}
var getTblId=document.getElementById('mainTblID');
getTblId.onmouseover=clear_actionpop;
var selectsizename=document.getElementById("selectsizename");
itemid=document.view_bag_popup.itemid.value;
itemname=document.view_bag_popup.itemname.value;
itemcolor=document.view_bag_popup.itemcolor.value;
itemsize=document.view_bag_popup.itemsize.value;
itemprice=document.view_bag_popup.itemprice.value;
itemimage=document.view_bag_popup.itemimage.value;
pro_quantity=document.view_bag_popup.pro_quantity.value;
pro_disURL=document.view_bag_popup.prodisplay_url.value;
//alert(pro_disURL+" now==>");
setCookie("variNO",document.view_bag_popup.prodvarino.value);

product_name_forpopup=document.view_bag_popup.productname.value;



var imgpath=contextpath+"store/assets/";
itemimage=imgpath+document.view_bag_popup.itemimage.value;
var data=getCookie("cart");
var cartcontent;
var xmlobject;
if(navigator.appName=="Netscape" || navigator.appName=="Opera")
{
xmlobject=document.implementation.createDocument('','',null);
var xmlp=new DOMParser();
//xmlobject.load("Tests.xml","text/xml");
xmlobject=xmlp.parseFromString(data,"text/xml");
}
else{
xmlobject = new ActiveXObject("Microsoft.XMLDOM");
xmlobject.async=false;
xmlobject.loadXML(data);
}
var fi=xmlobject.getElementsByTagName("itemid");
var fi1=xmlobject.getElementsByTagName("itemname");
var fi2=xmlobject.getElementsByTagName("itemcolor");
//var fi3=xmlobject.getElementsByTagName("itemsize");
var fi4=xmlobject.getElementsByTagName("itemprice");
var fi5=xmlobject.getElementsByTagName("quantity");
var fi6=xmlobject.getElementsByTagName("proURL");
var fi7=xmlobject.getElementsByTagName("proNO");

cartcontent="<cart>";
var ii;
//alert(data);

if(select.selectedIndex==0)
{lock.src=contextpath+"images/general_images/af_shop_icon.gif";
alert("Please select a size");
}
else
{

for(ii=0;ii<fi.length;++ii)
{
cartcontent=cartcontent+"<item>";
cartcontent=cartcontent+"<itemid>"+fi[ii].firstChild.nodeValue+"</itemid>";
cartcontent=cartcontent+"<itemname>"+fi1[ii].firstChild.nodeValue+"</itemname>";
//cartcontent=cartcontent+"<itemsize>"+fi3[ii].firstChild.nodeValue+"</itemsize>";
cartcontent=cartcontent+"<itemprice>"+fi4[ii].firstChild.nodeValue+"</itemprice>";
cartcontent=cartcontent+"<quantity>"+fi5[ii].firstChild.nodeValue+"</quantity>";
cartcontent=cartcontent+"<proURL>"+fi6[ii].firstChild.nodeValue+"</proURL>";
cartcontent=cartcontent+"<proNO>"+fi7[ii].firstChild.nodeValue+"</proNO>";
cartcontent=cartcontent+"</item>";
}
cartcontent=cartcontent+"<item>";
cartcontent=cartcontent+"<itemid>"+itemid+"</itemid>";
cartcontent=cartcontent+"<itemname>"+document.view_bag_popup.productname.value+"</itemname>";
//cartcontent=cartcontent+"<itemsize>"+selectsizename.options[select.selectedIndex].value+"</itemsize>";
cartcontent=cartcontent+"<itemprice>"+itemprice+"</itemprice>";
cartcontent=cartcontent+"<quantity>"+pro_quantity+"</quantity>";
cartcontent=cartcontent+"<proURL>"+pro_disURL+"</proURL>";
cartcontent=cartcontent+"<proNO>"+itemno+"</proNO>";
cartcontent=cartcontent+"</item>";
cartcontent=cartcontent+"</cart>";
//            this function set XML String into cookie       (-!-)                        
//            setCookie() function is define into cookie.js  (-!-)                       
setCookie("cart",cartcontent);
//alert(document.getElementById('uidpk').value);
//document.addPVToCartForm.action="../add-to-cart.do";
datgo(0);
morehidetime_cross();

document.getElementById('selectquantity_up_cross').visibility="visible";

}
}

/***************************************************************************************/
//=========================  [END]  ===================================================//
/***************************************************************************************/

//=====================  [ Complete The Look Section ]  ==============================//
/***************************************************************************************/
/***************************************************************************************/
function adddata_for_editlink(selectQuantity)
{
itemid=document.view_bag_popup.itemid.value;
itemname=document.view_bag_popup.itemname.value;
//alert(itemname);
itemcolor=document.view_bag_popup.itemcolor.value;
itemsize=document.view_bag_popup.itemsize.value;
itemprice=document.view_bag_popup.itemprice.value;
itemimage=document.view_bag_popup.itemimage.value;
pro_disURL=document.view_bag_popup.prodisplay_url.value;
old_bagid=document.view_bag_popup.oldID.value;
var itemno="1";
noofQuantity=selectQuantity.options[selectQuantity.selectedIndex].value;

update_xmldata(old_bagid);
var data=getCookie("cart");

var cartcontent;
var xmlobject;
if(navigator.appName=="Netscape")
{
xmlobject=document.implementation.createDocument('','',null);
var xmlp=new DOMParser();
//xmlobject.load("Tests.xml","text/xml");
xmlobject=xmlp.parseFromString(data,"text/xml");
}
else{
xmlobject = new ActiveXObject("Microsoft.XMLDOM");
xmlobject.async=false;
xmlobject.loadXML(data);
}



var fi=xmlobject.getElementsByTagName("itemid");
var fi1=xmlobject.getElementsByTagName("itemname");
//var fi3=xmlobject.getElementsByTagName("itemsize");
var fi4=xmlobject.getElementsByTagName("itemprice");
var fi5=xmlobject.getElementsByTagName("quantity");
var fi6=xmlobject.getElementsByTagName("proURL");
var fi7=xmlobject.getElementsByTagName("proNO");
cartcontent="<cart>";
var ii;
//alert(fi.length+" "+fi3.length+" "+data);

for(ii=0;ii<fi.length;++ii)
{
cartcontent=cartcontent+"<item>";
cartcontent=cartcontent+"<itemid>"+fi[ii].firstChild.nodeValue+"</itemid>";
cartcontent=cartcontent+"<itemname>"+fi1[ii].firstChild.nodeValue+"</itemname>";
//cartcontent=cartcontent+"<itemsize>"+"</itemsize>";
cartcontent=cartcontent+"<itemprice>"+fi4[ii].firstChild.nodeValue+"</itemprice>";
cartcontent=cartcontent+"<quantity>"+fi5[ii].firstChild.nodeValue+"</quantity>";
cartcontent=cartcontent+"<proURL>"+fi6[ii].firstChild.nodeValue+"</proURL>";
cartcontent=cartcontent+"<proNO>"+fi7[ii].firstChild.nodeValue+"</proNO>";
cartcontent=cartcontent+"</item>";
}

cartcontent=cartcontent+"<item>";
cartcontent=cartcontent+"<itemid>"+itemid+"</itemid>";
cartcontent=cartcontent+"<itemname>"+itemname+"</itemname>";
//cartcontent=cartcontent+"<itemsize>"+"</itemsize>";
cartcontent=cartcontent+"<itemprice>"+itemprice+"</itemprice>";
cartcontent=cartcontent+"<quantity>"+noofQuantity+"</quantity>";
cartcontent=cartcontent+"<proURL>"+pro_disURL+"</proURL>";
cartcontent=cartcontent+"<proNO>"+itemno+"</proNO>";
cartcontent=cartcontent+"</item>";
cartcontent=cartcontent+"</cart>";
//alert(cartcontent);
setCookie("cart",cartcontent);
}

//=========== [ Update Cookie Data when we click on remove link ( MY BAG Page) ] ======//
/***************************************************************************************/
/***************************************************************************************/

var checkformore=0;
function update_xmldata(proid)
{
checkformore=0;
var data=getCookie("cart");
var cartcontent;
var xmlobject;
if(navigator.appName=="Netscape" || navigator.appName=="Opera")
{
xmlobject=document.implementation.createDocument('','',null);
var xmlp=new DOMParser();
//xmlobject.load("Tests.xml","text/xml");
xmlobject=xmlp.parseFromString(data,"text/xml");
}
else{
xmlobject = new ActiveXObject("Microsoft.XMLDOM");
xmlobject.async=false;
xmlobject.loadXML(data);
}



var fi=xmlobject.getElementsByTagName("itemid");
var fi1=xmlobject.getElementsByTagName("itemname");
var fi2=xmlobject.getElementsByTagName("itemcolor");
//var fi3=xmlobject.getElementsByTagName("itemsize");
var fi4=xmlobject.getElementsByTagName("itemprice");
var fi5=xmlobject.getElementsByTagName("quantity");
var fi6=xmlobject.getElementsByTagName("proURL");
var fi7=xmlobject.getElementsByTagName("proNO");

cartcontent="<cart>";
var ii;
for(ii=0;ii<fi.length;++ii)
{
if(proid==fi[ii].firstChild.nodeValue && checkformore==0)
{
checkformore=1;
}
else{
cartcontent=cartcontent+"<item>";
cartcontent=cartcontent+"<itemid>"+fi[ii].firstChild.nodeValue+"</itemid>";
cartcontent=cartcontent+"<itemname>"+fi1[ii].firstChild.nodeValue+"</itemname>";
//cartcontent=cartcontent+"<itemsize>"+"</itemsize>";
cartcontent=cartcontent+"<itemprice>"+fi4[ii].firstChild.nodeValue+"</itemprice>";
cartcontent=cartcontent+"<quantity>"+fi5[ii].firstChild.nodeValue+"</quantity>";
cartcontent=cartcontent+"<proURL>"+fi6[ii].firstChild.nodeValue+"</proURL>";
cartcontent=cartcontent+"<proNO>"+fi7[ii].firstChild.nodeValue+"</proNO>";
cartcontent=cartcontent+"</item>";
}

}
cartcontent=cartcontent+"</cart>";
//alert(cartcontent);
setCookie("cart",cartcontent);
}



/***************************************************************************************/
//=========================  [END]  ===================================================//
/***************************************************************************************/







//=========== [ Remove Cookie Data when we click on remove link ( MY BAG Page) ] ======//
/***************************************************************************************/
/***************************************************************************************/

var checkformore=0;
function remove_xmldata(sessionkey,proid,quantity_fromviewbag )
{


checkformore=0;
var data=getCookie("cart");
var cartcontent;
var xmlobject;
if(navigator.appName=="Netscape" || navigator.appName=="Opera")
{
xmlobject=document.implementation.createDocument('','',null);
var xmlp=new DOMParser();
//xmlobject.load("Tests.xml","text/xml");
xmlobject=xmlp.parseFromString(data,"text/xml");
}
else{
xmlobject = new ActiveXObject("Microsoft.XMLDOM");
xmlobject.async=false;
xmlobject.loadXML(data);
}

var fi=xmlobject.getElementsByTagName("itemid");
var fi1=xmlobject.getElementsByTagName("itemname");
var fi2=xmlobject.getElementsByTagName("itemcolor");
//var fi3=xmlobject.getElementsByTagName("itemsize");
var fi4=xmlobject.getElementsByTagName("itemprice");
var fi5=xmlobject.getElementsByTagName("quantity");
var fi6=xmlobject.getElementsByTagName("proURL");
var fi7=xmlobject.getElementsByTagName("proNO");

cartcontent="<cart>";
var ii;
for(ii=0;ii<fi.length;++ii)
{
if(proid==fi[ii].firstChild.nodeValue && checkformore==0 && quantity_fromviewbag==fi5[ii].firstChild.nodeValue)
{
checkformore=1;
}
else{
cartcontent=cartcontent+"<item>";
cartcontent=cartcontent+"<itemid>"+fi[ii].firstChild.nodeValue+"</itemid>";
cartcontent=cartcontent+"<itemname>"+fi1[ii].firstChild.nodeValue+"</itemname>";
//cartcontent=cartcontent+"<itemsize>"+"</itemsize>";
cartcontent=cartcontent+"<itemprice>"+fi4[ii].firstChild.nodeValue+"</itemprice>";
cartcontent=cartcontent+"<quantity>"+fi5[ii].firstChild.nodeValue+"</quantity>";
cartcontent=cartcontent+"<proURL>"+fi6[ii].firstChild.nodeValue+"</proURL>";
cartcontent=cartcontent+"<proNO>"+fi7[ii].firstChild.nodeValue+"</proNO>";
cartcontent=cartcontent+"</item>";
}

}
cartcontent=cartcontent+"</cart>";
setCookie("cart",cartcontent);

var frmID=document.getElementById('remove_frm');
frmID.cikey.value=sessionkey;

frmID.submit(sessionkey);
}

/***************************************************************************************/
//=========================  [END]  ===================================================//
/***************************************************************************************/


//=======================  AJAX ============================

var portletReq;
function asynchGet_remove(sessionkey){
var updateURL=contextpath+"/removes-cart-item.do?cikey="+sessionkey;
    if (window.XMLHttpRequest) {
        portletReq = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        portletReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //alert(updateURL);
    portletReq.onreadystatechange = processReqChange_remove;
    portletReq.open("GET", updateURL, true);
    portletReq.send(null);
}
function processReqChange_remove() {
    if (portletReq.readyState == 4) {
        if (portletReq.status == 200) {
          // process response
          // alert("reponse is "+portletReq.responseText);
        }
    }
}
//=====================  end =================================
//=========================  fro wishlist ==========================
