/*
 * Returns an new XMLHttpRequest object, or false if the browser
 * doesn't support it
 */
 
  var xmlhttp;
  var mngmxmlhttp;
  var embxmlhttp;
  var reqUrl1;
/* function to identify doublebyte character */

function utf8StringByteCheck(UTF8String) {
	var str = String(UTF8String);
	var min=0x4e00;
	var max=0x9fa0;
	var fleadByteMin= 0x0081;
	var fleadByteMax= 0x9001;
	var karMin=0x00A0;
	var karMax=0x00DF;
	var sleadByteMin=0x00E0;
	var sleadByteMax=0x00EF;
	var byteSize = str.length;
	var oneByteMax = 0x007F;
	var twoByteMax = 0x07FF;
	
	if(document.getElementById('showMngText').value =='YES' ){
	
		for (i = 0; i < str.length; i++) {
			var hexval= str.charCodeAt(i);
			chr = str.charCodeAt(i);
			
			
			if (hexval > min && hexval < max  ) {
				document.getElementById('monoTextBox').value =""; 
			   	return false;
			}else if (hexval > fleadByteMin && hexval  < fleadByteMax) {
				document.getElementById('monoTextBox').value =""; 
				return false;
			} else if ( hexval > karMin && hexval < karMax){		
				document.getElementById('monoTextBox').value =""; 
				return false;
			} else if (hexval  > sleadByteMin && hexval  < sleadByteMax) {
				document.getElementById('monoTextBox').value =""; 
				return false;
			} else if (hexval > oneByteMax && hexval < twoByteMax) {
				document.getElementById('monoTextBox').value =""; 
				return false;
			}
				
		}
	}	
	return true;
} 

  
function getXMLObject(){  //XML OBJECT
		var xmlHttp = false;
   		try {
    		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")  // For Old Microsoft Browsers
   		}catch (e) {
    		try {
    			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")  // For Microsoft IE 6.0+
    		} catch (e2) {
    			xmlHttp = false   // No Browser accepts the XMLHTTP Object then false
    		}
   		}
   		if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
    		xmlHttp = new XMLHttpRequest();        //For Mozilla, Opera Browsers
   		}
   		return xmlHttp;  // Mandatory Statement returning the ajax object created
  }
  
  function getInputAddress() {
   // getting the zipcode 2210831
   var zipArray=new Array();
   var zip1 = document.getElementById("zipCode1").value ;
   var zip2 = document.getElementById("zipCode2").value ;
   
   /*zipArray = zip1.split("");
   var zipCode1 = "";
   for(i=0;i<zipArray.length;i++){
   	if(zipArray[i]=="0"){
   	  zipCode1 = zipCode1+"";
   	} else {
   	  zipCode1 = zipCode1+zipArray[i]; 
   	}
   }*/

   var zipcode = zip1 + zip2;
   
   if(zipcode==""){
	  var msg = document.getElementById("zipcodeNullErrortxt").value ;
	  //document.getElementById('zipcodeError').style.border='0px';
      //document.getElementById('zipcodeError').style.backgroundImage="url(../LEJStore/images/errorIcon.gif)";
      //document.getElementById('zipcodeError').style.backgroundColor='#c32a2b';
      //document.getElementById('zipcodeError').style.padding='10px 10px 10px 40px';
      //document.getElementById('zipcodeError').style.display='block';
      //document.getElementById('zipcodeError').style.color='#FFFFFF';
      
      //document.getElementById('zipcodeError').style.backgroundPosition='left';
      //document.getElementById('zipcodeError').style.backgroundRepeat='no-repeat';
      if (document.getElementById('ZipcodeNoExistError') !=null) {
      document.getElementById('ZipcodeNoExistError').style.color='#c32a2b';
      document.getElementById('ZipcodeNoExistError').innerHTML=msg;
      } else {
        document.getElementById('zipcodeError').style.color='#c32a2b';
      	document.getElementById('zipcodeError').innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+msg; 
      }
   } else if (zipcode.split("").length != 7) {
      var msg = document.getElementById("zipcodeLenErrortxt").value ;
	  //document.getElementById('zipcodeError').style.border='0px';
      //document.getElementById('zipcodeError').style.backgroundImage="url(../LEJStore/images/errorIcon.gif)";
      //document.getElementById('zipcodeError').style.backgroundColor='#c32a2b';
      //document.getElementById('zipcodeError').style.padding='10px 10px 10px 40px';
      //document.getElementById('zipcodeError').style.display='block';
      
      //document.getElementById('zipcodeError').style.backgroundPosition='left';
      //document.getElementById('zipcodeError').style.backgroundRepeat='no-repeat';
      if (document.getElementById('ZipcodeNoExistError') !=null) {
      document.getElementById('ZipcodeNoExistError').style.color='#c32a2b';
      document.getElementById('ZipcodeNoExistError').innerHTML=msg;
      } else {
      document.getElementById('zipcodeError').style.color='#c32a2b';
      document.getElementById('zipcodeError').innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+msg; 
      }
   } else {
	    xmlhttp = getXMLObject();
		if(xmlhttp) { 
			xmlhttp.open("POST", 'LEJInputAddressCmd', true); //getname will be the servlet name
		    xmlhttp.onreadystatechange  = getInputAddressStatus;
		    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		  
		   	var reqUrl = "zipCode="+zipcode;
		    xmlhttp.send(reqUrl);
		   	
		}
	}
}






