var xmlHttp
	
	function addtoCart(item_id,item_type,qty,opts,rads)
	{ 		
	
	  var l  ;
   var sel_con = "";
	  var u ;
   var rad_con = "";
		 
	  if(item_type == 'P')
	  {
    		 if(opts != "") 
    		 {
    		    var names = opts.split("~") ;
    		    var lng   = names.length ;
    		 
       		 for(l=0;l<lng;l++)
       		 {
       		     var value = document.getElementById("aaa"+names[l]).value ;
       		     if(value!="")
       		     {
       		       if(sel_con!="")
       		       {  sel_con += ":"   }
       		       
       		        sel_con   += "aaa"+names[l]+">"+value ;
       		     }		     
       		 }
    		 }
    		 
    		 if(rads != "")
    		 {
    		   var rnames = rads.split("~");
    		   var rlng   = rnames.length;
    		 
      		 for(u=0;u<rlng;u++)
      		 {
      		     var ropts  = rnames[u].split(":");
      		     var roname = ropts[0] ;
      		     var rolng  = ropts[1] ;
      		     var x ;
      		     var flag = 0 ;
      		     for(x=1;x<=rolng;x++)
      		     {	    
      		        if(document.getElementById("aaa"+roname+x).checked==true)
      		        {
      		            var rvalue = document.getElementById("aaa"+roname+x).value ;
      		            
      		            if(rad_con!="")
      		            {  rad_con += ":"   }
      		            
      		            rad_con   += "aaa"+roname+">"+rvalue ;
      		        }
      		        
      		     }		         
      		 }
    		 }
	  }
	  	
		 var url   ="cart_ajax.php?item_id=" + item_id + "&item_type=" + item_type+ "&quantity=" + qty +"&select="+ sel_con +"&radio="+rad_con ;		
		 xmlHttp=GetXmlHttpObject(stateChanged)
			xmlHttp.open("GET", url , true)
			xmlHttp.send(null)		
	} 
	
	function stateChanged() 
	{ 
//		alert("aaa responseText="+xmlHttp.responseText);
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			if(xmlHttp.responseText == 1)
			{								
				 window.location = "cart.php";
			}
			else if(xmlHttp.responseText == 2)
			{
			  alert("Quantity Not Available");
			}
			else
			{	
			 var err="Unable to add to cart";
				alert(err);
			}
					
		} 
	}

	
	function removeFromCart(cart_id)
	{ 
	  var url="cart_ajax.php?cart_id=" + cart_id;		
			xmlHttp=GetXmlHttpObject(stateChangedRemove)
			xmlHttp.open("GET", url , true)
			xmlHttp.send(null)
		
	} 
	
	function stateChangedRemove() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			if(xmlHttp.responseText == 1)
			{								
				window.location = "cart.php";
			}
			else
			{	
			 var err="Unable to delete from cart";
				alert(err);
			}
					
		} 
	}
	
	function GetXmlHttpObject(handler)
	{ 
		var objXmlHttp=null
	
		if (navigator.userAgent.indexOf("Opera")>=0)
		{
			alert("This example doesn't work in Opera") 
			return 
		}
		if (navigator.userAgent.indexOf("MSIE")>=0)
		{ 
			var strName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
			{
				strName="Microsoft.XMLHTTP"
			} 
			try
			{ 
				objXmlHttp=new ActiveXObject(strName)
				objXmlHttp.onreadystatechange=handler 
				return objXmlHttp
			} 
			catch(e)
			{ 
				alert("Error. Scripting for ActiveX might be disabled") 
				return 
			} 
		} 
			if (navigator.userAgent.indexOf("Mozilla")>=0)
			{
				objXmlHttp=new XMLHttpRequest()
				objXmlHttp.onload=handler
				objXmlHttp.onerror=handler 
				return objXmlHttp
			}
	}
	
	

