function toggleQuickSize(id){
	if(	document.getElementById("quicksize").value == "Custom"){
		document.getElementById("pwidth").removeAttribute('readOnly');
		document.getElementById("pheight").removeAttribute('readOnly');
		document.getElementById("customesizefield").style.display = '';
	}else{
		document.getElementById("pwidth").setAttribute('readOnly','readonly');
		document.getElementById("pheight").setAttribute('readOnly','readonly');
		document.getElementById("pwidth").value = '';
		document.getElementById("pheight").value = '';
		document.getElementById("customesizefield").style.display = 'none';
	}

}
//DISABLE PORTRAIT/LANDSCAPE
function disablePrintDirection(){	
	if(document.getElementById("quicksize").value == "Custom"){	
		document.getElementById("printDirection_0").checked=true;
		document.getElementById("printDirection_1").disabled=true;
	}else{
		document.getElementById("printDirection_0").checked=true;
		document.getElementById("printDirection_1").disabled=false;
	}
}
//SHIPPING ADDRESS CONTROL
function SelectDeliveryType(id,Status){
   if(Status=="0"){
	   	//shipment
		document.getElementById("delivery_name").style.display = '';
		document.getElementById("delivery_companyname").style.display = '';
		document.getElementById("delivery_email").style.display = '';
		document.getElementById("delivery_mobile").style.display = '';
		document.getElementById("delivery_quickoption").style.display = '';
		document.getElementById("delivery_address").style.display = '';
		document.getElementById("delivery_city").style.display = '';
		document.getElementById("delivery_state").style.display = '';
		document.getElementById("delivery_postcode").style.display = '';
		document.getElementById("delivery_country").style.display = '';
		document.getElementById("delivery_instruction").style.display = '';
		document.getElementById("pickup_address").style.display = 'none';

   }else{
	    //self pick up
		document.getElementById("delivery_name").style.display = 'none';
		document.getElementById("delivery_companyname").style.display = 'none';
		document.getElementById("delivery_email").style.display = 'none';
		document.getElementById("delivery_mobile").style.display = 'none';
		document.getElementById("delivery_quickoption").style.display = 'none';
		document.getElementById("delivery_address").style.display = 'none';
		document.getElementById("delivery_city").style.display = 'none';
		document.getElementById("delivery_state").style.display = 'none';
		document.getElementById("delivery_postcode").style.display = 'none';
		document.getElementById("delivery_country").style.display = 'none';
		document.getElementById("delivery_instruction").style.display = 'none';
		document.getElementById("pickup_address").style.display = '';   }
}

function SelectDeliveryQuickAddress(id,Status){
   if(Status=="0"){
	   //default address
		showhide();
		document.getElementById("name").setAttribute('readOnly');
		document.getElementById("company_name").setAttribute('readOnly');
		//document.getElementById("email").setAttribute('readOnly');
		document.getElementById("mobilephone1").setAttribute('readOnly');
		document.getElementById("mobilephone2").setAttribute('readOnly');
		document.getElementById("address").setAttribute('readOnly');
		document.getElementById("city").setAttribute('readOnly');
		document.getElementById("postcode").setAttribute('readOnly');
		//document.getElementById("state").setAttribute('readOnly');
		//document.getElementById("country").setAttribute('readOnly');

		document.getElementById("name").setAttribute("class", "form_field_text_readonly");
		document.getElementById("company_name").setAttribute("class", "form_field_text_readonly");
		//document.getElementById("email").setAttribute("class", "form_field_text_readonly");
		document.getElementById("mobilephone1").setAttribute("class", "form_field_text_readonly");
		document.getElementById("mobilephone2").setAttribute("class", "form_field_text_readonly");
		document.getElementById("address").setAttribute("class", "form_field_text_readonly");
		document.getElementById("city").setAttribute("class", "form_field_text_readonly");
		document.getElementById("postcode").setAttribute("class", "form_field_text_readonly");
		document.getElementById("state").setAttribute("class", "form_field_text_readonly");
		document.getElementById("country").setAttribute("class", "form_field_text_readonly");
		
   }else{
		//other address
		document.getElementById("name").removeAttribute('readOnly');
		document.getElementById("company_name").removeAttribute('readOnly');
		//document.getElementById("email").removeAttribute('readOnly');
		document.getElementById("mobilephone1").removeAttribute('readOnly');
		document.getElementById("mobilephone2").removeAttribute('readOnly');
		document.getElementById("address").removeAttribute('readOnly');
		document.getElementById("city").removeAttribute('readOnly');
		document.getElementById("postcode").removeAttribute('readOnly');
		//document.getElementById("state").removeAttribute('readOnly');
		//document.getElementById("country").removeAttribute('readOnly');

		document.getElementById("name").setAttribute("class", "form_field_text validate[required,custom[onlyLetter],length[0,50]] text-input");
		document.getElementById("company_name").setAttribute("class", "form_field_text validate[required,length[0,50]] text-input");
		//document.getElementById("email").setAttribute("class", "form_field_text_readonly");
		document.getElementById("mobilephone1").setAttribute("class", "form_field_text");
		document.getElementById("mobilephone2").setAttribute("class", "form_field_text");
		document.getElementById("address").setAttribute("class", "form_field_text");
		document.getElementById("city").setAttribute("class", "form_field_text");
		document.getElementById("postcode").setAttribute("class", "form_field_text");
		document.getElementById("state").setAttribute("class", "form_field_text");
		document.getElementById("country").setAttribute("class", "form_field_text");
   }
}
function DisableStateDropDownMenu(text,value){
	document.getElementById("state").length = 0;
	addOption(document.getElementById("state"),text,value);
}

