function GetBadge(){
	// if file indicated by user doesn't exist, return "blank" file to flash variable, to make the movie still work
	var retVal;
	var obj=myGetElementById('txtBadgeNbr');
	var badge=obj.value.trim();
	var base = GetBase();
	if (base=='') base='blank';
	if (FileExists("./FLASH/" + badge + "_" + base+".png")){
		retVal= badge;}
	else{
		retVal= 'NOTAVLBL';}
	//alert(retVal);
	return retVal;
}


function GetBase(){
	var obj;
	obj=myGetElementById('ddlFinish');
	var myindex  = obj.selectedIndex;
	var sFinish = obj[myindex].value;
	var mBase;
	switch (sFinish){
		case 'GOLD ELECTROPLATE':
			mBase = 'gold';
			break;
		case 'NICKEL ELECTROPLATE':
			mBase = 'silver';
			break;
		case 'RHODIUM ELECTROPLATE':
			mBase = 'silver';
			break;
		case 'SIL-RAY':
			mBase = 'silver';
			break;
		case 'GOL-RAY W/SIL-RAY PANELS':
			mBase='song';
			break;
		case 'SIL-RAY W/GOL-RAY PANELS':
			mBase='gons';
			break;
		default:
			mBase = 'gold';
	}

	//alert(mBase);
	return mBase;
}


function GetSeal(){
	// if file indicated by user doesn't exist, return "blank" file to flash variable, to make the movie still work
	var retVal= 'NOTAVLBLM';
	var obj=myGetElementById('txtCenter');
	if (obj==null){
		return '';
	}

	var seal=obj.value.trim().toUpperCase();
	var type = GetSealType();

	if (type=='') type='M';

	if (FileExists("./FLASH/" + seal + type+".png")){
		retVal=seal+type;
		}
	else{
		if (FileExists("./FLASH/" + seal + ".png")){
		retVal= seal;
		} else {
			retVal= 'NOTAVLBLM';
		}

        }

	if (seal=='' || seal=='-CLICK TO SEARCH-') retVal='BLANK' + type;
	//alert(retVal);

	return retVal;
}


function GetSealType(){
	var obj;
	obj=myGetElementById('ddlSealType');
	var myindex  = obj.selectedIndex;
	var sType = obj[myindex].value;

	return GetSealTypeByName(sType);
}


function ClickDropship(){
	//empty textboxes if un-checked
	var obj;
	obj=myGetElementById('chkDropship');
	if (obj.checked==false) {
		obj=myGetElementById("txtDropName");
		obj.value="";
		obj = myGetElementById("txtDropContact");
		obj.value='';
		obj = myGetElementById("txtDropAddress1");
		obj.value='';
		obj = myGetElementById("txtDropAddress2");
		obj.value='';
		obj = myGetElementById("txtDropCity");
		obj.value='';
		obj = myGetElementById("txtDropState")
		obj.value='';
		obj = myGetElementById("txtDropZip");
		obj.value='';
	}

	showhide('dropship_fields');
} //end func ClickDropship

function OpenDropshipHistory(){
    var WinSettings = "height=400,width=700";
    
    sList=window.open("DropShipAddress.aspx","list",WinSettings);


} //end funct OpenDropshipHistory

function OrderEntryOnLoad(){
	if (myGetElementById){
		//setupEnterAsTab(); -> not working too well
		var obj, obj2;
		// show/hide dropship fields depending of checkbox value (saved in session)
		obj = myGetElementById("dropship_fields");
		obj2=myGetElementById("hidDisplayDropship");
		obj.style.display = obj2.value;

		//show dropship button only if previous records exists in the database
		obj = myGetElementById("btnDropshipHist");
		obj2=myGetElementById("hidDisplayDropshipHistButton");
		obj.style.display = obj2.value;

		RefreshLayout();
        RefreshLeatherPic();

		}//endif myGetElementById

} //end func OrderEntryOnLoad


function SearchSeal(aff) {
    var url = "SearchSeal.aspx";
    if (aff) {
        url = url + "?aff=" + aff;
    }
        window.open(url, "SearchSeal", "height=550,width=800,status=1,scrollbars=yes");
}  // end func SearchSeal

function SearchLeather(){
	window.open ("SearchSeal.aspx?t=L","SearchLeather","height=550,width=800,status=1,scrollbars=yes");
}  // end func SearchSeal