function getInputAddressStatus() {
	
	if (xmlhttp.readyState == 4) {
     		if(xmlhttp.status == 200) {
     		   var response = xmlhttp.responseText;
          
               displayInputAddress(response);
              }
    }
}

function displayInputAddress(InputAddress) {
 	var respObject =  InputAddress;
	document.getElementById("inputAddress").innerHTML=InputAddress;
 
}

function uni2ent(snippet) {
   var uSnip = '';
   for (var c=0; c<snippet.length; c++) {
      var val = snippet.charCodeAt(c);
      
      if (val < 256) {
           
         uSnip += snippet.charAt(c);
      }
      else {
     
         uSnip += "&#" + val + ";"
      }
   }
 
   return uSnip;
}



function getMonogram(step) {
	monoStatusFlag = 1;
	checkStatusofCall();
    var reqUrl='';;
    var locationId;
    var monoType=''; 
    var styleTypeID='';
    var mngmStyleID='';
    var mngmStyleText='';  
    var embStyleText='';
    var embTypeID=''; 
    var monoTypeID='';
  	var monoText='';
    var colorID='';
    var colorText='';
    var updateStatus='';
    var locationGroupID='';
    var locationText='';
    var defaultLocationId='';
    var defaultColorId='';
    var paramText='';
    var monArray='';
    var embArray='';
    var embTempText='';
    var embMonoText='';
    var price='';
    mngmxmlhttp=null;
   	if(document.getElementById('currentStep').value=='set'){
    	
   	 return;
   	}else {
   	
   	}
   	
	if(document.getElementById('monocheckbox').checked==true){
	   
		mngmxmlhttp = getXMLObject(); 
  		if(mngmxmlhttp) {  		
	  		if(step=='cancel'){
	  			document.getElementById('monogramerror').innerHTML="";
    			document.getElementById('monogramerror').style.visibility = 'hidden';
				document.getElementById('locationText').value="";
				document.getElementById('mngmStyleText').value="";
				document.getElementById('retColorID').value="";
				document.getElementById('monoTypeID').value="";
				document.getElementById('locationID').value="";
				document.getElementById('price').value=="";
				document.getElementById('retText').value="";
				document.getElementById('retcolorText').value="";
				document.getElementById('MonogramSelected').value=0;
				document.getElementById('monocheckbox').checked=false;
				document.getElementById('monoUpdateStatus').value="";
				document.getElementById('CheckStatus')=="";
				document.getElementById('monogram').innerHTML="";
				document.getElementById('currentStep').value="Unset" ;
				
				monoStatusFlag = 0;
				checkStatusofCall();
				getProductPriceTotal();
				return;
			}
			
			locationGroupID=document.getElementById('locationGroupID').value;
			
  	    	if( step=="Update"){
  	    	   
				var selectedMngrOption = document.getElementById('monogramOptionId').value;	
  	 	       	defaultLocationId=document.getElementById('defaultLocationId').value;
  	 	        locationId =		document.getElementById('locationID').value  ;
  	            document.getElementById('monoUpdateStatus').value='Update';
  	            updateStatus= document.getElementById('monoUpdateStatus').value;
  	           
  	            /* clear th emonogram selected value*/
  	            reqUrl="locationID="+locationId+"&status="+updateStatus+"&locationGroupID="+locationGroupID+"&dlocID="+defaultLocationId+"&monogramOptionId="+selectedMngrOption;    	    			    
  	 	      	step="step1";
  	       	 }else {
   	        	  
   	        	  updateStatus= document.getElementById('monoUpdateStatus').value;
   	        	  
		  	       if(step=="step1"){		  	       	  	       		    	    	


		    	    	defaultLocationId=document.getElementById('defaultLocationId').value;	    	  
		  	 	      	reqUrl="locationID="+document.getElementById('locationID').value+"&status="+updateStatus+"&locationGroupID="+locationGroupID+"&dlocID="+defaultLocationId; 
		  	 	      	
				   	} else if(step=="step2"){				   	
      
		     					     			
		     			locationId=  document.getElementById('locationID').value;
		     					     			
		     			var radio = document.getElementsByName("mngrOptionRadio");	 
 						var selectedMngrOption;
 						var status = "false";
		         		for (var i=0; i<radio.length; i++)  {

		        			if (radio[i].checked)  {
		        				selectedMngrOption = radio[i].value;
		        				status = "true";
		           				break;
		           				
		           				
		           			}             			
		      		   	}		     			
		     			
	     		  		if(status!="true"){

	     		  			document.getElementById('monogramerror').style.visibility = 'visible'; 
	 	      		        document.getElementById('monogramerror').innerHTML=document.getElementById('VmonogramError').value;
	     		  			return;
	     		  		}
	     		  		
	     		  		defaultLocationId=document.getElementById('defaultLocationId').value;	
	     		  		
					    param_array = selectedMngrOption.split(",");	         
				        document.getElementById('monogramOptionId').value= param_array[0];
				        document.getElementById('showMngColor').value= param_array[1];
				        document.getElementById('showMngText').value= param_array[2];
				        
				        monoTypeID = document.getElementById('monoTypeID').value;				   		
		           		reqUrl="locationID="+locationId+"&status="+updateStatus+"&monogramTypeId="+monoTypeID+"&locationGroupID="+locationGroupID+"&locLength="+lengthLocation+"&monogramOptionId="+param_array[0]+"&dlocID="+defaultLocationId; 		           		
		           		
		    		}else if(step=="rstep1"){
		    		
		    			document.getElementById('monogramerror').innerHTML=="" ; 
		    			document.getElementById('monogramerror').style.visibility = 'hidden';	
		      		   	
		      		   	var num;	    
				        var locationObj = document.getElementById('selectMonogramlocation');
				        num =  locationObj.selectedIndex;
				        paramText=locationObj[num].value;
					    param_array= paramText.split(",");	         
				        document.getElementById('locationID').value= param_array[0];
				        document.getElementById('locationLength').value= param_array[1];
				        
		      		   	
		      		   	defaultLocationId=document.getElementById('defaultLocationId').value;	  
						var selectedMngrOption = document.getElementById('monogramOptionId').value;	
						
															
		    		    
		    		    reqUrl="locationID="+document.getElementById('locationID').value+"&status="+updateStatus+"&locationGroupID="+locationGroupID+"&dlocID="+defaultLocationId+"&monogramOptionId="+selectedMngrOption;    	    			
		    			
		    			
		    			step="step1"; 	
		    			 	
		    			 			    			 	
		    		}else if(step=="step3"){ /* to set the monogram TYPE */
		    		 	//alert("reaching here");	    		 
 		    		   var selectedMngrType = document.getElementById('monogramOptionId').value;
	    		       document.getElementById('monogramerror').innerHTML==""; 
	    		       document.getElementById('monogramerror').style.visibility = 'hidden';  
	    		       	      				
	      		 		/*added by joys*/
	      		 		
	      		 		var locationObj = document.getElementById('selectMonogramlocation');
				        num =  locationObj.selectedIndex;
				        paramText=locationObj[num].value;
					    param_array= paramText.split(",");	         
				        document.getElementById('locationID').value= param_array[0];
				        document.getElementById('locationLength').value= param_array[1];
				        var lengthLocation=param_array[1];			        
				      	locationId= param_array[0];
				        document.getElementById('locationText').value=locationObj[num].text;
				        
			       		defaultColorId=document.getElementById('defaultColorId').value;		
					
						colorID = document.getElementById('retColorID').value;
						
						monoText = document.getElementById('retText').value;																		

						
						//alert("1" + document.getElementById('monogramOptionId').value);
				        //alert("2" + document.getElementById('showMngColor').value);
				        //alert("3" + document.getElementById('showMngText').value);		
				        
				        var showMonoColor = document.getElementById('showMngColor').value;
				        var showMonoText = document.getElementById('showMngText').value;
				        
						//alert("showMonoColor" + showMonoColor);
						//alert("showMonoText" + showMonoText);
						
	            	    reqUrl="locationID="+locationId+"&status="+updateStatus+"&styleID="+ document.getElementById('monoTypeID').value+"&text="+encodeURIComponent(uni2ent(monoText))+"&colorID="+colorID+"&dcolID="+defaultColorId+"&locLength="+document.getElementById('locationLength').value+"&monogramOptionId="+selectedMngrType
	            	    +"&showMonoColor="+showMonoColor+"&showMonoText="+showMonoText; 
	    	       
	    	        }else if(step=="rstep2"){
	    	        	
	    	        	
	    	        	var showMonoColor = document.getElementById('showMngColor').value;
				        var showMonoText = document.getElementById('showMngText').value;
				            	        
	    	      		locationId = document.getElementById('locationID').value;	    	      		
	    	      		monoType = document.getElementById('monoTypeID').value;         	
		            
		            	defaultLocationId = document.getElementById('defaultLocationId').value;	
		            	
		            	var selectMonoObj = document.getElementById('styleMono');
					    var num1;
					    num1=selectMonoObj.selectedIndex;	
					                
					    monoTempText=selectMonoObj[num1].value; 			    	   						    	   		              	  
					    monoArray= monoTempText.split(",");	
					    monoTypeID=monoArray[0];
					    mngmStyleText = monoArray[1];					     
					     
					      
					      
						if(mngmStyleText!='Please Select'){
							var tempPrice=monoArray[2].split(".");
							price=tempPrice[0];
							document.getElementById('price').value= price;
							defaultColorId=document.getElementById('defaultColorId').value;	
						
						}
						
						
						
						document.getElementById('monoTypeID').value = monoTypeID;
						document.getElementById('locationID').value= locationId;
							
						if(showMonoColor == "YES") {						
							colorID = document.getElementById('monocolor').value;												
							document.getElementById('retColorID').value=colorID;
						}else{
							document.getElementById('retColorID').value="";
						}
						if(showMonoText == "YES") {	
							monoText = document.getElementById('monoTextBox').value;
							document.getElementById('retText').value = monoText;  
						}else {
							document.getElementById('retText').value = monoText;  
						}
						
						document.getElementById('mngmStyleText').value = mngmStyleText;
						
						//alert("showMonoColor" + showMonoColor);
						//alert("showMonoText" + showMonoText);
						            	
		    	   		reqUrl="locationID="+locationId+"&status="+updateStatus+"&monogramTypeId="+monoTypeID+"&locationGroupID="+locationGroupID+"&embTypeID="+embTypeID+"&dcolID="+defaultColorId+"&locLength="+document.getElementById('locationLength').value+"&monogramOptionId="+document.getElementById('monogramOptionId').value+"&dlocID="+defaultLocationId;;
		    	    	step = "step2";
	    	    	
	    	    	
	    	    	} else if(step=="step4"){
					
						var showMonoColor = document.getElementById('showMngColor').value;
				        var showMonoText = document.getElementById('showMngText').value;
				        
				        //alert("showMonoColor" + showMonoColor);
						//alert("showMonoText" + showMonoText);
				        
		    	        document.getElementById('monogramerror').innerHTML==""; 
		    		    document.getElementById('monogramerror').style.visibility = 'hidden';						
						
						
						
						 var selectMonoObj = document.getElementById('styleMono');
					     var num1;
					     num1=selectMonoObj.selectedIndex;	
					                
					     monoTempText=selectMonoObj[num1].value; 			    	   						    	   		              	  
					     monoArray= monoTempText.split(",");	
					     monoTypeID=monoArray[0];
					     mngmStyleText = monoArray[1];
					     
					      if(mngmStyleText=='Please Select'){
						  	document.getElementById('monogramerror').style.visibility = 'visible'; 
				      		document.getElementById('monogramerror').innerHTML=document.getElementById('Vembroideryerror').value;
				      		return;
					      } 
					      
					      if(mngmStyleText==''){
			      		        document.getElementById('monogramerror').style.visibility = 'visible'; 
			      		     	document.getElementById('monogramerror').innerHTML=document.getElementById('Vmonogramerror').value;
		      		     	  return;
		      		      }
					       
						 monoType = document.getElementById('styleMono').value			
						

	    	       		if(monoType!='') {	    	     
	    	       			
	    	       			locationId=document.getElementById('locationID').value ;
	    	       			
	    	       			if(showMonoColor == "YES") {	 
			    	           	var colorObj=document.getElementById('monocolor');
					        	var colornum=colorObj.selectedIndex;
					           	document.getElementById('retcolorText').value=colorObj[colornum].text;				        	      	  				    	    		
			    	    		colorID=document.getElementById('monocolor').value;
			    	    		document.getElementById('retColorID').value=colorID;
			    	    		colorText=document.getElementById('retcolorText').value;
		    	    		}else{
		    	    			document.getElementById('retcolorText').value ="";
		    	    			document.getElementById('retColorID').value ="";
		    	    		}
		    	    		
		    	    		if(showMonoText == "YES") {	
		    	    		
			    	    		monoText=document.getElementById('monoTextBox').value ; 
	
			    	    		if(!utf8StringByteCheck(monoText)|| trim(monoText)=="") {
			    	    		    document.getElementById('monogramerror').style.visibility = 'visible'; 
				      		     	document.getElementById('monogramerror').innerHTML=document.getElementById('Vtexterror').value;
			    	    			return;
			    	    		}			    	    		
			    	    		
			    	    		
			    	    		monoText=document.getElementById('monoTextBox').value;
								document.getElementById('retText').value=monoText; 
								
							}else{
								document.getElementById('retText').value = "";
							}
									     		
		    			   
		      		       			
		    	    	  
	    			       var tempPrice = monoArray[2].split(".");
	    			       
				           var price = tempPrice[0];	            
						   
						   var length  = monoArray[3];	
						   
				           //alert("price" + price);
				           //alert("length" + length);       
		            		
											            
		      		       	document.getElementById('price').value= price;
		      		       	document.getElementById('monoTypeID').value=monoTypeID;
		      		       	document.getElementById('mngmStyleText').value=mngmStyleText;                 

	            	}	            
	            	
	            	document.getElementById('monogramerror').innerHTML="";
	    	        document.getElementById('monogramerror').style.visibility = 'hidden';
	            	
	            	locationId=document.getElementById('locationID').value ;
	            	locationText=document.getElementById('locationText').value; 
	            	
					

	         	     document.getElementById('MonogramSelected').value=1;
	         	     
	  	   	   	     reqUrl="colorID="+colorID+"&styleID="+monoTypeID+"&text="+encodeURIComponent(uni2ent(monoText))+"&monogramOptionId="+document.getElementById('monogramOptionId').value+"&locationID="+locationId
	  	   	   	     		+"&status="+updateStatus+"&eText="+encodeURIComponent(uni2ent(embStyleText))+"&mText="+encodeURIComponent(uni2ent(mngmStyleText))+"&locText="+encodeURIComponent(uni2ent(locationText))+"&colText="+encodeURIComponent(uni2ent(colorText))+"&price="+price+"&showMonoColor="+showMonoColor+"&showMonoText="+showMonoText; 
	    	    }
	    	     
	    		} 
	    	 document.getElementById('monoUpdateStatus').value="";
	    	 document.getElementById('MonogramSelected').value=1; 	 	
	    	 document.getElementById('monogramerror').innerHTML="";
    	     document.getElementById('monogramerror').style.visibility = 'hidden';
    	  	 mngmxmlhttp.open("POST", 'LEJProductMonogramDisplayCmd', true); 
	         mngmxmlhttp.onreadystatechange  = getMonogramStatus;
	         mngmxmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	         var free = document.getElementById('monogramFree').value;
	         
	         reqUrl = reqUrl+"&position="+step+"&free="+free;
	         reqUrl1=reqUrl;
			 //alert("reqUrl" + reqUrl);  
			 //alert("step " + step);
			 
			
	         mngmxmlhttp.send(reqUrl);        
	         

			 
 	    	}else {
 	           /* else for xmlhttp*/
 	    	
 	    	}
       }else { /* else for monogram checked*/
         	    monoStatusFlag = 0;
		        checkStatusofCall();
		        document.getElementById('monogramerror').innerHTML="";
    			document.getElementById('monogramerror').style.visibility = 'hidden';
                document.getElementById('monogram').innerHTML="";
       		    document.getElementById('locationText').value="";

				document.getElementById('mngmStyleText').value="";
				document.getElementById('retColorID').value="";
				document.getElementById('monoTypeID').value="";
				document.getElementById('locationID').value="";				
				document.getElementById('retText').value="";
				document.getElementById('retcolorText').value="";
				document.getElementById('MonogramSelected').value=0;
				document.getElementById('monocheckbox').checked=false;
				document.getElementById('monoUpdateStatus').value="";
				document.getElementById('CheckStatus')=="";
				document.getElementById('showMngColor').value =="";
				document.getElementById('showMngText').value =="";
				getProductPriceTotal();
				
       }
    	
   }
   
   
   	function getMonogramStatus() {
   
		if (mngmxmlhttp.readyState != 4) {
              document.getElementById('monogram').innerHTML='<img src="/wcsstore/LEJStore/images/wait.gif"" border="0">';
            }
          
		if (mngmxmlhttp.readyState == 4) {
     		if(mngmxmlhttp.status == 200) {
     		   var response = mngmxmlhttp.responseText;
               displayMonogram(response);
               monoStatusFlag =0;
			   checkStatusofCall();
			   getProductPriceTotal();
              }else if(mngmxmlhttp.status == 404){
               	 mngmxmlhttp.open("POST", 'LEJProductMonogramDisplayCmd', true); 
	        	 mngmxmlhttp.onreadystatechange  = getMonogramStatus;
	        	 mngmxmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
              	 mngmxmlhttp.send(reqUrl1);   
              }
              
             
   		 }
	}  
  