function validateShippingfields(){
	status = 1;
	if(document.getElementById("shipmenttype_0").checked==true){
			
		
		if($("#name").val()==""){
			$.validationEngine.buildPrompt("#name","Please fill in Recipient Name","error");
			status = 0;
		}		
		if($("#company_name").val()==""){;
			$.validationEngine.buildPrompt("#company_name","Please fill in Recipient Company Name","error");
			status = 0;
		}
		if($("#email").val()==""){;
			$.validationEngine.buildPrompt("#email","Please fill in Recipient Company Name","error");
			status = 0;
		}
		if($("#mobilephone1").val()=="" || $("#mobilephone2").val()=="" || IsNumeric($("#mobilephone1").val())==false || IsNumeric($("#mobilephone2").val())==false){;
			$.validationEngine.buildPrompt("#email","Please fill in Recipient Company Name","error");
			status = 0;
		}
		if($("#address").val()==""){;
			$.validationEngine.buildPrompt("#address","Please fill in Recipient Email","error");
			status = 0;
		}		
		if($("#city").val()==""){;
			$.validationEngine.buildPrompt("#city","Please fill in Recipient City","error");
			status = 0;
		}		
		if($("#postcode").val()=="" && IsNumeric($("#quantitycustomizefield").val())==false){;
			$.validationEngine.buildPrompt("#postcode","Please fill in a valid Recipient Postcode","error");
			status = 0;
		}		
		if($("#state").val()==""){;
			$.validationEngine.buildPrompt("#state","Please fill in Recipient State","error");
			status = 0;
		}		
		if($("#country").val()==""){;
			$.validationEngine.buildPrompt("#country","Please fill in Recipient Country","error");
			status = 0;
		}	
	}
	if(	status == 0){
		return false;
	}else{
		return true;
	}

}
//NAME CARD AUTO SELECT FOLDING
function SelectNCFolding(){
	var myRegExp1 = /Fold/;
	var string1 = $("#quicksize option:selected").text();
	var matchPos1 = string1.search(myRegExp1);
	if(matchPos1 != -1){
		//fold
		document.getElementById("quote_remarks").value = 'NC_Folding';
	}
}

//VALIDATING FOLDING OPTIONS
function validateFoldingfields(){
	var foldingtype = document.getElementById("folding").value;
	var myRegExp1 = /Card/;
	var string1 = $("#papertype option:selected").text();
	var matchPos1 = string1.search(myRegExp1);
	if(matchPos1 != -1){
		//card
		if(foldingtype=="FF"){
			$.validationEngine.buildPrompt("#folding","Please select another folding type other than French Fold","error");
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: 300}, 500 );
			return false;
		}else{
			return true;	
		}
	}else{
		//not card
		return true;
	}
}
//DISABLE STUFF BASE ON PAPER TYPE
function SelectPaper(){
	var myRegExp1 = /Card/;
	var string1 = $("#papertype option:selected").text();
	var matchPos1 = string1.search(myRegExp1);
	if(matchPos1 != -1){
		//card
		$("#foldorcrease").html("Creasing Line");
	}else{
		//not card
		$("#foldorcrease").html("Folding");
	}
}

