
			/**
			*	Get cookie
			*
			*	@author vitalik
			*	@param string cookie_name
			*	@param string cookie_value
			*	@return void
			**/
			function getCookie(cookie_name,cookie_value)
			{
				var results;
				results = document.cookie.match ( '(^|;) ?' + name + '=([^;]*)(;|$)' );
				if ( results )
					return ( unescape ( results[2] ) );
				else return null;
			}

			/**
			*	Create cookie
			*
			*	@author vitalik
			*	@param string cookie_name
			*	@param string cookie_value
			*	@param string cookie_expire
			*	@return void
			**/
			function createCookie(cookie_name,cookie_value,expire_days)
			{
				var date, expires;
				if ( expire_days ) {
					date = new Date();
					date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
					expires = "; expires="+date.toGMTString();
				}
				else expires = "";
				document.cookie = cookie_name + "=" + cookie_value + expires + "; path=/";
			}

			/**
			*	Delete cookie
			*
			*	@author vitalik
			*	@param string name
			*	@return void
			**/
			function deleteCookie(name)
			{
				createCookie(name,"",-1);
			}

			/**
			*	check registration form.
			*	if return true then submit form else not.
			*	@author vitalik
			*	@param
			*	@return boolean
			**/
			function checkForm()
			{
				username    = $("username");
				password    = $("password");
				company     = $("company");
				email       = $("email");
				regForm     = $("regForm");
				invite_code = $("invite_code");

				if ( $F("username") == "" ) {
					window.alert("Wrong username!");
					username.focus();
					return false;
				} else
				if ( $F("password") == "" ) {
					window.alert("Wrong password!");
					password.focus();
					return false;
				} else
				if ( $F("invite_code") == "" ) {
					window.alert("Wrong invite code!");
					invite_code.focus();
					return false;
				} else
				if ( $F("company") == "" ) {
					window.alert("Wrong company!");
					company.focus();
					return false;
				} else
				if ( ($F("email") == "") || (!checkMail($F("email"))) ) {
					window.alert("Wrong email!");
					email.focus();
					return false;
				} else {
					regForm.submit();
					return true;
				}
			}

			/**
			*	validate email address
			*	@author vitalik
			*	@param value field value with email
			*	@return boolean
			**/
			function checkMail(value)
			{
				reg = /^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}/;
				if (!value.match(reg)) {
					return false;
				} else {
					return true;
				}
			}

			/**
			*	check register form for correct input
			*	@author vitalik
			*	@param
			*	@return
			**/
			function checkRegisterForm()
			{

			}