function RefreshTotalPrice(){
	if (myGetElementById){
		var obj;
		var nPU, nPT, nQ, cQ, nRP, nBP, nSP, nEP, nL, val;
		obj=myGetElementById("txtBaseCost");
		val=obj.value;
		nRP=(val=='' ? 0 : parseFloat(CurrencyToNumber(val)));

		obj=myGetElementById("txtBackCost");
		val=obj.value;
		nBP=(val=='' ? 0 : parseFloat(CurrencyToNumber(val)));

		obj=myGetElementById("txtSealCost");
		val=obj.value;
		nSP=(val=='' ? 0 : parseFloat(CurrencyToNumber(val)));

		obj=myGetElementById("txtEnamelCost");
		val=obj.value;
		nEP=(val=='' ? 0 : parseFloat(CurrencyToNumber(val)));

        nL=0;
        obj=myGetElementById("txtLeatherCost");
        if (obj){
		    val=obj.value;
		    nL=(val=='' ? 0 : parseFloat(CurrencyToNumber(val)));
        }

		nPU=nRP+nBP+nSP+nEP+nL;

		obj=myGetElementById("txtPricePerUnit");
		obj.value="$" + nPU.toFixed(2);
		
		obj=myGetElementById("txtQty");
		cQ=obj.value;
		obj=myGetElementById("txtCostQty");
		obj.value=cQ;
		nQ = parseInt((cQ=='')?'0':cQ);
		nPT = nQ*nPU;
		obj=myGetElementById("txtPriceTotal");
		obj.value="$" + nPT.toFixed(2);
		obj=myGetElementById("lblMultiplyByQty");
		if (obj) obj.innerText=(nQ==0)?'':'X';

	} //endif myGetElementById
}// end function RefreshTotalPrice


function RefreshPrice(){

	var url='OrderEntryRefresh.aspx?refresh=price';
	var obj;

	obj=myGetElementById('txtBadgeNbr');
	url+= '&b=' + obj.value;

	obj=myGetElementById("ddlBack");
	if (obj) {
		url+= '&bck=' + obj[obj.selectedIndex].value;
	}

	obj=myGetElementById("ddlFinish");
	url+= '&f=' + obj[obj.selectedIndex].value;

    
	obj=myGetElementById("ddlSealType");
	//url+= '&s=' + GetSealType();
	var sealType=(obj.style.display=='none' ? "PLAIN" : obj[obj.selectedIndex].value);
	url+= '&s=' + sealType;

	obj=myGetElementById("ddlLetterType");
	url+= '&e=' + obj[obj.selectedIndex].value;

    obj=myGetElementById("ddlLeather");
    if (obj){
	    url+= '&l=' + obj[obj.selectedIndex].value;
	}
	xmlhttp=null;
	wrapXMLHTTPRequest(url, 'RefreshPrice_Ready');
} //end func RefreshPrice


function RefreshPrice_Ready(){

	if (xmlhttp.readyState==4)
		{// 4 = "loaded"
		
		if (xmlhttp.status==200)
			{// 200 = "OK"
			//alert(xmlhttp.responseText);
			//responseText is in the form: RP#BP#SP#EP (retail, back, seal, enamel prices)
			var prices=xmlhttp.responseText.split("#",5);
			var RP, BP, SP, EP, L, str, obj;
			RP=(prices[0]=='' ? 0.00 : parseFloat(prices[0]));
			BP=(prices[1]=='' ? 0.00 : parseFloat(prices[1]));
			SP=(prices[2]=='' ? 0.00 : parseFloat(prices[2]));
			EP=(prices[3]=='' ? 0.00 : parseFloat(prices[3]));
            L=(prices[4]=='' ? 0.00 : parseFloat(prices[4]));
    
			obj=myGetElementById('txtBaseCost');
			obj.value="$" + RP.toFixed(2);
   
			obj=myGetElementById("ddlBack");
			str=obj[obj.selectedIndex].value;
			obj=myGetElementById('txtBackCostDesc');
			obj.value=((BP==0) ? '' : str + ' BACK'); 
			obj=myGetElementById('txtBackCost');
			obj.value=((BP==0) ? '' :"$" + BP.toFixed(2)) ;
   
			obj=myGetElementById("ddlSealType");
			str=obj[obj.selectedIndex].value;
			obj=myGetElementById('txtSealCostDesc');
			obj.value=((SP==0) ? '' : str + ' SEAL'); 
			obj=myGetElementById('txtSealCost');
			obj.value=((SP==0) ? '' :"$" + SP.toFixed(2));

			obj = myGetElementById("ddlLetterType");
			if (obj) {
			    str = obj[obj.selectedIndex].value.trim();
			}
			obj=myGetElementById('txtEnamelCostDesc');
			obj.value=((EP==0) ? '' : str + ' ENAMEL'); 
			obj=myGetElementById('txtEnamelCost');
			obj.value=((EP==0) ? '' :"$" + EP.toFixed(2));

			obj=myGetElementById('txtLeatherCostDesc');
			if (obj){
			    obj.value=((L==0) ? '' : 'LEATHER ACCESSORY'); 
                obj=myGetElementById('txtLeatherCost');
			    obj.value=((L==0) ? '' :"$" + L.toFixed(2));
			}
			RefreshTotalPrice();
		}
	else
		{
		//alert("Problem retrieving data:" + xmlhttp.statusText);
		}
	}
	
}//end func RefreshPrice_Ready


