$(function() {
	$("#registration").validate();
	//$("input[type=text]").each(function(){
	//	$(this).bind("keyup blur", function(){
	//		if ($(this).val() != ""){
	//			$(this).prev("label").hide();
	//		} else {
	//			$(this).prev("label").show();
	//		};
	//	});
	//});

	$("#modalClose,#modalBackgroundOverlay").click(function(){$("select").show();});
	//$("input,select,label").focus(function(){
	//	$("select").show();
	//});
	$("#Country").each(function(){
		$.ajax({	// Load Country element
			url: '/scripts/php/Ajax_List.php',
			type: 'POST',
			data: 'request=getCountryList',
			dataType: 'html',
			error: function(){
				alert('Error retrieving the country list');
			},
			success: function(data){
				$('#Country').append(data);
			}
		});
	});
	
	$("#Industry").each(function(){
		$.ajax({	//Load Industry element
			url: '/scripts/php/Ajax_List.php',
			type: 'POST',
			data: 'request=getIndustryList',
			dataType: 'html',
			error: function() {
				alert('Error retrieving the industry list');
			},
			success: function(data) {
				$('#Industry').append(data);
			}
		});
	});
	$('#Country').change(function() {	//Load State Province field upon country change
		$.ajax({
			url: '/scripts/php/Ajax_List.php',
			type: 'POST',
			data: 'request=getCountryStateList&ctry=' + $(this).val(),
			dataType: 'html',
			error: function(){
				alert('Error retrieving the country state list');
			},
			success: function(data){
				$('#StateProvince').html(data);
			}
		});
	});
	$("a.popup").click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
});
