// JavaScript Document
$(document).ready(function(){
	$("#fifthLink").click(function(){
             try
        {
            $(".s-player").hide();
        }
        catch(err)
        {

        }
		$.blockUI({
			message: $('#contact-us'),
			centerY: 0,
			css: {
				height: '365px',
				width: '682px',
				border: 'none',
				backgroundColor: '#DDD',
				top: '0',
				left: '20%',
				cursor: 'auto'
			}
		});
		return false;
	})
	$("#contact-close").click(function(){
		$.unblockUI();
	})
	
/////////////////////////////////////////////////////////
	$('#sedn-contact-us').click(function(){
		var contactName = $('#contactName').val();
		var contactEmail = $('#contactEmail').val();
		var contactEmail2 = $('#contactEmail2').val();
		var contactMSG = $('#contactMSG').val();
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		
		if( contactName == "" || contactEmail == "" || contactEmail2 == "" || contactMSG == ""){
			alert("عفواً .. جميع الحقول مطلوبة");
			return false;
		}
		if(!reg.test($('#contactEmail').val()) || !reg.test($('#contactEmail2').val()) ){
			alert("عفواً .. البريد الإلكتروني غير صحيح");
			return false;
		}
		if( contactEmail != contactEmail2 ){
			alert("عفواً .. البريد الإلكتروني غير متطابق");
			return false;
		}
		
		//$('#add-comment-form input,textarea').attr("disabled", true);		
		$('#contact-us-loading').ajaxStart(function(){ $(this).show() } );
		$('#contact-us-loading').ajaxError(function(){ $(this).hide() } );
		$.ajax({
			type:'POST',
			url:base_path+'conratct-us',
			data: 'contactName='+contactName+'&contactEmail='+contactEmail+'&contactMSG='+contactMSG,
			cache:false,
			error: function(xhr, ajaxOptions, thrownError){
				alert('error number: '+xhr.status);
			},
			success: function(msg){
				$('#contact-us-loading').hide();
				$('#contact-us-message').stop().animate( {"opacity": 1},{duration:1}).animate( {"top": 0},{duration:1333});
				$('#contact-us-message').show().html(msg).animate( {"opacity": "hide"}, { duration:5500 } ).css({top:0});
				setTimeout($.unblockUI, 1000);
				}
			});
	});
	$(".blockUI").click(function(){
		$.unblockUI();
	});
})