function showSubItem(item) {
        var sublistid = '.menulist-'+item.id;
        var parentLI = item.id.substring(3,4);
        if ($(sublistid).css('display')!='block') {
           $('#menulist'+parentLI).addClass('active');
           $(sublistid).show();
        } else {
          $('#menulist'+parentLI).removeClass('active');
          $(sublistid).hide();
        }
}
var slideNum = 0;
var pluscounter = 1;
$(document).ready(function() {

	  if ($('.subA111').length) {
	      $('.subA')
	      		.click(
	                function () {
	      			    showSubItem(this)
	                }
	      		)
	  }
      if ($('.sliderImage').length) {
      	$('.sliderImage').cycle({
		    fx:     'scrollLeft',
		    speed:    1000,
    		timeout:  6000,
    		sync: 1,
		    startingSlide: 0,
		    before: function() {
					},
		    after: function() {
						if ($('#sliderBtn'+(slideNum-1)).length) $('#sliderBtn'+(slideNum-1)).removeClass('sliderBtn-active');
						if (slideNum>3) slideNum=0;		    			
						$('#sliderBtn'+slideNum).addClass('sliderBtn-active');
						slideNum++;
					}

		});
      }
})

function memberchoice(nchoice) {
    if (nchoice==1)
        var otherchoice = 2;
    else
        var otherchoice = 1;
        if ($('#inner-rightcolumn'+nchoice).css('display')=='none') {
           $('#inner-rightcolumn'+nchoice).show();
           $('#inner-rightcolumn'+otherchoice).hide();
           $('#choice'+nchoice).addClass('memberchoice-select').removeClass('memberchoice-noselect');
           $('#choice'+otherchoice).removeClass('memberchoice-select').addClass('memberchoice-noselect');
           if ($('.error').length>0) $('.error').html('');
        }
}

function change_billingtype(obj) {	
	if (obj.value=='cc') {
		if ($('#billinginfo_cc').css('display')=='none') {
			$('#billinginfo_cc').show();
			$('#billinginfo_po').hide();
		}
	} else {
		if ($('#billinginfo_po').css('display')=='none') {
			$('#billinginfo_cc').hide();
			$('#billinginfo_po').show();		
		}
	}
	
}
function formatupload() {
     if (typeof window['labels']=='undefined') return false;
     
	 url = "/savequote.html";              
     var x;
     var data='';
     
     for (x in labels)
      {
      		if (labels[x]!='undefined') {
      			if (data!='') data += '&';
      			fldvalue = $('#'+fields[x]).val();
            	data += labels[x] +"="+fldvalue+ ";";
			}		
            		
      }
     $.ajax({
	   type: "POST",
	   url: url,
	   data: data, 
	   success: function(msg){
	     $("form#sfUploadForm").submit();	
	   }
	 });
	      
	 return false;
}

function changeCurrency(ext) {    
	 currency = $('#currency').val();	 
	 url = "/"+ext+"/currency/"+currency+".html";              
     location.href=url;	
}

function setStates() {
  //changeSelect('province', states, states);
//  setCities();
//  if (SelectedState.length>0) {
//		$("#province option:contains("+SelectedState+")").attr("selected", true);
//		setCities();
//		$("#city option:contains("+SelectedCity+")").attr("selected", true);
//	}
  countrySel = jQuery('#country').val();  
  statesList = states[countrySel];
  changeSelect('province', statesList, statesList);
  
}
 
function setCities() {
  stateSel = jQuery('#province').val();
  cityList = cities[stateSel];
  changeSelect('city', cityList, cityList);
}

function changeSelect(fieldID, newOptions, newValues) {
  selectField = document.getElementById(fieldID);
  selectField.options.length = 0;
  for (i=0; i<newOptions.length; i++) {
  	str = newOptions[i];
	arrData = str.split('|');
	selectField.options[selectField.length] = new Option(arrData[0], arrData[1]);
    //selectField.options[selectField.length] = new Option(newOptions[i], newValues[i]);
  }
}



