var jlib={
	$:function(qid){
		return document.getElementById(qid);
	},
	//create new element
	$CE:function(qel,qchild){
		var el;
		if ('string'==typeof qel) {
			el=document.createTextNode(qel);
		} else {
			el=document.createElement(qel.tag);
			delete(qel.tag);
	
			if ('undefined'!=typeof qchild) {
				for(var i=0; i<qchild.length; i++) {
					el.appendChild(qchild[i]);
				}
			}
			delete(qchild);
			for (attr in qel) {
				el[attr]=qel[attr];
			}
		}
		return el;
	},
	//delete element
	$DE:function(qid){
		var el=jlib.$(qid);
		if(el!=null){
			el.parentNode.removeChild(el);
		}
		el=null;
	},
	hide:function(qel){
		qel.style.display = 'none';
	},
	show:function(qel){
		qel.style.display = 'block';
	}
};
function hideSubmit(qel,qform){
	/*var elements = jlib.$(qform).elements;
    for (var i=0;i<elements.length;i++) {
        elements[i].disabled=true;
    }
	elements=null;*/
	
	
	var el=jlib.$(qel);
	var newEl=jlib.$CE({tag:'div',id:'showLoading'},[
		jlib.$CE({tag:'p'},[jlib.$CE('Please wait. The form is being processed')]),
		jlib.$CE({tag:'img',src:'loading.gif'})
	]);
	jlib.hide(el);
	window.location.hash=qel+'_top';
	el.parentNode.insertBefore(newEl,el);
	el=null;
}
function testCountry(qval,qclass,qfield){
	if(qval=='CA' || qval=='US'){
		$('.'+qclass).fadeIn();
	}else{
		$('.'+qclass).hide();
		$('#'+qfield).val('');
	}
}
$("document").ready(function(){
	$('#Country').change(function(){
		testCountry($(this).val(),'staterow','State');
	});
	testCountry($('#Country').val());
	
	$('#Country2').change(function(){
		testCountry($(this).val(),'staterow2','State2');
	});
	testCountry($('#Country2').val());
});