function validatefields()
{
		
	 if(document.customer.username_display.value=="")
  {
       var field_name= new Array("first_name","last_name","email");
       var display_name= new Array("First Name","Last Name","Email");
       var count_array=3;
	      if(check_fields('customer',field_name,display_name,count_array))
	    		{ 
	    		 
	    		 /*if(document.customer.cpassword.value!=document.customer.password.value)
	  		   {
	  		     alert("Password Mismatch");
	  		     document.customer.cpassword.focus();
	  		     return false;		  
	  		   }    */          
	    		}
	    		else
	    		{ 
	    			 return false;
	    		}      	
   }
	 
	
	 
	 if(chkCustomer())
	 { 
	 
   	 if (document.customer.cardnumber.value.length == 0 ) {
     alert("Please enter a Credit Card Number");
     document.customer.cardnumber.focus();
     return false;
     }
     if (isNaN(document.customer.cardnumber.value)) {
     alert("Please enter a Valid Credit Card Number");
     document.customer.cardnumber.value='';
     document.customer.cardnumber.focus();
     return false;
     }
     
     if (document.customer.cardnumber.value.length <13||document.customer.cardnumber.value.length >17) {
     alert("Please enter a Valid Credit Card Number");
     document.customer.cardnumber.value='';
     document.customer.cardnumber.focus();
     return false;
     }
     
     if (document.customer.cardexpiry_month.value == "" ) {
     alert("Please select Card Expiry Month");
     return false;
     }
     if (document.customer.cardexpiry_year.value == "" ) {
     alert("Please select Card Expiry Year");
     return false;
     }
     
     

	 var field_name= new Array("bfirstname","blastname","baddress1","bcity","bzip","bcountry","bphone");
  var display_name= new Array("Billing First Name","Billing Last Name","Billing Address1","Billing City","Billing Zip","Billing Country","Billing Phone");
  var count_array=7;
  
  if(check_fields('customer',field_name,display_name,count_array))
		{
//			  if(document.customer.bprovince.value=='')
//		   {
//		     alert("State/Province Is A Required Field !!");
//		     return false;
//		   }
		   
					
					var phone_pointer=document.customer.bphone.value;
					phone_pointer=phone_pointer.replace("(","");
					phone_pointer=phone_pointer.replace(")","");
					phone_pointer=phone_pointer.replace("+","");
					while(phone_pointer.indexOf(" ")>0)
					{
					phone_pointer=phone_pointer.replace(" ","");
					}
					while(phone_pointer.indexOf("-")>0)
					{
					phone_pointer=phone_pointer.replace("-","");
					}
					document.customer.bphone.value=phone_pointer;
											
//				 if(validateInteger('customer','bphone'))
//  		 {
//  			
//  		 }
//  		 else
//  		 { 
//  			   return false;
//  		 }
  		 /*if(!checkEmail(eval("document.customer.email.value")))
				 {
					  eval("document.customer.email.focus()");
					  return false;
				 }
				 if(!checkEmail(eval("document.customer.emailagain.value")))
				 {
					  eval("document.customer.emailagain.focus()");
					  return false;
				 }
				 if(document.customer.email.value!=document.customer.emailagain.value)
				 {
				 	 alert("Email mismatch")
				 	 eval("document.customer.emailagain.focus()");
					  return false;
				 }*/
				 if(document.customer.shipflag.value>0)
				 {
			  		 
			  		 if(document.customer.shipping.checked==false)
			  		 {
			  		   var field_name= new Array("sfirstname","slastname","saddress1","scity","szip","scountry","sphone");
					     var display_name= new Array("Shipping First Name","Shipping Last Name","Shipping Address1","Shipping City","Shipping Zip","Shipping Country","Shipping Phone");
			     	 var count_array=7;
			     	 if(check_fields('customer',field_name,display_name,count_array))
			     		{
//			     		    if(document.customer.sstate.value=='')
//			      		   {
//			      		     alert("State/Province Is A Required Field !!");
//			      		     return false;
//			      		   }
														var phone_pointer=document.customer.sphone.value;
														phone_pointer=phone_pointer.replace("(","");
														phone_pointer=phone_pointer.replace(")","");
														while(phone_pointer.indexOf(" ")>0)
														{
														phone_pointer=phone_pointer.replace(" ","");
														}
														while(phone_pointer.indexOf("-")>0)
														{
														phone_pointer=phone_pointer.replace("-","");
														}
														document.customer.sphone.value=phone_pointer;
														
			     		    if(validatephone('customer','sphone'))
			         		{
			         			
			         		}
			         		else
			         		{ 
			         			return false;
			         		}
			     		}
			     		else
			     		{
			     		    return false;
			     		}
			  		 }
			  		 else
			  		 {
			  		    chkinform();
			        document.customer.sfirstname.disabled=false;
			        document.customer.slastname.disabled=false;
			        document.customer.saddress1.disabled=false;
			        document.customer.saddress2.disabled=false;
			        document.customer.scity.disabled=false;
			        document.customer.szip.disabled=false;
			        document.customer.scountry.disabled=false;
			        document.customer.sstate.disabled=false;
			        document.customer.sphone.disabled=false;
			  		 } 
				 }
				 /*if(document.customer.username_display.value=="")
     {			
        checkCustomer(document.customer.username.value,document.customer.email.value);	 	//ajax checking to avoid duplicate entry	      	
     }
     else     
     {*/
				 var fields = $(".passengerinfo");
					var len = fields.length;
					for(i = 0; i < len; i++){
						if(fields[i].value=='') {
							var field_name = fields[i].name;
							var field_type = '';
							if(field_name.indexOf('sname')==-1){
								field_type = 'First Name';
							}else{
								field_type = 'Last Name';
							}
							alert("Please enter passenger " + field_type);
						    fields[i].focus();
						    return false;
						}
					}
       document.customer.submit();
     //} 		 
     
		}
		else
		{ 
			return false;
		}
	 }
	 
	 if(document.customer.isgift.checked == true)
	 {		
		 if (document.customer.rec_firstname.value.length == 0 ) {
		     alert("Please enter a Recipient First Name");
		     document.customer.rec_firstname.focus();
		     return false;
		     }
		 if (document.customer.rec_lastname.value.length == 0 ) {
		     alert("Please enter a Recipient Last Name");
		     document.customer.rec_lastname.focus();
		     return false;
		     }
		 
		 if(document.customer.deliverdpe.checked == true)
		 {
			 if (document.customer.fedexname.value.length == 0 ) {
			     alert("Please enter a Fed-ex Name");
			     document.customer.fedexname.focus();
			     return false;
			     }
			 if (document.customer.fedexaddress.value.length == 0 ) {
			     alert("Please enter a Fed-ex Address");
			     document.customer.fedexaddress.focus();
			     return false;
			     }
			 if (document.customer.fedexcity.value.length == 0 ) {
			     alert("Please enter a Fed-ex City");
			     document.customer.fedexcity.focus();
			     return false;
			     }
			 if (document.customer.fedexzip.value.length == 0 ) {
			     alert("Please enter a Fed-ex Zip / Postal Code");
			     document.customer.fedexzip.focus();
			     return false;
			     }
			 if (document.customer.fedexcountry.value.length == 0 ) {
			     alert("Please enter a Fed-ex Country");
			     document.customer.fedexcountry.focus();
			     return false;
			     }
			 if (document.customer.fedexstate.value.length == 0 ) {
			     alert("Please enter a Fed-ex State / Province");
			     document.customer.fedexstate.focus();
			     return false;
			     }
		 }
	 }
	 
	 
	 
	 
}