//============================admin section

		/**
		*
		**/
		function draw_pay_pal()
		{
			if ( $("webmoney") ) $("profile_div").removeChild($("webmoney"));
			if ( $("check_div") ) $("profile_div").removeChild($("check_div"));
			profile_div = $("profile_div");
			main_form = $("operation");
			paypal_email = document.createElement("input");
			paypal_email.className = "input_text";
			paypal_email.type = "text";
			paypal_email.id = "paypal_email";
			paypal_email.name = "paypal_email";
			paypal_email.value = $("email").value;
			profile_div.appendChild(paypal_email);
			main_form.appendChild(profile_div);

		}


		function draw_webmoney()
		{
			if ( $("paypal_email") ) $("profile_div").removeChild($("paypal_email"));
			if ( $("check_div") ) $("profile_div").removeChild($("check_div"));
			profile_div = $("profile_div");
			main_form = $("operation");
			webmoney = document.createElement("input");
			webmoney.type = "text";
			webmoney.className = "input_text";
			webmoney.id = "webmoney";
			webmoney.name = "webmoney";
			webmoney.setAttribute("maxlength","13");
			//webmoney.value = webmoney.name;
			profile_div.appendChild(webmoney);
			main_form.appendChild(profile_div);
		}


		function draw_check()
		{
			if ( $("webmoney") ) $("profile_div").removeChild($("webmoney"));
			if ( $("paypal_email") ) $("paypal_email").removeChild($("paypal_email"));
			profile_div = $("profile_div");
			main_form = $("operation");

			check_div = document.createElement("div");
			check_div.setAttribute("id","check_div");

			check_div.innerHTML += "First name<font style=\"color:#FF0000;\">*</font>";
			firstname_check = document.createElement("input");
			firstname_check.type = "text";
			firstname_check.className = "input_text";
			firstname_check.id = "firstname_check";
			firstname_check.name = "firstname_check";
			check_div.appendChild(firstname_check);

			check_div.innerHTML += "Middle name";
			middlename_check = document.createElement("input");
			middlename_check.type = "text";
			middlename_check.className = "input_text";
			middlename_check.id = "middlename_check";
			middlename_check.name = "middlename_check";
			check_div.appendChild(middlename_check);

			check_div.innerHTML += "Last name<font style=\"color:#FF0000;\">*</font>";
			lastname_check = document.createElement("input");
			lastname_check.type = "text";
			lastname_check.className = "input_text";
			lastname_check.id = "lastname_check";
			lastname_check.name = "lastname_check";
			check_div.appendChild(lastname_check);

			check_div.innerHTML += "Country<font style=\"color:#FF0000;\">*</font>";
			country_check = document.createElement("input");
			country_check.type = "text";
			country_check.className = "input_text";
			country_check.id = "country_check";
			country_check.name = "country_check";
			check_div.appendChild(country_check);

			check_div.innerHTML += "City<font style=\"color:#FF0000;\">*</font>";
			city_check = document.createElement("input");
			city_check.type = "text";
			city_check.className = "input_text";
			city_check.id = "city_check";
			city_check.name = "city_check";
			check_div.appendChild(city_check);

			check_div.innerHTML += "State/Province<font style=\"color:#FF0000;\">*</font>";
			state_check = document.createElement("input");
			state_check.type = "text";
			state_check.className = "input_text";
			state_check.id = "state_check";
			state_check.name = "state_check";
			check_div.appendChild(state_check);

			check_div.innerHTML += "Address1<font style=\"color:#FF0000;\">*</font>";
			addr1_check = document.createElement("input");
			addr1_check.type = "text";
			addr1_check.className = "input_text";
			addr1_check.id = "addr1_check";
			addr1_check.name = "addr1_check";
			check_div.appendChild(addr1_check);

			check_div.innerHTML += "Address2";
			addr2_check = document.createElement("input");
			addr2_check.type = "text";
			addr2_check.className = "input_text";
			addr2_check.id = "addr2_check";
			addr2_check.name = "addr2_check";
			check_div.appendChild(addr2_check);

			check_div.innerHTML += "zip<font style=\"color:#FF0000;\">*</font>";
			zip_check = document.createElement("input");
			zip_check.type = "text";
			zip_check.className = "input_text";
			zip_check.id = "zip_check";
			zip_check.name = "zip_check";
			check_div.appendChild(zip_check);

			profile_div.appendChild(check_div);
			main_form.appendChild(profile_div);

		}


		function draw_payment_type()
		{
			payment_type = $("payment_type");
			switch (payment_type.value)
			{
				case "paypal" :
					//draw_pay_pal();
				break;
				case "webmoney" :
					//draw_webmoney();
				break;
				case "check" :
					//draw_check();
				break;
			}
		}

		function select_date(date)
		{
			//alert(date.length);
			$("current_operation").value = "selected_date";
			$("selected_date").value = date;
//return false;
			$("operation").submit();
		}


		/**
		*	change current operation and submit form
		*
		*	@author vitalik
		*	@param	action current_operation - link in menu
		*	@return void
		**/
		function button_function(action)
		{
//alert(action);
			switch (action)
			{
				case "earning" :
					$("current_operation").value = "earning";
					$("operation").submit();
				break;
				case "loads" :
					$("current_operation").value = "loads";
					$("operation").submit();
				break;
				default :
					$("current_operation").value = "invites";
					$("operation").submit();
				break;
				case "logout" :
					$("current_operation").value = "logout";
					$("operation").submit();
				break;
				case "profile" :
					$("current_operation").value = "profile";
					$("operation").submit();
				break;
				case "payments" :
					$("current_operation").value = "payments";
					$("operation").submit();
				break;
				case "statistics" :
					$("current_operation").value = "statistics";
					$("operation").submit();
				break;
			}
		}

		/**
		*	generate invite codes
		**/
		function generateInvites()
		{
			generate_invites = $("generate_invites");
			generate_invites.value = "generate_invites";
			$("operation").submit();
		}


		function orderBy(field) {
			$("order_by").value = field;
			$("operation").submit();
		}



