function gen_unique(){return++gen_unique._counter;}
gen_unique._counter=0;
function ge(id){
	if(typeof(id)=='undefined'){
		Util.error('Tried to get an undefined element!');
		return null;
	}
	var obj;
	if(typeof(id)=='string'){
		obj=document.getElementById(id);
		if(!(ua.ie()>=7)){
			return obj;
		}
	if(!obj){
		return null;
	}else if(typeof(obj.id)=='string'&&obj.id==id){
		return obj;
	}else{
		var candidates=document.getElementsByName(id);
		if(!candidates||!candidates.length){
			return null;
		}
	var maybe=[];
	for(var ii=0;ii<candidates.length;ii++){
		var c=candidates[ii];
		if(!c.id&&id){
			continue;
		}
		if(typeof(c.id)=='string'&&c.id!=id){
			continue;
	}
	maybe.push(candidates[ii]);
	}
	if(maybe.length!=1){
		Util.error('ge() failed in a bizarre complicated edge case. Check comments.');
		return null;
	}
	return maybe[0];
	}
	}else{
		return id;
	}
	return null;
}
function remove_node(node){if(node.removeNode){node.removeNode(true);}else{for(var ii=node.childNodes.length-1;ii>=0;ii--){remove_node(node.childNodes[ii]);}
node.parentNode.removeChild(node);}
return null;}

var ua={ie:function(){return this._ie;},firefox:function(){return this._firefox;},opera:function(){return this._opera;},safari:function(){return this._safari;},windows:function(){return this._windows;},osx:function(){return this._osx;},populate:function(){var agent=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso).(\d+\.\d+))|(?:Opera.(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))/.exec(navigator.userAgent);var os=/(Mac OS X;)|(Windows;)/.exec(navigator.userAgent);if(agent){ua._ie=agent[1]?parseFloat(agent[1]):NaN;ua._firefox=agent[2]?parseFloat(agent[2]):NaN;ua._opera=agent[3]?parseFloat(agent[3]):NaN;ua._safari=agent[4]?parseFloat(agent[4]):NaN;}else{ua._ie=ua._firefox=ua._opera=ua._safari=NaN;}
if(os){ua._osx=!!os[1];ua._windows=!!os[2];}else{ua._osx=ua._windows=false;}},adjustBehaviors:function(){onloadRegister(addSafariLabelSupport);if(ua.ie()<7){try{document.execCommand('BackgroundImageCache',false,true);}catch(ignored){}}}};function is_scalar(v){switch(typeof(v)){case'string':case'number':case'null':case'boolean':return true;}
return false;}


function editor_two_level_change(selector,subtypes_array,sublabels_array)
{
	selector=ge(selector);if(selector.getAttribute("typefor"))
	subselector=ge(selector.getAttribute("typefor"));
	if(selector&&subselector){
		subselector.options.length=1;
		type_value=selector.options[selector.selectedIndex].value;
		if(type_value==""){
			type_value=-1;
		}
		index=1;
		suboptions=subtypes_array[type_value];
		if(typeof(suboptions)!="undefined"){
			for(var key=0;key<suboptions.length;key++){
				if(typeof(suboptions[key])!="undefined"){
					subselector.options[index++]=new Option(suboptions[key],key);
				}
			}
		}
		if(sublabels_array){
			if(sublabels_array[type_value]){
				subselector.options[0]=new Option(sublabels_array[type_value],"");
				subselector.options[0].selected=true;
			}else{
				subselector.options[0]=new Option("---","");
				subselector.options[0].selected=true;
			}
		}
		subselector.disabled=subselector.options.length<=1;
	}
}
function editor_date_month_change(month_el,day_el,year_el){
	var month_el=ge(month_el);
	var day_el=ge(day_el);
	var year_el=year_el?ge(year_el):false;
	var new_num_days=month_get_num_days(month_el.value,year_el.value&&year_el.value!=-1?year_el.value:false);
	var b=day_el.options[0].value==-1?1:0;
	for(var i=day_el.options.length;i>new_num_days+b;i--){
		remove_node(day_el.options[i-1]);
	}
	for(var i=day_el.options.length;i<new_num_days+b;i++){
		day_el.options[i]=new Option(i+(b?0:1));
	}
}
	function editor_date_year_change(month,day,year){
		editor_date_month_change(month,day,year);
	}
	function month_get_num_days(month,year){
		var temp_date;if(month==-1){
			return 31;
		}
		temp_date=new Date(year?year:1912,month,0);
		return temp_date.getDate();
	}
	
	
	
	function getStatesDisabled(){
		var country = document.getElementById("country").value;
		if(country == 1){
			document.getElementById("states").style.display = "block";
			document.getElementById("txtstates").style.display = "none";
		}
		else{
			document.getElementById("states").style.display = "none";
			document.getElementById("txtstates").style.display = "block";
		}
		
	}
	