function checkFree(obj){if (obj.checked) {document.getElementById('tbPrice').value='0.00'; document.getElementById('tbPrice').disabled=true;} else {document.getElementById('tbPrice').value=''; document.getElementById('tbPrice').disabled=false;}}
///////////////////////////////////////////////////////////////////////////////////////
function changeFurnTypeSubCat(){
  var myDD
  if (document.getElementById("ddFurnType")){myDD = document.getElementById("ddFurnType");}
  if ((myDD)&&(document.getElementById("ddFurnTypeSubCat"))){
  
      var myDDSub = document.getElementById("ddFurnTypeSubCat");
      var parentID = myDD[myDD.selectedIndex].value;
		  var typeID = myDDSub[myDDSub.selectedIndex].value;
		  
		  if (myDDSub.options.length!=0){
		    document.getElementById("hidPUFID").value = parentID;
		    document.getElementById("hidUFID").value = typeID;
		  }else{
		    document.getElementById("hidPUFID").value = parentID;
		    document.getElementById("hidUFID").value = parentID;
		  }
		  //alert(parentID + "," + typeID);
		  //alert(document.Form1.hidPUFID.value + "," + document.Form1.hidUFID.value);
  }
	clearAttributes(1);clearAttributes(2);
}
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
function changeFurnType(){

if (document.getElementById("ddFurnType")){
  var myDD = document.getElementById("ddFurnType");


	var parentID = myDD[myDD.selectedIndex].value;
	if (parentID != document.getElementById("hidPUFID").value){
		document.getElementById("hidPUFID").value = parentID;
		document.getElementById("hidUFID").value = parentID; //set SubCat initially = to Parent
	}
		
	if (document.getElementById("ddFurnTypeSubCat")){
	      var hasKids = false;
	      var kidOPTIONS;
	      var kidVALUES;
	      var myINPUTS = document.body.getElementsByTagName("input");
	      var optionName;
	      var length;
		    var myDDSub = document.getElementById("ddFurnTypeSubCat");
        parentID = parentID.replace('UF', '');
        //alert(parentID);
        	
        // Clears the SubCategory Dropdown list.
		    for (var i=0;i < myDDSub.options.length;i++){
			    myDDSub.options[i] = null;
		    }
		    myDDSub.options.length = 0;
			

		    for (var i = 0; i < myINPUTS.length -1; i++){	
			    myID = myINPUTS[i].id; 
    			
			    var myOptionID = myID.replace('hidOPTION_UF', '');
			    var myValueID = myID.replace('hidVALUES_UF', '');

			    if (myOptionID == parentID  && parentID != ''){
				    kidOPTIONS = document.getElementById(myID).value;
				    kidOPTIONS = kidOPTIONS.substring(0, kidOPTIONS.length-1);
				    hasKids = true;
			    }
			    if(myValueID == parentID  && parentID != ''){
				    kidVALUES = document.getElementById(myID).value;
				    kidVALUES = kidVALUES.substring(0, kidVALUES.length-1);
			    }
		    }
    		
		    if(hasKids){
			    arOPTS = kidOPTIONS.split(",");
			    arVALS = kidVALUES.split(",");
			    for(i=0; i<arOPTS.length; i++){
				    optionName = new Option(arOPTS[i], arVALS[i]);
				    length = myDDSub.length;
				    myDDSub.options[length] = optionName;
			    }
			    document.getElementById("tdSubCatDD").style.display='block';
			    document.getElementById("tdSubCatText").style.display='block';
		    }else{
			    document.getElementById("tdSubCatDD").style.display='none';
			    document.getElementById("tdSubCatText").style.display='none';
		    }
	}
	clearAttributes(1);clearAttributes(2);
}
		if (document.getElementById("tbFurnType")){
	document.getElementById("tbFurnType").value = document.Form1.ddFurnType[document.Form1.ddFurnType.selectedIndex].innerHTML;
	}
}
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
function clearAttributes(which){
  var myDD = eval('document.getElementById("ddAtt'+which+'")');
  if (myDD){myDD.options.length=0;}
    
}
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
function changeAttributes(which){

  var myDD
  if (document.getElementById("ddFurnType")){myDD = document.getElementById("ddFurnType");}
	if ((myDD)&&(document.getElementById("ddFurnTypeSubCat"))){ 

    var myDDSub = document.getElementById("ddFurnTypeSubCat");
    
    //var parentID = whichDD[whichDD.selectedIndex].value;
    var parentID = myDD[myDD.selectedIndex].value;

		var hasKids = false;
		var kidOPTIONS;
		var kidVALUES;
		var optionName;
		var length;
		var boxDescription = "";
		var myDD = eval('document.getElementById("ddAtt'+which+'")');
		var myHID = eval('document.getElementById("hidATT'+which+'")');
		var myNameHolder = eval('document.Form1.hidAttName'+which+'_'+parentID);
		var myNameVHolder = eval('document.Form1.hidAttNameV'+which+'_'+parentID);
		
    
    if (!myNameHolder){
      if (myDDSub.length>0){
        parentID = myDDSub[myDDSub.selectedIndex].value;
        if(myDDSub){
          myNameHolder = eval('document.Form1.hidAttName'+which+'_'+parentID);
	        myNameVHolder = eval('document.Form1.hidAttNameV'+which+'_'+parentID);
	      }
	    }
    }

		      if(myNameHolder){
			      boxDescription = myNameHolder.value;
			      strOptions = eval('document.Form1.hidAtt'+which+'_'+parentID).value;
			      strOptions = strOptions.substring(0, strOptions.length-1);
			      strValues = eval('document.Form1.hidAttV'+which+'_'+parentID).value;
			      strValues = strValues.substring(0, strValues.length-1);
			      hasKids = true;
			      if(myNameVHolder){
			        eval('document.Form1.hidPATT'+which).value = myNameVHolder.value;
		        }
		        //if (myDD.value != myHID.value){
		          myHID.value = myDD.value;
		         //alert(myDD.value + "," + myHID.value);
	          //}
		      }else{
		        myHID.value = "";
		      }

		      if(hasKids){
		        if(myDD.options.length == 0){
			        arOPTS = strOptions.split(",");
			        arVALS = strValues.split(",");
			        for(i=0; i<arOPTS.length; i++){
				        optionName = new Option(arOPTS[i], arVALS[i]);
				        length = myDD.length;
				        myDD.options[length] = optionName;
			        }
			      }
			      document.getElementById('tdAtt'+which+'DD').style.display='block';
			      document.getElementById('tdAtt'+which+'Text').style.display='block';
			      document.getElementById('tdAtt'+which+'Text').innerHTML = '<b>' + boxDescription + '</b>';
		      }else{
			      document.getElementById('tdAtt'+which+'DD').style.display='none';
			      document.getElementById('tdAtt'+which+'Text').style.display='none';
		      }
				}	


}
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
function saveSelected(which){
	var myDD = eval('document.Form1.ddAtt'+which);
	var myHID = eval('document.Form1.hidATT'+which);
	var myHIDText = eval('document.Form1.hidATT'+which+'N');
			
			if (myDD.selectedIndex > 0){
				myHIDText.value = myDD[myDD.selectedIndex].innerHTML;
				myHID.value = myDD.value;
			}else{
				if (document.Form1.hidInit.value =='0'){
					myHID.value="";
					myHIDText.value = "";
				}else{
					document.Form1.hidInit.value ='0';
				}
			}
			//alert(myHID.value +"-"+ myHIDText.value);
}
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
function selectAttribute(which) {
	if (document.Form1.ddFurnTypeSubCat){
		var myDD = eval('document.Form1.ddAtt'+which);
		var myHID = eval('document.Form1.hidATT'+which);
				
		selectedValue = myHID.value;
		
		if (myDD){
			var myIndex = 0;
			for (var i=0;i < myDD.options.length;i++){
				if (myDD.options[i].value == selectedValue){
					myIndex = myDD.options[i].index;
				}
			}

			myDD.selectedIndex = myIndex;

		}
	}
}
function selectAttribute(which, selectedValue) {
if (document.Form1.ddFurnTypeSubCat){
	var myDD = eval('document.Form1.ddAtt'+which);
	var myHID = eval('document.Form1.hidATT'+which);

	if (selectedValue==''){
	   selectedValue = myHID.value;
	}else{
	  myHID.value = selectedValue;
	}
	
	if (myDD){
		var myIndex = 0;
		for (var i=0;i < myDD.options.length;i++){
			if (myDD.options[i].value == selectedValue){
				myIndex = myDD.options[i].index;
			}
		}

		myDD.selectedIndex = myIndex;
	
	}
	}
}
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
function selectSubCat(selectedValue) {
if (document.Form1.ddFurnTypeSubCat){
var myIndex = 0;

	for (var i=0;i < document.Form1.ddFurnTypeSubCat.options.length;i++){
		if (document.Form1.ddFurnTypeSubCat.options[i].value == selectedValue){
			myIndex = document.Form1.ddFurnTypeSubCat.options[i].index;
		}
	}
	document.Form1.ddFurnTypeSubCat.selectedIndex = myIndex;
	if(document.getElementById("tbFurnTypeSubCat")){
	  if (myIndex > 0){
	    document.getElementById("tbFurnTypeSubCat").value = document.Form1.ddFurnTypeSubCat[document.Form1.ddFurnTypeSubCat.selectedIndex].innerHTML;
	  }
	}
	}
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function clearPost(){
	document.Form1.ddFurnType.selectedIndex = 0;
	document.Form1.ddFurnTypeSubCat.selectedIndex = 0;
	document.getElementById("tdSubCatDD").style.display='none';
	document.getElementById("tdSubCatText").style.display='none';
	document.Form1.tbName.value = '';
	document.Form1.ddCondition.selectedIndex = 0;
	document.Form1.tbDescription.value = '';
	document.Form1.tbPrice.value = '';
	document.getElementById('divMess').style.display='none';	
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function clearMaint(){
  document.Form1.ddFurnType.selectedIndex = 0;
  document.Form1.ddFurnTypeSubCat.options.length = 0;
  document.Form1.tbName.value = '';
	document.Form1.ddCondition.selectedIndex = 0;
	document.Form1.tbDescription.value = '';
	document.Form1.ddStyle.selectedIndex = 0;
	document.getElementById('dgDimensions__ctl2_tbDim').value = '';
  document.getElementById('dgDimensions__ctl3_tbDim').value = '';
  document.getElementById('dgDimensions__ctl4_tbDim').value = '';
  document.getElementById('dgDimensions__ctl5_tbDim').value = '';
	document.Form1.tbPrice.value = '';
	document.Form1.tbRetailValue.value = '';
	document.Form1.ddMfg.selectedIndex = 0;
	
	document.Form1.ddFurnTypeSubCat.options.length = 0;
	document.Form1.ddAtt1.options.length = 0;
	document.Form1.ddAtt2.options.length = 0;

	document.getElementById("tdSubCatDD").style.display='none';
	document.getElementById("tdSubCatText").style.display='none';
	document.getElementById('tdAtt1DD').style.display='none';
	document.getElementById('tdAtt1Text').style.display='none';	
	document.getElementById('tdAtt2DD').style.display='none';
	document.getElementById('tdAtt2Text').style.display='none';	

	
	document.Form1.rblContact(0).value = false;
	document.Form1.rblStatus.selected = -1;
	document.getElementById('divMess').style.display='none';		
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function checkPost(btnClick) {

  var message = "";
  var messageStart = "Please correct the following problems with your form:          \n\n";
	
	
	/*if (((document.Form1.hidUserType.value == "Showroom")||(document.Form1.hidUserType.value == "PrimaryLocation"))&&(document.Form1.ddShowroomLocations.selectedIndex == 0)){
		message += "\tPlease select a Location.\n";
	}*/
	
	if(document.Form1.ddShowroomLocations){
	 if(document.Form1.ddShowroomLocations.selectedIndex==0){
	  message += "\tPlease select a Location.\n";
	 }
	}
	
		
	if (document.Form1.tbName.value == ""){
		message += "\tPlease enter a Name to identify the item.\n";
	}
	
	
	if (document.Form1.ddFurnType.selectedIndex == 0){
		message += "\tPlease select a Furniture Type.\n";
	}
	

	if (document.Form1.ddCondition.selectedIndex == 0){
		message += "\tPlease select a Condition.\n";
	}
	
	/*if (document.Form1.tbDescription.value == ""){
		message += "\tPlease enter a Description.\n";
	}*/

	var nDim = document.Form1.tbPrice.value;
	nDim = nDim.replace(",", "");
	if (nDim == ""){
		message += "\tPlease enter your Asking Price.\n";
	}else{
		if (isNaN(nDim)){
		document.Form1.tbPrice.value = "";
		message += "\tPlease enter a numeric Asking Price.\n";
		}
	}

	if ((btnClick == 'coupon')&&(document.Form1.tbCoupon.value == "")){
			message += "\tPlease enter your Coupon Code.\n";
	}
	
	if((btnClick == 'listFree')&&!(document.Form1.rbFreeForFall_0.checked)){
		message += "\tPlease select the Free for Fall option.\n";
	}else if ((btnClick != 'listFree')&&(document.Form1.rbFreeForFall_0.checked)){
		message += "\tPlease select the Regular or the Premium listing option.\n";
	}


	if (message != ""){
		alert(messageStart + message);
		return false;
	}else{
		/*if (btnClick == 'purchase'){
			document.getElementById("btnBuyNow").disabled = true;
			alert('PayPal processing will occur here.  This is just a placeholder.');
			return true;
	  }*/
	}  
}






//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function checkMaint() {

  var message = "";
  var messageStart = "Please correct the following problems with your form:          \n\n";
	
	if (document.Form1.ddFurnType.selectedIndex == 0){
		message += "\tPlease select a Furniture Type.\n";
	}
	
	if (document.Form1.tbName.value == ""){
		message += "\tPlease enter a Name to identify the item.\n";
	}
	if (document.Form1.hidFurnSubCatRequired.value == "1" && (document.Form1.hidUFID.value == "" || document.Form1.hidUFID.value == document.Form1.hidPUFID.value)){
	  message += "\tPlease select a Furniture Sub Category.\n";
  }
	
	//if (document.Form1.ddCondition.selectedIndex == 0){
	//	message += "\tPlease select a Condition.\n";
	//}
	
	/*if (document.Form1.tbDescription.value == ""){
		message += "\tPlease enter a Description.\n";
	}*/

    var nDim = document.Form1.tbPrice.value;
    nDim = nDim.replace(",", "");
	if (nDim == ""){
		message += "\tPlease enter your Asking Price.\n";
	}else{
		if (isNaN(nDim)){
		document.Form1.tbPrice.value = "";
		message += "\tPlease enter a numeric Asking Price.\n";
		}
	}
	nDim2 = document.Form1.tbRetailValue.value;
	nDim2 = nDim2.replace(",", "");
	if ((nDim2 != "") && (isNaN(nDim2))){
		document.Form1.tbRetailValue.value = "";
		message += "\tPlease enter a numeric Retail Value.\n";
	}
	if (message != ""){
		alert(messageStart + message);
		return false;
	}
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function loadSell() {
	addPrompt();
  if (document.getElementById("tbCondition")){
    document.getElementById("tbCondition").value = document.Form1.ddCondition[document.Form1.ddCondition.selectedIndex].innerHTML;
  }

}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function hideRBL(){
 var rbl = document.getElementById("rblStatus");
 if ((rbl == null) || (rbl == undefined)) { } 
 else { 
    var NestedLabels = rbl.getElementsByTagName("td");
    var NestedInputs = rbl.getElementsByTagName("input");
    if (NestedInputs[1].checked){
      NestedLabels[0].style.display = "none";
    }
    if (NestedInputs[2].checked){    
      NestedLabels[0].style.display = "none";
      NestedLabels[1].style.display = "none";
    }
 } 
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function itemSold() {
	hidePrompt();
	if (confirm("Once an item is sold, the listing will no longer be visible.\n\nAre you sure your item is sold?")){
			//if user selects "ok" (yes, mark as sold)
			return true;
		}else {
			//if user selects "cancel" (no, do not mark as sold)
			return false;
		}
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function itemUpgrade() {
	hidePrompt();
  return confirm("You have selected to upgrade your listing.\n\nYou will be directed to PayPal to complete upgrade.");
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function hidePrompt(){
	document.getElementById("hidSurpressPrompt").value = "1";
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function showPrompt(){
	document.getElementById("hidShowPrompt").value = "1";
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function itemSave() {
	if (document.getElementById("hidShowPrompt").value == "1" && document.getElementById("hidSurpressPrompt").value =="0"){
		if (!confirm("Your changes have not been saved.\n\n Discard changes?")){
			//if user selects "cancel" (to remain on page and not lose changes)
			//return 'Press "Cancel" to remain on this page.';
			return false;
		}else {
			//if user selects "ok" (to discard changes)
			return true;
		}
	}else{
		document.getElementById("hidSurpressPrompt").value = '0';
		return true;
	}
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function addPrompt(){
	//showPrompt();
	var x = document.getElementsByTagName('a');
	for (var i=0;i<x.length;i++)
	{
		if (x[i].getAttribute('id') == "aSold" || x[i].getAttribute('id') == "aUpgrade" || x[i].getAttribute('id') == "UploadLink" || x[i].getAttribute('id') == "UploadLink2" || x[i].getAttribute('id') == "RemoveLink" || x[i].getAttribute('id') == "RemoveLink2" || x[i].getAttribute('id') == "aEnlarge" || x[i].getAttribute('id') == "ibtnSwap1And2" || x[i].getAttribute('id') == "ibtnSwap2And3" || x[i].getAttribute('id') == "ibtnSwap3And4" || x[i].getAttribute('id') == "lnkHelp" || x[i].getAttribute('id') == "lnkHelp2" || x[i].getAttribute('id') == "lnkHelp3" || x[i].getAttribute('id') == "lnkHelpImage" || x[i].getAttribute('id') == "lnkHelpImage2" || x[i].getAttribute('id') == "lnkHelpImage3"){
		}else{
				x[i].onclick = function () {
				return itemSave();
			}
		}
	}
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
function doSwap(leftnum, rightnum){
    document.getElementById("hidSurpressPrompt").value = '0';
		if (leftnum==1 && rightnum==2){__doPostBack("ibtnSwap1And2","")};
		if (leftnum==2 && rightnum==3){__doPostBack("ibtnSwap2And3","")};
		if (leftnum==3 && rightnum==3){__doPostBack("ibtnSwap3And4","")};
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789,").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
function resetFeaturedSeq(flagFeatured){
	if(flagFeatured){
		document.getElementById("tbFeatSeqNo").style.visibility = 'visible';
	}else{
		document.getElementById("tbFeatSeqNo").style.visibility = 'hidden';
	}
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
function checkID(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// ALPHANUMERIC
//else if ((("ABCDEFHGHIJKLMNOPQRSTUVWXYZ0123456789,.[]()#-_/").indexOf(keychar) > -1))
//  return true;
else if ((("abcdefghijklmnopqrstuvwxyz").indexOf(keychar) > -1))
	 {
	 Form1.tbInternalID.value = Form1.tbInternalID.value + keychar.toUpperCase();
   return false;
   }
// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
function BeforePaste_Event()
{
    // Cancel default behavior
    event.returnValue = false;
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
function Paste_Event()
{
    var objTxtBox = window.event.srcElement; 
    event.returnValue = false;
    var PasteData = window.clipboardData.getData("Text");
    //if (PasteData != "")
    //{
    //    objTxtBox.value = PasteData;
    //}    
    objTxtBox.value = ""
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
function uppercase(){
var y = Form1.tbInternalID.value;
Form1.tbInternalID.value = y.toUpperCase();
}

/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////

