

// Global to tabs function.  
// Should be used in the majority of cases
$(function(){
	// tabs
jQuery('.contentTabs').tabs();
	
	// another tab set
	jQuery(".tabs").tabs();
	
	// resizable
	$( '.resizable').resizable();
	
	

});



/// global confirm function
/// just add class 'confirm' to any link or element
/// then add attribute confirm_message
$(function(){
	
	$('.confirm').click(function () { 	

		if ( !confirm( $(this).attr("confirm_message") ) )
			{
			return false;	
			}
		
	});

});












//////////////////////////////////////////
///////// Lead Submit from form
////////////////////////////////////////
$(function(){
$(".lead-submit").submit(function(){
//alert($(this).attr("id"));

var formID = $(this).attr("id");
var id = formID.split("-");

// this is the id of the response element where resposne message will show
var responseID = id[0]+"_response-"+id[1];
var imageID = id[0]+"_image-"+id[1];



$("#"+formID).css('display','none').fadeOut(1000);
//$("#"+imageID).css('display','none').fadeOut(1000);
//$("#"+imageID).css('border','0');

// 'this' refers to the current submitted form
var str = $(this).serialize();

   var response = $.ajax({
	   type: "POST",
	   url:  domain+"Leads.php",
	   data: str,
	   error: function(msg){
			// fail function here
			alert("error");
			alert(msg);
			var message = "<h3>An error has occured, your request has not been submitted.  Please contact us via Phone. We Apologize for any inconvenience.</h3>";
			$("#"+responseID).append(message);
			$("#"+responseID).css("display","block").fadeIn(1000);
	
			},
	   success: function(msg){
			// success function here
			//alert(msg);

			
			var message = "<p class='darkGrey' style='font-style:italic;font-size:1.2em;'>Your questions/comments have been submitted.<br>We will be back with your answers promptly.</p><p style='text-align:right;font-style:italic;margin-right:100px;color:#1969BC;'> Thank You.</p>";
			
			$("#"+responseID).append(message);
			$("#"+responseID).css('display','block').fadeIn(1000);
			
			// fade out the salesman image and fade in email image
			//$("#"+imageID).css('display','block').fadeIn(1000);
			$("#"+imageID).css('border','#ffffff').fadeIn(1000);
			$("#"+imageID).attr('src', images_app_url+'icons/email.jpg').fadeIn(1000);
			//alert("success");
			//alertResponse(response);
			}
	
	 });
	
	return false;

});
});




	
$(function(){
	// allows global behavior for dialog boxes.

	jQuery( ".info_dialog" ).dialog({
				autoOpen: false,
				height: 520,
				width: 820,
				modal: true,
				buttons: { "Close": function() {
						jQuery( this ).dialog( "close" );
					}
				},
				close: function() {
				}
			});


	jQuery( ".info_dialog_controller" ).click(function() {
		
		jQuery(jQuery(this).attr("dialog_box_id")).dialog("open");
		
		});
	

});

