function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function fuckedIE(){
	if(($(window).width()<=1000)&&($.browser.msie)){
		$("body").css({"width":"1000px"});
	}
}
function validateEmail(email)
{
	if (email.search(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/) != -1)
		return true;
	else
		return false;
}
var inputTexts = new Array();

$(document).ready(function(){
	$(".text").focus(function(){
		if(typeof(inputTexts[this.id])=='undefined'){
			inputTexts[this.id] = $(this).val();
		}
		$(this).val("");
	});
	
	$(".text").blur(function(){
		if(typeof(inputTexts[this.id])!='undefined' && (document.getElementById(this.id).value=="" || document.getElementById(this.id).value==inputTexts[this.id])){
			$(this).val(inputTexts[this.id]);
		} else{
			$(this).val(document.getElementById(this.id).value);
		}
	});
	
	var options = {
		target: '#container8_1_2', 
        beforeSubmit: showRequest, 
        success: showResponse, 
        url: '/content.php' 
	};
	
	// pre-submit callback 
	function showRequest(formData, jqForm, options){
		 var form = jqForm[0];
		 var userEmail = form.feedback_textbox.value;
		 var userText = form.feedback_textarea.value; 

		if(validateEmail(userEmail)){
			if((userText=='') || (userText=='Enter your text...')){
				alert("Please enter your text.");
				return false;
			} else {
				return true;
			}
		} else{
			alert("Please enter valid e-mail.");
			return false;
		}
	}
	
	// post-submit callback 
	function showResponse(responseText, statusText){
		$("#container8_1_1").hide();
		$("#container8_1_2").html('<p style="color: #FFF; text-align: center; font-size: 13px;">'+responseText+'</p>').show();
        setTimeout(function(){
        	$("#container8_1").animate({top: '-150px'}, 500);
        	$(".feedback_href").removeClass("menuNow").addClass("menu");
        	feedbackShow = false;},2000);
	} 
	
	$('#feedback_form').ajaxForm(options); 
		
});