function chkinform()
{
if(document.customer.shipping.checked==true)
   {
    
    document.customer.sfirstname.value=document.customer.bfirstname.value
    document.customer.sfirstname.disabled=true;
    document.customer.slastname.value=document.customer.blastname.value
    document.customer.slastname.disabled=true;
    document.customer.saddress1.value=document.customer.baddress1.value
    document.customer.saddress1.disabled=true;
    document.customer.saddress2.value=document.customer.baddress2.value
    document.customer.saddress2.disabled=true;
    document.customer.scity.value=document.customer.bcity.value
    document.customer.scity.disabled=true;
    document.customer.szip.value=document.customer.bzip.value
    document.customer.szip.disabled=true;
    document.customer.scountry.value=document.customer.bcountry.value
    document.customer.scountry.disabled=true;       
    document.customer.sstate.value=document.customer.bstate.value
    document.customer.sstate.disabled=true;
    document.customer.sphone.value=document.customer.bphone.value
    document.customer.sphone.disabled=true;
   }
   else
   {
    document.customer.sfirstname.value='';
    document.customer.sfirstname.disabled=false;
    document.customer.slastname.value='';
    document.customer.slastname.disabled=false;
    document.customer.saddress1.value='';
    document.customer.saddress1.disabled=false;
    document.customer.saddress2.value='';
    document.customer.saddress2.disabled=false;
    document.customer.scity.value='';
    document.customer.scity.disabled=false;
    document.customer.szip.value='';
    document.customer.szip.disabled=false;
    document.customer.scountry.value='';
    document.customer.scountry.disabled=false;   
    document.customer.sstate.value=''
    document.customer.sstate.disabled=false;
    document.customer.sphone.value='';
    document.customer.sphone.disabled=false;
   }
}