function ShowControls(strControls, bShow){
	var arControls=strControls.split(",");
	for (var i=0; i<arControls.length; i++) {
		obj=myGetElementById(arControls[i]);
		if (obj!=null){
			obj.style.display=(bShow ? "":"none");
		} //end if obj!=null
		} //end for 
}  // end function ShowControls



function RefreshLayout(){
	var url='OrderEntryRefresh.aspx?refresh=laysize';
	var obj=myGetElementById('txtBadgeNbr');
	url+= '&b=' + obj.value;
	xmlhttp=null;
	wrapXMLHTTPRequest(url, 'RefreshLayout_Ready');

} //end function RefreshLayout

function RefreshLayout_Ready(){
	if (xmlhttp.readyState==4)
		{// 4 = "loaded"
		
		if (xmlhttp.status==200)
			{// 200 = "OK"
			//alert(xmlhttp.responseText);
			//responseText is a string of 1 and 0s, each representing the fact that corresponding control is visible or not
			//order: line1..6, back, center
			// and then semicolon, width, semicolon, height
			var response=xmlhttp.responseText;
			
			var result1=response.split(";",3);
			
			//size
			obj=myGetElementById("txtBadgeSize");
			
			if (obj){
				if (parseFloat(result1[1])>0 && parseFloat(result1[2])>0)
					obj.value="Dimensions (w x h):     " + result1[1] + "'' X " + result1[2] +"''";
				if (parseFloat(result1[1])==0 && parseFloat(result1[2])>0)
					obj.value="Dimension (h):     " + result1[2] + "''";
				if (parseFloat(result1[1])>0 && parseFloat(result1[2])==0)
					obj.value="Dimension (w):     " + result1[1] + "''";
				if (parseFloat(result1[1])==0 && parseFloat(result1[2])==0)
					obj.value="";
			}
			
			
			//lines
			var result=result1[0].split("",8);
			var controls1='';  //will store the name of controls wich must be made visible (separated by comma)
			var controls0='';  //will store the name of controls wich must be made invisible (separated by comma)
			var obj;
   
			//lines
			var j=0;   // re-number lines labels
			for (var i=1;i<=6;i++){
				eval('controls' + result[i-1] + '+="lblLine' + i + ',txtLine' + i +',"');
				if (result[i-1]=='0') {
					obj=myGetElementById('txtLine' +i);
					obj.value='';
				} else {
					j = j + 1;
					obj=myGetElementById('lblLine' +i);
					if (obj) {
	                    if (document.all) {
					        obj.innerText = 'LINE ' + j;
					        } else {
					        obj.textContent = 'LINE ' + j;
					        }
					    }
				}
				
				
			}
			//no font if no lines
			if (response.substring(0,6)=='000000') {
				controls0+= 'lblFont,ddlFont,';
			}
			else {
				controls1+= 'lblFont,ddlFont,';
			}
 
			//back
			eval('controls' + result[6] + '+="lblBack,ddlBack,"');
			// emptyback if no back
			if (result[6]=='0'){
				obj=myGetElementById('ddlBack');
				if (obj!=null) {obj.value='';}
			}

			
			//center
			eval('controls' + result[7] + '+="lblCenter,txtCenter,lblSealType,ddlSealType,hSearchSeal"');
			
			
			//empty seal values if no seal
			if (result[7]=='0'){
				obj=myGetElementById('txtCenter');
				if (obj!=null) {obj.value='';}
			}
   
			ShowControls(controls1,true);
			ShowControls(controls0,false);

			

			//refresh validators
			OrderEntryValidators();
			
			//layouts should be refreshed when changing badge number, therefore we need to refresh everything else
			SetDefaultValues();
			RefreshCatalogImageLink();
			
			RefreshBadgeNote();
			RefreshPrice();
			BuildFlash();
			
		}
	else
		{
		//alert("Problem retrieving data:" + xmlhttp.statusText);
		}
	}
}// end function RefreshLayout_Ready