//DISABLE SPOT UV BUTTON
function DisableSpotUV(id,Status){
   if(Status=="1"){
		document.getElementById("coating_suv").disabled=true;
		document.getElementById("coating_suvside1").disabled=true;
		document.getElementById("coating_suvside2").disabled=true;
		document.getElementById("coating_suv").checked=false;
		document.getElementById("coating_suvside1").checked = false;
		document.getElementById("coating_suvside2").checked = false;
   }else{
		document.getElementById("coating_suv").disabled=false;
   }
}

//DISABLE SPOT UV CHOOSE SIDE
function DisableSpotUVSide(id,Status){
   if(document.getElementById(id).checked==true){
		document.getElementById("coating_suvside1").disabled=false;
		document.getElementById("coating_suvside2").disabled=false;
   }else{
		document.getElementById("coating_suvside1").disabled=true;
		document.getElementById("coating_suvside2").disabled=true;
		document.getElementById("coating_suv").checked=false;
		document.getElementById("coating_suvside1").checked = false;
		document.getElementById("coating_suvside2").checked = false;
   }
}

//DISABLE HOT STAMPING BUTTON
function DisableHotStamping(id,Status){
   if(document.getElementById(id).value==""){
		document.getElementById("finishingsize2").disabled=true;
   }else{
		document.getElementById("finishingsize2").disabled=false;
   }
	
}

//DISPLAY NAME CARD PICTURES
function SelectNC(){
	if($("#quicksize").val() =="86x52"){
		document.getElementById("ncpicture").src="/images/product/quote/businesscard/86x52.png";
	}else if($("#quicksize").val() =="89x54"){
		document.getElementById("ncpicture").src="/images/product/quote/businesscard/89x54.png";
	}else if($("#quicksize").val() =="86x104"){
		document.getElementById("ncpicture").src="/images/product/quote/businesscard/86x104.png";
	}else if($("#quicksize").val() =="89x108"){
		document.getElementById("ncpicture").src="/images/product/quote/businesscard/89x108.png";
	}else if($("#quicksize").val() =="52x172"){
		document.getElementById("ncpicture").src="/images/product/quote/businesscard/52x172.png";
	}else if($("#quicksize").val() =="54x178"){
		document.getElementById("ncpicture").src="/images/product/quote/businesscard/54x178.png";
	}else if($("#quicksize").val() =="Custom"){
		document.getElementById("ncpicture").src=""
	}
}

//DISPLAY FOLDING PICTURES
function SelectFolding(){
	var foldingType = document.getElementById("folding").value;
	switch(foldingType){
		case "HF":
		  document.getElementById('foldingpicture').innerHTML = "<img src='/images/product/quote/folding/HalfFold.png' />";
		  break;
		case "TF":
		  document.getElementById('foldingpicture').innerHTML = "<img src='/images/product/quote/folding/TriFold.png' />";
		  break;
		case "GF":
		  document.getElementById('foldingpicture').innerHTML = "<img src='/images/product/quote/folding/GateFold.png' />";
		  break;
		case "DGF":
		  document.getElementById('foldingpicture').innerHTML = "<img src='/images/product/quote/folding/DoubleGateFold.png' />";
		  break;
		case "ZF":
		  document.getElementById('foldingpicture').innerHTML = "<img src='/images/product/quote/folding/ZFold.png' />";
		  break;
		case "AF":
		  document.getElementById('foldingpicture').innerHTML = "<img src='/images/product/quote/folding/AccordianFold.png' />";
		  break;
		case "RF":
		  document.getElementById('foldingpicture').innerHTML = "<img src='/images/product/quote/folding/RollFold.png' />";
		  break;
		case "DPF":
		  document.getElementById('foldingpicture').innerHTML = "<img src='/images/product/quote/folding/DoubleParallelFold.png' />";
		  break;
		case "FF":
		  document.getElementById('foldingpicture').innerHTML = "<img src='/images/product/quote/folding/FrenchFold.png' />";
		  break;
		default:
		  document.getElementById('foldingpicture').innerHTML = "";
	}			
}

function ProcessPeriod(id){
	var p = document.getElementById("day"+id);
	for (i=2;i<=8;i++){
		document.getElementById("day"+i).style.display = 'none';
	}
	
	document.getElementById("progressperiod").value = id;
	p.style.display = 'block';
}

function IsNumeric(sText){
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++){ 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1){
         IsNumber = false;
         }
      }
   return IsNumber;
}



