// JavaScript Document

var domain = 'http://' + location.host + '/';

function menu_expand_collapse(menu_ids, sub_menu_ids, type)

{

	if (type === 'auto') {

		$(menu_ids).click(function() {

			var element_id = '#sub_'	+ this.id;	

			var disp = $(element_id).css('display');			

			if (disp == 'none') {

				$(element_id).show('slow');				

			} else {

				$(element_id).hide('slow');

			}

		});		

	} else if (type === 'expand')

	{

		$(sub_menu_ids).show('slow');

		

	} else if (type === 'collapse')

	{

		$(sub_menu_ids).hide('slow');			

	}

	return false;

}







function ajaxHTMLLoader(requestURL, formData, container, loader, callOnSuccess)

{				

	$(loader).html('<img src="' + domain + 'images/wrapper/loaders/loading3.gif" width="28" height="28" alt="loading..." />');

	

	$.ajax({

	   type: 'POST',

	   url: requestURL,

	   data: formData,

	   cache: false,

	   dataType: "html",

	   success: function(data){			

		   $(loader).html('');	

		   $(container).empty().html(data);

		   if (callOnSuccess != '')

		   {

		   		callOnSuccess();

		   }

	   },

	   error: function(data, textStatus) {

		   $(loader).html('');

		   $(container).html('<br/><center> Error: An error occurd while processing your request!</center><br/>');		   	

	   }

	 });

	return false;

}





// JavaScript Document

$(document).ready(function() {

	
/*
	jQuery.validator.addMethod("nameDefaultValue", function(value, element) 

    {

	   return this.optional(element) || value != 'First Name';

	   

	   /*if (value == 'First Name') {

		return false;

		alert('');

	   	  

    });

	

	jQuery.validator.addMethod("emailDefaultValue", function(value, element) 

    {

	   return this.optional(element) || value != 'Email';		  

    });

	

	jQuery.validator.addMethod("phDefaultValue", function(value, element) 

    {

	   return this.optional(element) || value != 'Telephone Number';		  

    });

	

	$('#form').validate({

			submitHandler:function() {

				// set ajax submit options

				var frmOptions = {	

					success: function(responseText) 

					{						

						if (responseText == 'success') 

						{

							location.href='thankyou_3.php';

						} else {

							$("#error").html(responseText);

							$("#error").show();

						}

					}

				};

				// submit form using ajax

				$('#form').ajaxSubmit(frmOptions);

			},

			

			errorPlacement:function(error, element) {				

				//$("#error").append('<br/>' +element.get(0).title + '<sup>*</sup>');

			}, 

			

			invalidHandler: function(form, validator) {

				var errors = validator.numberOfInvalids();

				  if (errors) {

					$("#error").html("Error: Please enter/select correct values in required fields!!");

					$("#error").show();

				  } else {

					$("#error").hide();

				  }

			}

 	});

	}*/	

});


