// Easing equation, borrowed from jQuery easing plugin
// http://gsgd.co.uk/sandbox/jquery/easing/
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

jQuery(function( $ ){
	

//// this code for top slider
$("#myController").jFlow({
		slides: "#slides",
		controller: ".jFlowControl", // must be class, use . sign
		slideWrapper : "#jFlowSlide", // must be id, use # sign
		selectedWrapper: "jFlowSelected",  // just pure text, no sign
		auto: true,		//auto change slide, default true
		width: "610px",
		height: "246px",
		duration: 400,
		prev: ".jFlowPrev", // must be class, use . sign
		next: ".jFlowNext" // must be class, use . sign
	});


});






function bookmark(bookMarkLink){
	window.open(bookMarkLink+encodeURIComponent(location.href)+'&amp;t=');
	return false;
}

function submitform(){
		if(document.search_form.onsubmit && 
			!document.search_form.onsubmit())
		{
			return;
		}
		document.search_form.submit();
}

function submitmailform(){
	
	
		 var form = document.forms["mail_form"];
	
	    form.dissmis_share.value= 0;
	    email_text = document.getElementById('mail_text').value;
		
		if (isEmail(email_text)==false) 
	    {
	   		 alert ('يجب إدخال بريد إلكتروني صحيح');
		  	 
    	}
		else
		{		
			if(document.mail_form.onsubmit && 
				!document.mail_form.onsubmit())
			{
				return;
			}
			document.mail_form.submit();
		}
		
}

function dissmis_share(){
	
	     email_text = document.getElementById('mail_text').value;
		 var form = document.forms["mail_form"];
	
		 form.dissmis_share.value= 1;
		
		if (isEmail(email_text)==false) 
	    {
	   		 alert ('يجب إدخال بريد إلكتروني صحيح');
			 return;
		  	 
    	}
		else
		{		
			if(document.mail_form.onsubmit && 
				!document.mail_form.onsubmit())
			{
				return;
			}
			document.mail_form.submit();
		}
		
}

function isEmail(email_text) {

if ((email_text == "" ||
     email_text.indexOf('@', 0) == -1) || 
	 email_text.indexOf('.') == -1) {
return false
}
else {
return true
   }
}

function character(textField) {
	var result = true;
	var string = textField.value;
	var size = string.length;
	var iChars = "*|,\":<>[]{}`\';()@&$#%?";
	for ( var i = 0; i < size; i++) {
		if (iChars.indexOf(string.charAt(i)) != -1)
			result = false;
	}

	return result;
}

function validate_email(field, alerttxt) {
	with (field) {
		apos = value.indexOf("@");
		dotpos = value.lastIndexOf(".");
		if (apos < 1 || dotpos - apos < 2) {
			alert(alerttxt);
			return false;
		} else {
			return true;
		}
	}
}

function validate_required(field, alerttxt) {
	with (field) {
		if (value == null || value == "") {
			alert(alerttxt);
			return false;
		} else {
			return true
		}
	}
}

function validate_form1(thisform) {
	with (thisform) {
		if (validate_required(username, "حقل الاسم فارغ") == false) {
			username.focus();
			return false;
		}

		if (validate_required(title, "حقل عنوان التعليق فارغ") == false) {
			title.focus();
			return false;
		}

		if (validate_required(comment, "حقل التعليق فارغ") == false) {
			comment.focus();
			return false;
		}

		if (email.value != "") {
			return validate_email(email, 'البريد الالكتروني غير صحيح!');
		}

		if (!character(username) || !character(title)) {
			alert('فقط يسمح بإدخال الأحرف و الأرقام في حقلي الاسم و عنوان التعليق');
			return false;
		}
	}
}


function next_image(){
	jQuery(document).ready(function($) {
	$(".jFlowNext").click()
});
}

function image_timer(){
jQuery(document).ready(function($) {
      // Run our swapImages() function every 5secs
      setInterval(next_image, 10000);
    });
}
window.load= image_timer();