function validateQuantity(){
	if($("#quantity").val() =="CUSTOM"){
		
		if($("#quantitycustomizefield").val()=="" && $("#quantitycustomizefield2").val()=="" && $("#quantitycustomizefield3").val()=="" ){
			$.validationEngine.buildPrompt("#quantitycustomizefield","Please fill in at least one Quantity","error")
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: 300}, 500 );
			return false;
		}
		
		if($("#quantitycustomizefield").val()!="" && IsNumeric($("#quantitycustomizefield").val())==false){
			$.validationEngine.buildPrompt("#quantitycustomizefield","Please fill in custom Quantity","error")
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: 300}, 500 );
			return false;
		}
			
		if($("#quantitycustomizefield2").val()!="" && IsNumeric($("#quantitycustomizefield2").val())==false){
			$.validationEngine.buildPrompt("#quantitycustomizefield2","Please fill in custom Quantity","error")
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: 300}, 500 );
			return false;
		}
			
		if($("#quantitycustomizefield3").val()!="" && IsNumeric($("#quantitycustomizefield3").val())==false){
			$.validationEngine.buildPrompt("#quantitycustomizefield3","Please fill in custom Quantity","error")
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: 300}, 500 );
			return false;
		}
			
	}
}

//COMMON WIDTH HEIGHT VALIDATION
function validate2fields(){
	if($("#quicksize").val() =="Custom" &&  ($("#pwidth").val() == "" || isNaN($("#pwidth").val()) || $("#pheight").val() == ""|| isNaN($("#pheight").val()))){
		$.validationEngine.buildPrompt("#pwidth","Please fill in custom Width","error")
		$.validationEngine.buildPrompt("#pheight","Please fill in custom Height","error")
		$("html:not(:animated),body:not(:animated)").animate({ scrollTop: 300}, 500 );
		return false;
	}else{
		return true;
	}
}
//SPECIAL FOR BOOK CONTENT
function validate2fieldsContent(){
	if($("#2quicksize").val() =="Custom" &&  ($("#pwidthqs2").val() == "" ||  $("#pheightqs2").val() == "")){
		$.validationEngine.buildPrompt("#pwidthqs2","Please fill in custom Width","error")
		$.validationEngine.buildPrompt("#pheightqs2","Please fill in custom Height","error")
		$("html:not(:animated),body:not(:animated)").animate({ scrollTop: 850}, 500 );
		return false;
	}else{
		return true;
	}
}

//PAPER BAG WITH EXTRA LENGHT ATTRIBUTE
function validate3fields(){
	if($("#pwidth").val() == "" || isNaN($("#pwidth").val()) ||  $("#pheight").val() == "" || isNaN($("#pwidth").val())  ||  $("#plength").val() == "" || isNaN($("#plength").val()) ){
		status = 0;
		if($("#pwidth").val() == ""|| isNaN($("#pwidth").val())){
			$.validationEngine.buildPrompt("#pwidth","Please fill in custom Width","error")
		}
		if($("#pheight").val() == ""|| isNaN($("#pheight").val())){
			$.validationEngine.buildPrompt("#pheight","Please fill in custom Height","error")
		}
		if($("#plength").val() == ""|| isNaN($("#plength").val())){
			$.validationEngine.buildPrompt("#plength","Please fill in custom Length","error")
		}
		$("html:not(:animated),body:not(:animated)").animate({ scrollTop: 300}, 500 );
		return false;
	}else{
		status = 1;
		return true;
	}
}