function validatephone(form,myField) 
{
  var objfield ="document."+form+"."+myField; 
  var objvalue ="document."+form+"."+myField+".value"; 
  objfield = eval(objfield);
  objvalue = eval(objvalue);
  
  if (!isInteger(objvalue)) 
  {    
    if(objfield.disabled==true)
    {
     objfield.disabled=false;
     objfield.focus();
    }  
    alert('Invalid Integer Value Entered For Shipping Phone\n');
      
    return false;
  }

  if (window.RegExp && !integer.test(eval("document."+form+"."+myField+".value"))) {
    
    alert('Invalid Integer Value Entered For Shipping Phone\n');    
    return false
  }
	

  return true;
}

function reviewCart()
{
  window.location="cart.php";
}

function submitLogin()
{
 loginCheck();
 return false;
}

function loginCheck()
{ 	
 	  
  	if(trimSpaces(document.urlogin_form.uid.value)=="")
	 	{
   	 		alert("User Name Is A Required Field");
   	 		document.urlogin_form.uid.focus();
	 	}
	 	else
	 	{ 
	 	  	var url="cart_ajax.php?uname=" + document.urlogin_form.uid.value +"&pwd="+ document.urlogin_form.pwd.value; 	
	   		xmlHttp=GetXmlHttpObject(chkLogin)
	   		xmlHttp.open("GET", url , true)
	   		xmlHttp.send(null)
	 	}		
} 

