$(document).ready(function(){
$("img.small_logos").each(
	function() 
	{
		var $container = $(this);
		var $img_id = "big_" + $container.attr('id');
		$big_container = $('#' + $img_id);
		var $img = $("img:first", $big_container);

		$container.mouseover(function() 
		{
			//var $right_text_object = $("#main_text");
			//$right_text_object.hide();
			
				$("div.preview").each(
					function() 
					{
						var $big_site_object = $(this);
						if ($big_site_object.attr('id') !== $img_id)
							$big_site_object.hide();
						else
						{
							$big_site_object.fadeIn(600);
							
							// Create an object of all right_more_info
							/*
							$("div.RightDiv").each(
							function()
							{
								var $new_right_more_info_id = "more_info_" + $container.attr('id');
								var $right_more_info_new_object = $("#" + $new_right_more_info_id);
								var $right_more_info_current_object = $(this);

								if ($right_more_info_current_object.attr('id') == $new_right_more_info_id)
									$right_more_info_new_object.show();
								else
									$right_more_info_current_object.hide();
							}
							)
							*/

						}
					}
				)	
		});  
    }
)
});

function validPhone(phone_field)
{	

	var area_codes = "02,03,04,08,09,072,073,076,077,078,079,050,052,054,057";
	var phone_number = document.getElementById(phone_field).value;
	var pre_code = document.getElementById("pre_phone_code").value; // need to see there is no hitnagshot here

	phone_number = pre_code + phone_number;

	var valid = false;
	// Check for correct phone number
	 var rePhoneNumber = new RegExp(/^([0-9]{7})$/);
	 var phone_areas = area_codes.split(",");
	 for(area_code=0;area_code<phone_areas.length;area_code++)
	 {
		if(phone_number.substr(0, phone_areas[area_code].length) == phone_areas[area_code])
		{
			phone = phone_number.substr(phone_areas[area_code].length);
			if(rePhoneNumber.test(phone))
			{
				valid = true;
			}
		}//If area code found
	 }//For each area code in list
	return valid;
}

function check_details(the_value,which)
{
	if (which == "fullname")
		{
			fullname_obj = document.getElementById("fullname");
			if (fullname_obj.value.length > 1)
				fullname_obj.style.color="green";
			else
			{
				fullname_obj.style.color="red";
				return;
			}
		}
	else
	{
		if (which == "phone")
		{
			phone_obj = document.getElementById("phone");
			pre_phone_code_obj = document.getElementById("pre_phone_code");

			if (validPhone("phone"))
			{
				phone_obj.style.color="green";
				pre_phone_code_obj.style.color="green";
			}
			else
			{
				phone_obj.style.color="red";
				pre_phone_code_obj.style.color="red";
				return;
			}
		}
	}
}

function send_details()
{
	fullname_obj = document.getElementById("fullname");
	phone_obj = document.getElementById("phone");
	
	if (fullname_obj.value.length < 1)
	{	
		fullname_obj.focus();
		return;
	}
	else if (!validPhone("phone"))
	{
		phone_obj.focus();
		return;
	}
	
	document.getElementById("contact_form").submit();
}