//VALIDATE NORMAL FINISHING OR BOOK COVER
function validateFinishingfields(){
	if(status != 0){

			//if(document.getElementById("finishing1").value != "" && document.getElementById("finishingsize1").value == "CUSTOM" && (document.getElementById("finishingcustomsize1").value == "" || isNaN(document.getElementById("finishingcustomsize1").value)) || document.getElementById("finishing2").value != "" && document.getElementById("finishingsize2").value == "CUSTOM" && (document.getElementById("finishingcustomsize2").value == "" || isNaN(document.getElementById("finishingcustomsize2").value)) || document.getElementById("finishing3").value != "" && document.getElementById("finishingsize3").value == "CUSTOM" && (document.getElementById("finishingcustomsize3").value == "" || isNaN(document.getElementById("finishingcustomsize3").value)) || document.getElementById("finishing4").value != "" && document.getElementById("finishingsize3").value == "CUSTOM" && (document.getElementById("finishingcustomsize4").value == "" || isNaN(document.getElementById("finishingcustomsize4").value)) ){
				
				if(document.getElementById("finishing1").value != "" && document.getElementById("finishingsize1").value == "CUSTOM" && (document.getElementById("finishingcustomsize1").value == "" || isNaN(document.getElementById("finishingcustomsize1").value))){
					status = 0;	
					$.validationEngine.buildPrompt("#finishingcustomsize1","Please fill in custom size in square inch","error");
				}else if(document.getElementById("finishing2").value != "" && document.getElementById("finishingsize2").value == "CUSTOM" && (document.getElementById("finishingcustomsize2").value == "" || isNaN(document.getElementById("finishingcustomsize2").value))){
					$.validationEngine.buildPrompt("#finishingcustomsize2","Please fill in custom size in square inch","error");
					status = 0;	
				}else if(document.getElementById("finishing3").value != "" && document.getElementById("finishingsize3").value == "CUSTOM" && (document.getElementById("finishingcustomsize3").value == "" || isNaN(document.getElementById("finishingcustomsize3").value))){
					$.validationEngine.buildPrompt("#finishingcustomsize3","Please fill in custom size in square inch","error");
					status = 0;	
				}else if(document.getElementById("finishing4").value != "" && document.getElementById("finishingsize4").value == "CUSTOM" && (document.getElementById("finishingcustomsize4").value == "" || isNaN(document.getElementById("finishingcustomsize4").value))){
					$.validationEngine.buildPrompt("#finishingcustomsize4","Please fill in custom size in square inch","error");
					status = 0;	
				//new coating validation
				}else if(document.getElementById("coating_suv").checked==true && (document.getElementById("coating_suvside1").checked==false && document.getElementById("coating_suvside2").checked==false)){
					$.validationEngine.buildPrompt("#coating_suv","Please select a side for Spot UV","error");
					status = 0;	
				}
				
				if(status==0){
					$("html:not(:animated),body:not(:animated)").animate({ scrollTop: 350}, 500 );
					return false;
				}else{
					status = 1;	
					return true;
				}
			}else{
				status = 1;	
				return true;
			}
	//}else{
		//return false;
	//}
}
//SPECIAL FINISHING VALIDATION FOR BOOK CONTENT
function validateContextFinishingfields(){
	if(status != 0){
			//if(document.getElementById("2finishing1").value != "" && document.getElementById("2finishingsize1").value == "CUSTOM" && document.getElementById("2finishingcustomsize1").value == "" || document.getElementById("2finishing2").value != "" && document.getElementById("2finishingsize2").value == "CUSTOM" && document.getElementById("2finishingcustomsize2").value == "" || document.getElementById("2finishing3").value != "" && document.getElementById("2finishingsize3").value == "CUSTOM" && document.getElementById("2finishingcustomsize3").value == "" || document.getElementById("2finishing4").value != "" && document.getElementById("2finishingsize3").value == "CUSTOM" && document.getElementById("2finishingcustomsize4").value == "" ){
			
				if(document.getElementById("2finishing1").value != "" && document.getElementById("2finishingsize1").value == "CUSTOM" && (document.getElementById("2finishingcustomsize1").value == ""|| isNaN(document.getElementById("2finishingcustomsize1").value))){
				
					$.validationEngine.buildPrompt("#2finishingcustomsize1","Please fill in custom size in square inch","error")
				}else if(document.getElementById("2finishing2").value != "" && document.getElementById("2finishingsize2").value == "CUSTOM" && (document.getElementById("2finishingcustomsize2").value == "" || isNaN(document.getElementById("2finishingcustomsize2").value))){
					$.validationEngine.buildPrompt("#2finishingcustomsize2","Please fill in custom size in square inch","error")
				}else if(document.getElementById("2finishing3").value != "" && document.getElementById("2finishingsize3").value == "CUSTOM" && (document.getElementById("2finishingcustomsize3").value == "" || isNaN(document.getElementById("2finishingcustomsize3").value))){
					$.validationEngine.buildPrompt("#2finishingcustomsize3","Please fill in custom size in square inch","error")
				}else if(document.getElementById("2finishing4").value != "" && document.getElementById("2finishingsize4").value == "CUSTOM" && (document.getElementById("2finishingcustomsize4").value == "" || isNaN(document.getElementById("2finishingcustomsize4").value))){
					$.validationEngine.buildPrompt("#2finishingcustomsize4","Please fill in custom size in square inch","error")
				}
				$("html:not(:animated),body:not(:animated)").animate({ scrollTop: 1000}, 500 );
				status = 0;	
				return false;
			}else{
				status = 1;	
				return true;
			}
	//}else{
		//return false;
	//}
}