function chkLogin() 
	{ 
   		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   		{ 
      		if(xmlHttp.responseText == 2)
     			{								
       				alert('Logged In Successfully')
       				window.location.reload();
       				window.location ="purchase.php";  	
     			}
     			else if(xmlHttp.responseText == 1)
     			{
     			   alert('Logged In Successfully')
       				window.location.reload(); 	     			 
       		 	window.location ="purchase.php"; 	     			 
     			}
     			else if(xmlHttp.responseText == 4)
     			{
     			   alert('Login Session Already Exists \n Logout And Try Again');       				 	     			 
     			}
     			else
     			{
     			   alert("Invalid Username or Password");
     			}			
   		} 
	}

	
	function checkCustomer(uname,email)
	{ 
	
		var url="cart_ajax.php?username=" + uname +"&email="+ email
		xmlHttp=GetXmlHttpObject(stateChangedCustomer)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
	} 
	
	
	
	function stateChangedCustomer() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 

			if(xmlHttp.responseText == 1)
			{
								
				alert('Customer Username Already Exists')
					
			}
			else if(xmlHttp.responseText == 2)
			{
				alert('Customer Email Already Exists')
			}
			else 
			{
				
				document.customer.submit()
			}
			
			
		} 
	}
	
	
	 function chkQty(id) 
	 { 
	 	 var fld='a_'+id;
				if(eval('document.forms[0].'+fld+'.value') == '')
		  { 
		    alert('Quantity Is A Required Field')
		    eval('document.forms[0].'+fld+'').focus();
		    return false
		  }
		  if(parseInt(eval('document.forms[0].'+fld+'.value')) <= 0)
		  {
		     alert('Quantity Should Be Greater Than Zero')
		     eval('document.forms[0].'+fld+'').focus();
		     return false
		  }
		  if(!validateInteger('forms[0]',fld))
		  {
		     eval('document.forms[0].'+fld+'').focus();
		     return false
		  }
		  return true; 
	 }
	 
	//
	
	function getCouponValueNew(item_ids,subtot,grtotalvalue)
	{ 
//		alert(item_ids);
		
		var myRegExp1 = /couponcode/;
		var matchPos1;
		var matchPos2;
		var couponcode_all="";
		var couponcode = document.form1.couponcode.value;
		var itemids_tot = "";
		
		var inputboxes,i,selecount;
	    selecount = 0;
		inputboxes = document.form1.elements;
		//alert("len= "+inputboxes.length);
		for (i=0; i < inputboxes.length; i++) 
		{
			matchPos1 = inputboxes[i].name.search(myRegExp1);
			//alert("i="+i+" ---matchPos1="+matchPos1+" ---name="+inputboxes[i].name+" ---value="+inputboxes[i].value);
			if(matchPos1 != -1)
			{
				//matchPos2 = inputboxes[i].name.search(item_id);
				//if(matchPos2 != -1)
				//{
					couponcode = inputboxes[i].value;
					couponcode_all += inputboxes[i].value+",";
					//alert(couponcode_all);
				//}
			}
		}
		//alert("couponcode_all="+couponcode_all);
		
		var itemidarr = item_ids.split("~");
		for (i=0; i < itemidarr.length; i++)
		{
			var linkObj = document.getElementById('oldtot_'+itemidarr[i]);
			//alert(" linkObj="+linkObj.value);
			itemids_tot += itemidarr[i]+"_"+linkObj.value+"|";
		}
		//alert(" itemids_tot="+itemids_tot);
		
		var url="cart_coupon_ajax.php?couponcode_all=" + couponcode_all + "&prodids=" + item_ids + "&subtot=" + subtot + "&grtotalval=" + grtotalvalue+"&itemids_tot="+itemids_tot;
		xmlHttp=GetXmlHttpObject(stateChangedCoupon)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	}
	
	/*
	function getCouponValue(item_id,subtot,grtotalvalue) //old copy
	{ 
		//alert(item_id);
		
		var myRegExp1 = /couponcode/;
		var matchPos1;
		var matchPos2;
		var couponcode="";
			
		var inputboxes,i,selecount;
	    selecount = 0;
		inputboxes = document.form1.elements;
//		alert("len= "+inputboxes.length);
		for (i=0; i < inputboxes.length; i++) 
		{
			matchPos1 = inputboxes[i].name.search(myRegExp1);
			if(matchPos1 != -1)
			{
				matchPos2 = inputboxes[i].name.search(item_id);
				if(matchPos2 != -1)
				{
					couponcode = inputboxes[i].value;
				}
				
			}
			
		}
		
		var url="cart_coupon_ajax.php?coupon=" + couponcode + "&prodid=" + item_id + "&subtot=" + subtot + "&grtotalval=" + grtotalvalue;
		xmlHttp=GetXmlHttpObject(stateChangedCoupon)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	}
	*/
	
	function stateChangedCoupon() 
	{ 
		//alert(xmlHttp.responseText);
		
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			var res = xmlHttp.responseText;
			var resarr = res.split("#");
			var itemid_newtot = resarr[0];
			var discount_list = resarr[1];
			
//			var resarr = resarr1[0].split("_");
//			var couponvalue = resarr[0];
//			var prodid = resarr[1];
//			var subtot = resarr[2];
//			var grt = resarr[3];
			var grt_new1 = 0,itemdiscount = 0;
			
			//alert("itemid_newtot="+itemid_newtot);
			var itemid_newtot_all = itemid_newtot.split("|"); //1_219|29_49840|31_311.5
			for (var i=0; i < itemid_newtot_all.length; i++)
			{
				itemid_newtot_allarr = itemid_newtot_all[i].split("_");
				itemid = itemid_newtot_allarr[0];
				itemtot = itemid_newtot_allarr[1];
				itemdiscount += parseFloat(itemid_newtot_allarr[2]);
				grt_new1 += parseFloat(itemtot);
				
				var linkObjo = document.getElementById('oldtot_'+itemid);
				//linkObjo.value = itemtot;
			
				var linkObj = document.getElementById('newtot_'+itemid);
				////linkObj.value = itemtot;
			}
			document.getElementById('grtotal').innerHTML = '$ '+grt_new1;
			document.form1.grtotal1.value = grt_new1;
			document.getElementById('discount_total').innerHTML = '$ '+itemdiscount;
			
			document.getElementById('discountlist').innerHTML = discount_list;
           
		}
	}
	//
	
	/*function initializevalue(item_id,subtot,grtotalvalue,qty)
	{
		var linkObjcc = document.getElementById( 'couponcode_'+item_id );
	    if( linkObjcc ) {
	        linkObjcc.value = '';
	    }
		
	    var linkObj1 = document.getElementById('newtot_'+item_id);
	    var linkObj = document.getElementById('oldtot_'+item_id);
	    var linkObjt = document.getElementById('grtotal1');
	    if( linkObj ) {
	         diffe = ((linkObj.value) - (linkObj1.value));
	         if(diffe>0)
	         {
	         	 linkObj1.value = linkObj.value;
	         	 linkObjt.value = (parseFloat(linkObjt.value) + diffe);
	         }
 		}
	    
	    
		var url="cart_coupon_init_ajax.php?prodid=" + item_id + "&subtot=" + subtot + "&grtotalval=" + grtotalvalue + "&qty=" + qty;
		xmlHttp=GetXmlHttpObject(stateChangedCouponInit)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	}
	
	function stateChangedCouponInit() 
	{ 
		//alert(xmlHttp.responseText);
		
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{
			var tot=0;
			var res = xmlHttp.responseText;
			var resarr = res.split("_");
			var couponvalue = resarr[0]; //0
			var prodid = resarr[1];
			var pricetot = resarr[2];
			var grt = resarr[3];
			var cart_prdids = resarr[4];
			
			var linkObj = document.getElementById( 'newtot_'+prodid );
		    if( linkObj ) {
		    	linkObj.value = pricetot;
		    }
		    var cart_prdidsarr = cart_prdids.split(",");
		    for(var i=0;i<cart_prdidsarr.length;i++)
		    {
		    	var linkObjall = document.getElementById( 'newtot_'+cart_prdidsarr[i] );
			    if( linkObjall ) {
			    	tot += parseFloat(linkObjall.value);
			    }
		    }
	    	var linkObjdiscount_amt = document.getElementById( 'discount_amt' );
		    if( linkObjdiscount_amt ) {
		    	tot = (tot - parseFloat(linkObjdiscount_amt.value));
		    }
			
			document.getElementById('grtotal').innerHTML = '$ '+tot;
			document.form1.grtotal1.value = tot;
			document.form1.old_grtotal1.value = tot;
		}
	}*/

