function AddColourItemToCart(newurl)
{

var returnval = window.location.href;
  if(newurl != ''){
      var qty = document.getElementById('txtqty').value;
     var chosencolour = document.getElementById('colourchoice').value;
      if(chosencolour == 'Please select Colour...'){
          alert('Please select a colour before adding this item to the shopping cart!');
           return returnval;
       }
      else{
          returnval = newurl + "&colour=" + document.getElementById('colourchoice').value + "&qty=" + qty;
          return returnval;
     }
  }

alert(' Invalid selection! \n\nUnable to add this item to the shopping cart.');
return returnval;
}

function AddItemToCart(newurl,txtqty,iIndex)
{

var returnval = window.location.href;


//alert(returnval);
  if(newurl != ''){
  	  
      //var qty = document.getElementById(txtqty).value;
      
        if(txtqty =='') {        	
        	alert('Please enter a quantity first.');
        	return returnval; 
        }        
        else{    
								
							var choiceParams = '';	
							var optionfail = '';					
							var colorchoice = document.getElementById('colouroption' + iIndex);
							
							if(colorchoice != null ){
							
								 var colorvalue = colorchoice.options[colorchoice.selectedIndex].value;
								 							
								 if(colorvalue.indexOf('Please') == -1){
								 	choiceParams = '&colour=' + colorvalue;
								}else{
									 optionfail = 'true';
								}
								
							}
							
							var modulechoice = document.getElementById('moduleoption' + iIndex);
							if(modulechoice != null){
								 var modulevalue = modulechoice.options[modulechoice.selectedIndex].value;
								 if(modulevalue.indexOf('Please') == -1){
								 	choiceParams = choiceParams + '&module=' + modulevalue;
								}else{
									 optionfail = 'true';
								}
							}
							
							var strapchoice = document.getElementById('strapoption' + iIndex);
							if(strapchoice != null ){
								 var strapvalue = strapchoice.options[strapchoice.selectedIndex].value;
								 if(strapvalue.indexOf('Please') == -1){
								 	choiceParams = choiceParams + '&strap=' + strapvalue;
								}else{
									 optionfail = 'true';
								}
							}
						}
					 
					 if(optionfail == 'true'){
					 	  alert('Please enter the required option values first.');
        	    return false; 
					  }
					
          returnval = newurl +  "&qty=" + txtqty + choiceParams;
          window.location.href=returnval;
        
   }

//return returnval;
}



function AddPopupItemToCart(theurl,qty)
{
	//alert(theurl + " Qty: " + qty);
	if (window.opener && !window.opener.closed){
        window.opener.AddItemToCart(theurl,qty);
      }
	}



function refreshParent() {
	
	//alert(window.opener.document.getElementById('ItemTotal').value); 
	alert(window.opener.location.href);
  //window.opener.location.href = window.opener.location.href;

}