//FINISHING GENERATING/INTERFACE INTERACTIVE
function DefaultSelectFinSubCat(id,fvalue){
	var target_id=id.charAt(id.length-1);
	var fsizecustom = document.getElementById("finishingcustomsize"+target_id);
	var fsizecustomdiv = document.getElementById("finishingcustomsizediv"+target_id);

	SelectFinCat("finishing"+target_id,fvalue);

	if(fvalue == 'CUSTOM'){
		fsizecustomdiv.style.display = '';
	}else{
		fsizecustomdiv.style.display = 'none';
	}
}


function SelectQuantity(id){
	var q = document.getElementById(id);
	if(q.value=="CUSTOM"){
		document.getElementById("quantitycustomize").style.display = '';
	}else{
		document.getElementById("quantitycustomize").style.display = 'none';
	}
}

function SelectFinSubCat(id){
	var target_id=id.charAt(id.length-1);
	var f = document.getElementById("finishingsize"+target_id);
	var fsizecustom = document.getElementById("finishingcustomsize"+target_id);
	//f.style.display = '';
	//alert(document.getElementById("finishingsize"+target_id).value);
	//alert(id);
	if(f.value == 'CUSTOM'){
		//fsizecustom.style.display = '';
		//fsizecustom.setAttribute("class", "form_field_text validate[funcCall[validateFinishingfields]]");
		fsizecustom.setAttribute("class", "form_field_text");
		fsizecustom.removeAttribute('readOnly');
	}else{
		//fsizecustom.style.display = 'none';
		fsizecustom.value = "";
		fsizecustom.setAttribute("class", "form_field_text_readonly");
		fsizecustom.setAttribute('readOnly','readonly');
	}
}
function SelectFinCat(id,fvalue){
	// ON selection of category this function will work
	var target_id=id.charAt(id.length-1);
	var f = document.getElementById("finishing"+target_id);
	var fsize = document.getElementById("finishingsize"+target_id);
	var fsizediv = document.getElementById("finishingsizediv"+target_id);
	var fsizecustom = document.getElementById("finishingcustomsize"+target_id);
	var fsizecustomdiv = document.getElementById("finishingcustomsizediv"+target_id);

	removeAllOptions(fsize,fsizecustomdiv);
	//fsizediv.style.display = '';
	fsize.removeAttribute('readOnly');
	fsize.setAttribute("class", "form_field_text");

	
	if(f.value == 'DC'){
		addOption(fsize,"100", "100 sq inch", target_id,fvalue);
		addOption(fsize,"150", "150 sq inch", target_id,fvalue);
		addOption(fsize,"200", "200 sq inch", target_id,fvalue);
		addOption(fsize,"CUSTOM", "Custom Size", target_id,fvalue);
	}
	if(f.value == 'EM'){
		addOption(fsize,"50", "50 sq inch", target_id,fvalue);
		addOption(fsize,"100", "100 sq inch", target_id,fvalue);
		addOption(fsize,"150", "150 sq inch", target_id,fvalue);
		addOption(fsize,"CUSTOM", "Custom Size", target_id,fvalue);
	}
	if(f.value == 'HS1'){
		addOption(fsize,"5", "5 sq inch", target_id,fvalue);
		addOption(fsize,"10", "10 sq inch", target_id,fvalue);
		addOption(fsize,"15", "15 sq inch", target_id,fvalue);
		addOption(fsize,"20", "20 sq inch", target_id,fvalue);
		addOption(fsize,"CUSTOM", "Custom Size", target_id,fvalue);
	}
	if(f.value == 'HS2'){
		addOption(fsize,"5", "5 sq inch", target_id,fvalue);
		addOption(fsize,"10", "10 sq inch", target_id,fvalue);
		addOption(fsize,"15", "15 sq inch", target_id,fvalue);
		addOption(fsize,"20", "20 sq inch", target_id,fvalue);
		addOption(fsize,"CUSTOM", "Custom Size", target_id,fvalue);
	}
	if(f.value == ''){
		//fsizediv.style.display = 'none';
		fsizediv.setAttribute('readOnly','readonly');
		var optn = document.createElement("OPTION");
		optn.text = "None";
		optn.value = "";
		fsize.options.add(optn);
		
		//textfield.style.display = 'none';
		fsize.setAttribute("class", "form_field_text_readonly");
		fsize.setAttribute('readOnly','readonly');
		SelectFinSubCat(target_id);
	}
}

function removeAllOptions(selectbox,textfield)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}


function addOption(selectbox, value, text, parent_id,fvalue)
{	
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	if(fvalue && (value == fvalue)){
		optn.selected = true;
	}
	selectbox.options.add(optn);
}