function RefreshCatalogImageLink(){
	var h='';
	var strCheck=new Array(3);
	var obj=myGetElementById('txtBadgeNbr');
	
	strBadge=obj.value;
	
	strCheck[0] = "IMAGES/" + strBadge + ".jpg";
	strCheck[1] = "IMAGES/" + strBadge.toUpperCase() + ".jpg";
	strCheck[2] = "IMAGES/" + strBadge.toLowerCase() + ".jpg";
		
	if (strBadge=='') {
		h=''
	}else {

		for (var i=0;i<3;i++){
		  if (FileExists(strCheck[i])){
			h=strCheck[i];
			break;
		  }//end if fileexists

		}//end for

	}//end if

	
	if (h==''){
		ShowControls('linkSample',false);
	}else{
	  obj=myGetElementById('linkSample');
	  if (obj){
	  	  obj.href=h;
	      ShowControls('linkSample',true);
	     }
	}

	
} //end function RefreshCatalogImageLink

function BuildFlash(){

    UCaseAll();
    
	var mFont='sans';
	var mColor="black";
	var sBadgeStyle=GetBadge();
	var mBase=GetBase();
	var	obj=myGetElementById("ddlFont");
	if (obj!=null){
		mFont=obj[obj.selectedIndex].value.trim();
		mFont=(mFont=='ROMAN'?'roman':'block');
		}
	obj=myGetElementById('ddlColor');
	if (obj!=null){
		mColor=obj==null?'black':obj.value.trim().toLowerCase();
		}
	for (var i=1;i<=6;i++){
		obj=myGetElementById('txtLine' + i);
		eval('t'+i +'=obj==null? "": obj.value.trim()');
		}
	SealStr=GetSeal();
	url="Badge.swf?badge=" + sBadgeStyle + "&base=" + mBase + "&textfont=" + mFont + "&textcolor=" + mColor + "&text1=" + urlencode(t1) + "&text2=" +urlencode(t2) + "&text3=" + urlencode(t3) + "&text4=" + urlencode(t4) + "&text5=" + urlencode(t5) + "&text6=" + urlencode(t6) + "&seal=" + SealStr + "&refresh=1&basePath=Flash/";
	debug(url);
	//alert(url);
	obj=myGetElementById('AiFlashIn1');
	//if(myGetElementById('AIFlashIn1_mozilla') != undefined) obj=myGetElementById('1_mozilla')
	//else obj=myGetElementById('1');
//obj=getFlashMovieObject("1");
	//	obj.movie=url;

setFlash(url);	
	
} //end func BuildFlash

function SetDefaultValues(){
	//default back: SHELL
	var obj=myGetElementById('ddlBack');
	if (obj.style.display!='none' && obj.value.trim()==''){
	 obj.value='SHELL';
	}
	
	//default enamel: SOFT (REGULAR)
	obj=myGetElementById('ddlLetterType');
	if (obj.style.display!='none' && obj.value.trim()==''){
	 obj.value='SOFT (REGULAR)';
	}
	
	//default letter color: BLACK
	obj=myGetElementById('ddlColor');
	if (obj.style.display!='none' && obj.value.trim()==''){
	 obj.value='BLACK';
	}
	
	//default font:BLOCK
	obj=myGetElementById('ddlFont');
	if (obj.style.display!='none' && obj.value.trim()==''){
	 obj.value='BLOCK';
	}
} //end func SetDefaultValues

function RefreshDefaultShape(){
	var url='OrderEntryRefresh.aspx?refresh=defshape';
	var obj=myGetElementById('ddlAttachment');
	url+= '&att=' + encodeURIComponent(obj.value.trim());

	xmlhttp=null;
	wrapXMLHTTPRequest(url, 'RefreshDefaultShape_Ready');

} //end function RefreshDefaultShape