function getLength(){

 	var selectMonoObj=document.getElementById('styleMono');
    var num1;
    var length;
    num1=selectMonoObj.selectedIndex;	         
    var monoTempText=selectMonoObj[num1].value;
    var monoArray= monoTempText.split(",");	 
    var  mngmStyleText=monoArray[1];
    
	if(mngmStyleText=='Please Select') {
		length=10 ;
	}else {				             		    	   						    	   		              	  
    	length = monoArray[3];
    }
	document.getElementById('monogramerror').innerHTML="";
    document.getElementById('monogramerror').style.visibility = 'hidden';
	var monotext='';
	try{
		document.getElementById('maxlength').innerHTML=length;
	}catch(e){
	
		var spanElement=document.getElementById('maxlength');
		var wrappingElement = document.createElement('div');
	    wrappingElement.innerHTML = length;
	      
		if(spanElement!=null){
			spanElement.innerHTML="";
			spanElement.appendChild(wrappingElement);
	    }

	}
	
	if(document.getElementById("monoTextBox")==null){
		
	}else{
		monotext = document.getElementById('monoTextBox').value;
	}
	
	try{
	
		document.getElementById('drawmonotextbox').innerHTML='<input name="monoTextBox" id="monoTextBox" type="text" size="20" maxlength="'+length+' value="'+monotext+'"/>'
		document.getElementById('monoTextBox').value=monotext.substr(0,length);
	
	}catch(e){
	
		var spanElement=document.getElementById('drawmonotextbox');
		var wrappingElement = document.createElement('div');
	    wrappingElement.innerHTML = '<input name="monoTextBox" id="monoTextBox" type="text" size="20" maxlength="'+length+' value="'+monotext+'"/>';
	       
		if(spanElement!=null){
			spanElement.innerHTML="";
			 spanElement.appendChild(wrappingElement);
	        document.getElementById('monoTextBox').value=monotext.substr(0,length);
        }
		
	}

}   
    
    

