function displayUpload(argument) {
	var uploadtype;
	var imagediv;
	var textdiv;
	var design;
	var firstoption;
	var falseoption;
	var order;
	order=document.getElementById('orderref').value;
	imagediv=document.getElementById('imageupload');
	textdiv=document.getElementById('textupload');
	design=document.getElementById('design');
	firstoption=document.getElementById('firstoption');
	falseoption=document.getElementById('falseoption');
	textinstructiondiv=document.getElementById('textinstruction');
	logoinstructiondiv=document.getElementById('logoinstruction');
	textoptiondiv=document.getElementById('textoption');
	logooptiondiv=document.getElementById('logooption');

	imagediv.style.display ='block';
	textdiv.style.display= 'block';

	if (argument=='1') {
		design.value='/images/ww/custom/'+order+'/';

		//firstoption.checked=false;
		falseoption.checked=true;
		logoinstructiondiv.style.display ='block';
		textinstructiondiv.style.display ='none';
		textoptiondiv.style.display ='none';
		logooptiondiv.style.display ='block';

		/*
		textdiv.style.display= 'none';
		imagediv.style.display ='block';
		*/
	} else {
		design.value='Enter Text';
		falseoption.checked=true;
		//firstoption.checked=true;
		logoinstructiondiv.style.display ='none';
		textinstructiondiv.style.display ='block';
		textoptiondiv.style.display ='block';
		logooptiondiv.style.display ='none';

		/*
		textdiv.style.display ='block';
		imagediv.style.display = 'none';
		*/
	}
	
}
function validdateradio() {
	var uploadtype1=document.getElementById('designtype1');	
	var uploadtype2=document.getElementById('designtype2');
	var falseoption=document.getElementById('falseoption');
	var qty=document.getElementById('quantity').value;
	var qty2=document.getElementById('hiddenqty').value;

	if ((!uploadtype1.checked&&!uploadtype2.checked)||falseoption.checked) {
		alert('You must select either Logo or Text to be applied to this garment');
		return false;
	} else {
		return validateQuantities();
	}
}

var intDefaultQuantity;
var arrIDs;

function validateQuantities() {
/*
	var totalQTY=0;
	
	for(var n=0;n<arrIDs.length;n++){
		if(!isNaN(document.getElementById('option'+arrIDs[n]).value)){
			var intValue=parseInt(document.getElementById('option'+arrIDs[n]).value);
			
			totalQTY+=intValue;
		}
	}
*/	
	if(document.getElementById('quantity').value==document.getElementById('hiddenqty').value){
		return true;
	} else {
		alert('Quantities entered in the size options must total to the main quantity entered');
		return false;
	}
		
}

function updateQTYsFromCookies(idstring){
	var strIDString=idstring;
	
	arrIDs=strIDString.split(';');
	var sizeoptions='';
	var totalQTY=0;;
	
	for(var n=0;n<arrIDs.length;n++){
		//alert(arrIDs[n]);
		
		if(GetCookie(arrIDs[n])!=null){
			document.getElementById('option'+arrIDs[n]).value=GetCookie(arrIDs[n]);
		}else{
			document.getElementById('option'+arrIDs[n]).value='0';
		}
	}
	
	
	/****** IF WE DONT DO THIS, THE HOW CAN THE SIZE OPTIONS AND HIDDENTQTY BE CALCULATED ON A RERESH OR UPDATE??? *****/
		
	for(var n=0;n<arrIDs.length;n++){
		if(!isNaN(document.getElementById('option'+arrIDs[n]).value)){
			var intValue=parseInt(document.getElementById('option'+arrIDs[n]).value);

			sizeoptions+='<br />'+document.getElementById('option'+arrIDs[n]+'_label').innerHTML+document.getElementById('option'+arrIDs[n]).value;
			totalQTY+=intValue;
		}
	}
	
	document.getElementById('sizeoptions').value=sizeoptions;
	document.getElementById('hiddenqty').value=totalQTY;
}

function updateSizeOptions(element) {	
	var totalQTY=parseInt(document.getElementById('hiddenqty').value);

	SetCookie(element.id.replace('option',''),element.value);

	var sizeoptions='';
	var totalQTY=0;
	
	for(var n=0;n<arrIDs.length;n++){
		if(!isNaN(document.getElementById('option'+arrIDs[n]).value)){
			var intValue=parseInt(document.getElementById('option'+arrIDs[n]).value);		
			//document.getElementById('option'+arrIDs[n]).value=GetCookie(arrIDs[n]);
			
			sizeoptions+='<br />'+document.getElementById('option'+arrIDs[n]+'_label').innerHTML+document.getElementById('option'+arrIDs[n]).value;
			totalQTY+=intValue;
		}
	}
	
	document.getElementById('hiddenqty').value = totalQTY;
	//alert(sizeoptions);
	//alert(document.getElementById('hiddenqty').value);
		
	document.getElementById('sizeoptions').value=sizeoptions;
	
	if(document.getElementById('quantity').value!=document.getElementById('hiddenqty').value){
		document.getElementById('quantity').value=totalQTY;
		document.getElementById('hiddenqty').value=totalQTY;
	}
}