function RefreshDefaultShape_Ready(){
	if (xmlhttp.readyState==4)
		{// 4 = "loaded"
		if (xmlhttp.status==200)
			{// 200 = "OK"
			//alert(xmlhttp.responseText);
			var shape=xmlhttp.responseText.trim();
			obj=myGetElementById('ddlShape');
			obj.value=shape;
       }
	else
		{
		//alert("Problem retrieving data:" + xmlhttp.statusText);
		}
	}
} //end func RefreshDefaultShape_Ready()


function debug(str){
return;
  var obj=myGetElementById('lblDebug');
  obj.innerHTML=str;
  
} //end func debug



function urlencode(str) {
return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}



function OrderEntryValidators(){

    //no validation on buildbadge page
    var obj=myGetElementById("NOVALIDATION");
    if (obj) {
        //nothing, terminate function
        return;
    }    
    
 	    frmvalidator = new Validator(document.forms[0].name);
 	    frmvalidator.clearAllValidations(); 
	    frmvalidator.EnableMsgsTogether();



 
 obj=myGetElementById("txtBadgeNbr");
 if (obj!=null){
	if (obj.style.display!='none'){
		frmvalidator.addValidation("txtBadgeNbr","req","Please enter a Badge Number");
		}
	}
	
 obj=myGetElementById("txtQty");
 if (obj!=null){
	if (obj.style.display!='none'){
		frmvalidator.addValidation("txtQty","req","Please enter the Quantity");
		frmvalidator.addValidation("txtQty","numeric","Please enter a valid Quantity");
		}
	}
 
 obj=myGetElementById("ddlBack");
  if (obj!=null){
	if (obj.style.display!='none'){
		frmvalidator.addValidation("ddlBack","dontselect=0","Please select Badge Back");
		}
	}
 
 obj=myGetElementById("ddlFinish");
 if (obj!=null){
	if (obj.style.display!='none'){
		frmvalidator.addValidation("ddlFinish","dontselect=0","Please select Badge Finish");
		}
	}
 
 obj=myGetElementById("ddlFont");
 if (obj!=null){
	if (obj.style.display!='none'){
		frmvalidator.addValidation("ddlFont","dontselect=0","Please select Badge Font");
		}
	}
	
obj=myGetElementById("ddlSealtype");
 if (obj!=null){
	if (obj.style.display!='none'){
		frmvalidator.addValidation("ddlSealType","dontselect=0","Please select Seal Type");
		}
	}
 
 obj=myGetElementById("ddlLetterType");
 if (obj!=null){
	if (obj.style.display!='none'){
		frmvalidator.addValidation("ddlLetterType","dontselect=0","Please select Enamel Type");
		}
	}
	
 obj=myGetElementById("ddlAttachment");
 if (obj!=null){
	if (obj.style.display!='none'){
		frmvalidator.addValidation("ddlAttachment","dontselect=0","Please select an Attachment");
		}
	}
	
 obj=myGetElementById("ddlShape");
 if (obj!=null){
	if (obj.style.display!='none'){
		frmvalidator.addValidation("ddlShape","dontselect=0","Please select Badge Shape");
		}
	}
	
 obj=myGetElementById("ddlColor");
 if (obj!=null){
	if (obj.style.display!='none'){
		frmvalidator.addValidation("ddlColor","dontselect=0","Please select Letter Color");
		}
	}
	
 for (var i=1;i<=6;i++){
	obj=myGetElementById("txtLine" + i);
	if (obj!=null){
		if (obj.style.display!='none'){
			frmvalidator.addValidation("txtLine" + i,"req","Please type  Line " + i + " or type '(leave blank)'");
			}
		}
 }

obj=myGetElementById("txtSpecialInstructions")
if (obj) 
	frmvalidator.addValidation("txtSpecialInstructions","maxlen=100","Maximum length of Special Instructions is 100 characters.");


frmvalidator.setAddnlValidationFunction("DoCustomValidation"); 

}


