//==================================== the initial ====================================================
$(document).ready(function() {
	$("#signature").append("&copy; 2009 CHERYL GREY | design: <a href='http://www.snazzymedia.co.uk'>www.snazzymedia.co.uk</a>");
	
	$("#email_link").append("<a href='mailto:admin@cherylgrey.co.uk'><img src='img/spacer.gif' width='172' height='20' border='0' style='opacity:0; filter:alpha(opacity=0)'/></a>");
	$('#email_link').each(function(){
    	var lnk = $(this).html().replace(/([\w-]+@([\w-]+\.)+[\w-]+)/, '$1');
    	$(this).html(lnk);
	});
	});
//======================================================================================================

//==================================== the hilite tab ==================================================
$(document).ready(function() {
	var myInterval = setInterval(function() {
										  //alert("hey");
	$("div#menu_tab").each(function() {			
											  
		$(this).find("img").each(function() {
		if($(this).parent().attr("href") == undefined) {
			
			$(this).attr("src", $(this).attr("src").replace("_off","_ovr"));
			
		}
									  });
												});
		//clearInterval(myInterval);
												}, 100);
	
	});
//====================================================================================================

//==================================== the rollover ==================================================
$(document).ready(function() {
	$("div#menu_tab").each(function() {			
		
	$(this).find("img").hover(
		function() {
			
			$(this).attr("src", $(this).attr("src").replace("_off","_ovr"));
			var imgLoad = $(this);
			imgLoad.error(
						  function() {
							  $(this).attr("src", $(this).attr("src").replace("_off","_ovr"));
						  }); 
		}
		, function() {
			$(this).attr("src", $(this).attr("src").replace("_ovr","_off"));
		});
												});
	
	});

//===================================================================================================

//==================================== the rollover ==================================================
$(document).ready(function() {
	$("#submit").hover(
		function() {
			
			$(this).attr("src", $(this).attr("src").replace("_off","_ovr"));
			var imgLoad = $(this);
			imgLoad.error(
						  function() {
							  $(this).attr("src", $(this).attr("src").replace("_off","_ovr"));
						  }); 
		}
		, function() {
			$(this).attr("src", $(this).attr("src").replace("_ovr","_off"));
		});
	
	});

//===================================================================================================

//====================================== the table ==================================================
$(document).ready(function() {
	$("div#form").each(function() {	

		var widthArray = new Array(75, 0);
		var heightArray = new Array();
		var inputWidth = 0;

		$(this).find("div[id^='tr']").each(function(j) {
													
										 var tempWidth = 0;
										 heightArray[j] = 0;
										 
										 if($(this).find("input").width() > inputWidth) {
										 			inputWidth = $(this).find("input").width();
													//alert(inputWidth);
										 }
										 
										 $(this).find("div").each(function(i) {

																		  tempWidth = $(this).width();

																		  if(tempWidth > widthArray[i]) {
																			  widthArray[i] = tempWidth;
																			  //alert(tempWidth);
																		  }
																			
																		  if($(this).height() > heightArray[j]) {
																		  	  heightArray[j] = $(this).height() + 5;
																		  }

										 });
												});

	
		$(this).find("div[id^='tr']").each(function(j) {
													
										 $(this).find("div").each(function(i) {
																		  
																		  //$(this).css({'background-color' : 'red'});
																		  $(this).width(widthArray[i]);
																		  $(this).find("textarea").width(inputWidth);
										 });
										 $(this).height(heightArray[j]);
										 //$(this).find("input[id='submit']").height(20);
										//$(this).find("div#td_btn").css({'float' : 'left', 'text-align' : 'right', 'width' : '345px', 'height' : '20px', 'padding' : '0px', 'background-color' : 'red'});
										
										//$(this).append("<div id='clearFloat'></div>");
												});
			});
	});

//===================================================================================================

//====================================== the form checker ===========================================
$(document).ready(function() {
		
		//$("#confirmation").hide(); 
		
		$("#submit").click(function() {
									  //var inputChecked;
									  $("#form").find("input:not(:#submit)").each(function() {
																			 
																			 if($(this).val().length == 0) {
																				 
																				 alert('Please fill in '+$(this).attr('name'));
																				 //inputChecked = false;
																				 
																			 }
																			 
																			 });
									  
									  $("#form").find("textarea").each(function() {
																			 //alert($(this).val().length);
																			 if($(this).val().length <= 1) {
																				 
																				 alert('Please fill in '+$(this).attr('name'));
																				 //inputChecked = false;
																				 
																			 }
																			 
																			 });
									 // if(inputChecked) {
										//$("#confirmation").show();  
									  //}
									  
									  });
		
	});

//===================================================================================================
