// changelog: 2010/12/30 commented out var done on line 6
jQuery(document).ready( function($) {

$(function() {
	var newerrorstring="";
//	var done=0;
  $('.error').hide();

  $('input.text-input').css({backgroundColor:"#FFFFFF"});

$('.webmailcall').live('click',function(){
	var page=document.location.href;
	page=page.replace("#","");
	var title=$(this).attr('title');
	if(title!=''){$('#dialog').dialog('option', 'title', title);}
	$('#dialog').dialog('option','modal',true);
	var requesttype=$(this).attr('id');
   	$('#dialog').load(page,{
			'ajaxrequest':requesttype
			},
			function(data){
				$('#dialog').html(data);// add the data to the div
		  		$('#dialog').dialog('open');
				$('#subject').focus();
				$('#subject').css({backgroundColor:"#FFDDAA",border:'2px inset black'});
				/*
if(document.domain!='kiwaniswebsites.org'){
				$('input.text-input').focus(function(){
					$(this).css({backgroundColor:"#FFDDAA",border:'2px inset black'});
					$(".swd-validation-errors").show();
				});

				$('input.text-input').blur(function(){
					var itemid=$(this).attr("id");// assign the id of the input element to the variable itemid
					var itemclass=$(this).attr("class");// get the class of the element and assign it to a variable
					$(this).css({backgroundColor:"#FFFFFF"});
					$('#' + itemid + '-modify').checked='';
				    $.post(page,{
					'ajaxrequest':'validate',
					'f':itemid,
					'value' : $('input#' + itemid).val(),
					'class' : itemclass,
					'id' : itemid},
					function(data){
				        var dataarray=data.split("&&");// split the returned message into an array
						// the array that is returned the keys will be in this format:
						// validated=0, valid-result=1,valid-value=2
						var validated=dataarray[0].substring(10);// 0 (validation failed) or 1 (validation occured)
						var validresult=dataarray[1].substring(13);// 0 (invalid) or 1 (valid)
						var validvalue=dataarray[2].substring(12);// value of the data
						var validerror=dataarray[3].substring(12);// the error message from validation
						var errors=$("#swd-errors").val();// get the existing errors
						var found=errors.indexOf(itemid);// check the existing errors for a match with the itemid
						var divid="div" + itemid;
						var newerrorcount='';
						var errorarray='';
						if(validated==1 && validresult==1){// this was successfully validated
							$('input#' + itemid).val(validvalue);// assign the data to the input element if it is valid
			  		   		if(found>=0){// if the error already exists, we now need to remove it since the error has been corrected
								if(errors.length>0){
									errorarray=errors.split('&&' + itemid);// split the original errors with the itemid
									newerrorcount=errorarray.length;
								}
								else{
									errorarray='';
									newerrorcount=0;
								}
								if(errorarray.length==2){
									if(errorarray[0].length>0){
										newerrorstring=errorarray[0];
									}
									else{
										newerrorstring='';
									}

									if(errorarray[1].length>0){
										newerrorstring=newerrorstring+errorarray[1];
									}

								}
						 	}
/*                           var diagnostics='there are no errors on 98 and  diagnostics are found=' + found + ' for the itemid of ' + itemid + ' the new errorcount is ' + newerrorcount + ' the newerrorstring is ' + newerrorstring + ' and the errors are ' + errors + ' for the parts ' + errorarray[0] + ' and ' + errorarray[1];
$('.swd-debug').html(diagnostics);
*/
/*						}
						else{
							// the data was not validated or validation failed
							if(validated==1 && validresult==0){
								// data was validated, but is not valid
								$('input#' + itemid).val('');// return a blank to the form field
								$('input#' + itemid).css({'border':'2px solid red'});// highlight the field in red
								// if there is an error for this itemid, do nothing, otherwise, add it to the error string
					   			if(found<0){// add the error to the end of the string
									newerrorstring=errors + "&&" + itemid;

						 		}
							}
							else{// the only remaining option is that the validation itself failed
								$('#swd-validation-errors').append("<div id='" + divid + "' style='background-color:blue;color:red'>Fatal Error - Validation Failed</div>");
							}


						}
						if(data=='invalid'){
							newerrorstring=errors + '&&Fatal Validation Error';
						}

						if(newerrorstring!=''){
					   //		$(".swd-validation-errors").show();
					   //		$(".swd-validation-errors").html('errorcount is ' + newerrorcount + 'found is ' + found + ' for the errors ' + errors + ' and the errorstring is ' + newerrorstring);
							$("#swd-errors").val(newerrorstring);// replace the error string in the form
						}
						else {// if there are no errors, clear the field and hide it
							$(".swd-validation-errors").hide();
							$('.swd-validation-errors').html(newerrorstring);
							$('#swd-errors').val('');
						}// end newerrorstring if statement

					});// end post and data function call

				});// end input.text function

}// end of the IP test section
*/
  });// end data function call and load page statement
  });// end webmail loop
/*
  $("#rememberme").click(function(){
  	$("#rememberme").val('1');
  });

*/
$(".ajax-loader").ajaxStart(function(){// show the animated gif when loading ajax
   $(this).show();
 });

$(".ajax-loader").ajaxStop(function(){// hide the animated gif
   $(this).hide();
 });


});// end main function call


});// end main jquery call