function setFlash(theSrc)
{
	var obj=myGetElementById("hidSWF");
    if (obj)  obj.value=theSrc;

    var flash='<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" WIDTH="400" HEIGHT="400">';
    flash+='<PARAM NAME=movie VALUE="'+theSrc+'"><PARAM NAME=quality VALUE=high><PARAM NAME=wmode VALUE=transparent>';
    flash+='<EMBED wmode=transparent SRC="'+theSrc+'" QUALITY=high PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" ';
    flash+='TYPE="application/x-shockwave-flash" WIDTH="400" HEIGHT="400">';
    flash+='</EMBED>';
    flash+='</OBJECT>';
    obj = myGetElementById("badgeflash");
    if (obj) obj.innerHTML=flash;
    //alert(theSrc);
    //alert(myGetElementById("hidSWF").value);
    
    
}

function cancelClicked(){
var answ=confirm('Click OK to end this data entry and lose any recently entered data. Click Cancel to return to the screen with no loss of data.');

if (answ)
{
    if (frmvalidator){
        frmvalidator.setAddnlValidationFunction(""); 

	    frmvalidator.clearAllValidations();
	    return true;
	    }
	else{
	    return false;
	}
}else{
	return false;
}
}



function DefaultEnamelType(){
	var obj;
	obj=myGetElementById('ddlFinish');
	var myindex  = obj.selectedIndex;
	var sFinish = obj[myindex].value;
	var sType;
	switch (sFinish){
		case "COTE D'OR":
			sType = 'HARD';
			break;
		case 'GOL-RAY W/SIL-RAY PANELS':
			sType = 'HARD';
			break;
		case 'SIL-RAY W/GOL-RAY PANELS':
			sType = 'HARD';
			break;
		case 'SIL-RAY':
			sType = 'HARD';
			break;
		case 'GOL-RAY':
			sType = 'HARD';
			break;
		default:
			sType = 'SOFT (REGULAR)';
	}

	
	//default enamel
	obj=myGetElementById('ddlLetterType');
	if (obj.style.display!='none'){
	 obj.value=sType;
	}
}


function UCaseAll()
{
// CSS text-transform changes only the display, not the actual characters...
var uCaseObj=new Array("txtBadgeNbr","txtLine1","txtLine2","txtLine3","txtLine4","txtLine5","txtLine6");
var obj;
for (i=0;i<uCaseObj.length;i++){
    obj=myGetElementById(uCaseObj[i]);
    if (obj) obj.value=obj.value.toUpperCase();
}

}


function RefreshBadgeNote(){
return;
	var url='OrderEntryRefresh.aspx?refresh=bnote';
	var obj=myGetElementById('txtBadgeNbr');
	url+= '&b=' + obj.value;
	xmlhttp=null;
	wrapXMLHTTPRequest(url, 'RefreshBadgeNote_Ready');

} //end function RefreshLayout

function RefreshBadgeNote_Ready(){
	if (xmlhttp.readyState==4)
		{// 4 = "loaded"
		if (xmlhttp.status==200)
			{// 200 = "OK"
			//alert(xmlhttp.responseText);
			//responseText is a string of 1 and 0s, each representing the fact that corresponding control is visible or not
			//order: line1..6, back, center
			// and then semicolon, width, semicolon, height
			var response=xmlhttp.responseText;
			
		
			//size
			obj=myGetElementById("txtBadgeNote");
			
			if (obj){
				obj.value=response;
			}
	
		}
	else
		{
		//alert("Problem retrieving data:" + xmlhttp.statusText);
		}
	}
}// end function RefreshBadgeNote_Ready

function RefreshLeatherPic(){
var obj1=myGetElementById('spanLeatherPic');
if (obj1) obj1.innerHTML="";

var obj=myGetElementById('ddlLeather');
if (obj) {
    var myindex  = obj.selectedIndex;
	var sLeather = obj[myindex].value;
    if (FileExists("./images/" + sLeather + ".jpg")){
        obj1.innerHTML="<img src=\"w3ShowImage.aspx?img=" + sLeather + ".jpg&f=images/&h=100&maxw=100\" alt=\"\">";
        }
    }
}


function DoCustomValidation()
{
  var obj=myGetElementById("ddlAttachment");
  if (obj){
    var myindex  = obj.selectedIndex;
	var sAtt = obj[myindex].value;
	
	if (sAtt=='GLUE IN LEATHER'){
	    obj=myGetElementById("ddlLeather");
	    myindex  = obj.selectedIndex;
	    var sLea = obj[myindex].value;
	    //alert(sLea);
	    if (sLea==''){
	        alert("You selected GLUE IN LEATHER option, please select the LEATHER ACCESSORY model number");
	        return false;
	    }
	}
  }
  
  return true;
}

