$(document).ready(function(){

	//sugget a bussiness loader

	if($("#AjaxdivSuggestProcess").length>0) {

		$("#AjaxdivSuggestProcess").hide();

	}

	$("#stateSelectedType").val("state");

	listState();

	showBusinessOthers();

	$("#businessReqCountryID").change(function(){

			$("#stateSelectedID").val("");

			listState();					

	});

	$("#reload_icon_captcha").click(function(){
		$("#businessRequestSecurityCode").val("");

     });
	$("#businessTypeID").change(function(){

		showBusinessOthers();			

	});
	$("#businessReqStateID").change(function(){

		var stateID = $("#businessReqStateID").val();						  

		$("#stateSelectedID").val(stateID);						  

								  

	});	

$("#businessReqFirstName").bind('change keyup', function(event) {	

        var message = $(this).val();

		validate(message,$(this));

});	

$("#businessReqName").bind('change keyup', function(event) {	

        var message = $(this).val();

		validate(message,$(this));

});	

$("#businessReqComments").bind('change keyup', function(event) {	

        var message = $(this).val();

		validate(message,$(this));

});	

$("#businessReqLastName").bind('change keyup', function(event) {	

        var message = $(this).val();

		validate(message,$(this));

});	

$("#businessReqAddress1").bind('change keyup', function(event) {	

        var message = $(this).val();

		validate(message,$(this));

});	

});
function showBusinessOthers()

{

		var businessTypeID=$("#businessTypeID").val();		

		if(businessTypeID) {
			if(businessTypeID !=0)

			{
			   $("#spanBusinessOthers").hide();

			   $("#businessSelectedType").val("business");
		     }

	    	else{
				   validateReset('formRunaproduct','businessTypeID');
				   $("#spanBusinessOthers").show();
	               $("#businessTypeOther").focus();	
				   $("#businessSelectedType").val("businessOthers");
		      }

		}

		else {

			   $("#spanBusinessOthers").hide();

		}

		

}



function listState()

{

	var dataArray 			= new Array();

	dataArray[0] 		= $("#businessReqCountryID").val();

	dataArray[1] 		= $("#stateSelectedID").val();
	

	$.ajax({

		  url: GLOBAL_BASE_PATH+"/ajax/ajaxState/",

		  type: "POST",

		  cache: false,

		  async: false,

		  global: false,

		  data: { ajax_request: dataArray },

		  success: function(data) {

			 if(dataArray[0]!='') {

			  if(data!="") {

				  $("#businessReqStateID").empty();

				  $("#businessReqStateID").append('<option value="">'+lblSelect+'</option>'+data);

				  $("#spanStateProvince").hide();

				  $("#spanState").show();

				  $("#stateSelectedType").val("state");

				  

			  } else {

				  $("#spanState").hide();

				  $("#spanStateProvince").show();

				  $("#stateSelectedType").val("province");

			  }

		}  else{

				 $("#businessReqStateID").empty();

				 $("#businessReqStateID").append('<option value="">'+lblSelect+'</option>');

			 }

		  }

		  

	});
}

function validate(val,item){

    if(val.match(/([\<])([^\>]{1,})*([\>])/i)) {

        jAlert(lblHtmltags);

        item.val('');

    }

}