function getMonogramEmbroideryStatus() {
     document.getElementById('currentStep').value="set";	
      
	if (embxmlhttp.readyState != 4) {
			  		
	       document.getElementById('monogramholder').innerHTML='<img src="/wcsstore/LEJStore/images/wait.gif"" border="0">';
      	
       }
	if (embxmlhttp.readyState == 4) {
	 
    	if(embxmlhttp.status == 200) {
     		var response = embxmlhttp.responseText;
     		
                try{
            	document.getElementById('monogramholder').innerHTML="";
				document.getElementById('monogramholder').innerHTML=response;
				}catch(e){
					var spanElement=document.getElementById('monogramholder');
					spanElement.innerHTML="";
					var wrappingElement = document.createElement('div');
        			wrappingElement.innerHTML = response;
       				spanElement.appendChild(wrappingElement);
       				
				}
				 document.getElementById('currentStep').value="Unset";	
				 monoListStatusFlag = 0;
				 checkStatusofCall();
    }
  }  
}


function displayMonogram(monogramResponse) {

	var respObject =  monogramResponse;
	try {
	
		document.getElementById('monogram').innerHTML="";
		document.getElementById('monogram').innerHTML=monogramResponse;
		
	}catch(e){
	
		var spanElement=document.getElementById('monogram');
		spanElement.innerHTML="";
		var wrappingElement = document.createElement('div');
        wrappingElement.innerHTML = monogramResponse;
        spanElement.appendChild(wrappingElement);

	}

}






  
  