//
function addelem() {
	var inpt = document.createElement ('INPUT');
	inpt.type = 'text';
	inpt.name = 'couponcode_new';
	inpt.id = 'couponcode_new';
	inpt.size = 5;
	document.getElementById ('codeDiv').appendChild (inpt);
	document.getElementById ('removelink').style.display='block';
	
	var myRegExp1 = /couponcode_new/;
	var inputboxes,i,selecount=0;
	var matchPos1;
	var inputboxes = document.form1.elements;
	for (i=0; i < inputboxes.length; i++) 
	{
		matchPos1 = inputboxes[i].name.search(myRegExp1);
		//alert("i="+i+" ---matchPos1="+matchPos1+" ---name="+inputboxes[i].name);
		if(matchPos1 != -1)
		{
			selecount++;
		}
	}
	var linkObjCount = document.getElementById('theCount');
	linkObjCount.value = selecount;
}
//
function removeelem() {
	var inputboxes = document.form1.elements;
//	alert("len= "+inputboxes.length);

	var inputboxes,i,selecount;
	
	var inpt = document.getElementById('couponcode_new');
	document.getElementById ('codeDiv').removeChild (inpt);
	
	var linkObjCount = document.getElementById('theCount');
	selecount = linkObjCount.value;
	selecount--;
	linkObjCount.value = selecount;
	if(linkObjCount.value == 0)
	{
		document.getElementById ('removelink').style.display='none';
	}
}

/*
function addElement() {
//	alert(1);
	
	var ni = document.getElementById('myDiv');
	var numi = document.getElementById('theValue');
	var num = (document.getElementById('theValue').value -1)+ 2;
	numi.value = num;
	var newdiv = document.createElement('div');
//	var divIdName = 'my'+num+'Div';
	var divIdName = 'couponcode'+num;
	newdiv.setAttribute('id',divIdName);
	newdiv.innerHTML = ' <a href=\'javascript:;\' onclick=\'removeElement(\"'+divIdName+'\")\' title=\'Remove\'>x name='+divIdName+'</a>';
	ni.appendChild(newdiv);
	
	var inpt = document.createElement ('INPUT');
	inpt.type = 'text';
	inpt.name = divIdName;
	inpt.id = divIdName;
	inpt.size = 5;
	document.getElementById ('myDiv').appendChild (inpt);
	
}

function removeElement(divNum) {
	alert(divNum);
//	var d = document.getElementById('myDiv');
	var olddiv = document.getElementById(""+divNum+"");
//	d.removeChild(olddiv);
	var inpt = document.getElementById(divNum);
	olddiv.removeChild (divNum);
//	document.getElementById ('couponcode1').removeChild ('couponcode1');
}
//
//function removeElement(divNum) {
//	alert(divNum);
//	var d = document.getElementById('myDiv');
//	var olddiv = document.getElementById(divNum);
//	d.removeChild(olddiv);
//	var inpt = document.getElementById('couponcode');
//	document.getElementById ('myDiv').removeChild (inpt);
//}

//

var intTextBox=0;

//FUNCTION TO ADD TEXT BOX ELEMENT
function addElement2()
{
	alert(1);
	intTextBox = intTextBox + 1;
	var contentID = document.getElementById('content');
	var newTBDiv = document.createElement('div');
	newTBDiv.setAttribute('id','strText'+intTextBox);
	newTBDiv.innerHTML = "Text "+intTextBox+": <input type='text' id='" + intTextBox + "' name='" + intTextBox + "'/>";
	contentID.appendChild(newTBDiv);
}

//FUNCTION TO REMOVE TEXT BOX ELEMENT
function removeElement2()
{
	alert(2);
	if(intTextBox != 0)
	{
		var contentID = document.getElementById('content');
		contentID.removeChild(document.getElementById('strText'+intTextBox));
		intTextBox = intTextBox-1;
	}
}
*/

function addMore()
{
	count	= jQuery("#addmore_count").val();
	count = parseInt(count)+parseInt(1);
	jQuery("#coupon_code_tbl").append('<tr id="addmore_'+count+'"><td><input type="text" name="couponcode[]" id="couponcode_'+count+'" size="5" /></td><td><a href="javascript:void(0);" class="bluelink" onclick="removeItem('+count+')"><img src="assets/images/icn_remove.gif" border="0" alt="Remove" width="16"  height="16"    title="Remove" /></a></td></tr>');
	jQuery("#addmore_count").attr('value',count);
}
function removeItem(id)
{  
	jQuery("#addmore_"+id).remove();  	
} 
function applyCoupon()
{
     
	var file_flag = 0;	  
	var coupon_code    =   '';
    for(i=1; i<=jQuery("#addmore_count").val(); i++)
    {    	   
        
     if (jQuery("#addmore_"+i).length)
    	 if( jQuery("#couponcode_"+i).val() !="" ) {
    		    file_flag  = file_flag+1; 
    		    
    	 }     
    }   
    if(file_flag == 0)
    {
       
      alert("Please en ter atleast one coupon code.");
       jQuery("#couponcode_1").focus();
      return false;
    } 
    
}
