﻿/* ©2008 Persian Ava System Ltd. */
/* www.ava-biz.com */

$(document).ready(function() {
	$('#winners_cwid').change(function() {
		$('#loading').show(); 
		$('#table_winners').hide(); 					
		$.ajax({
			type: 'GET',
			cache: false,
			url: $('#form_winners_ifrm').attr('action'),
			data: $('#form_winners_ifrm').serialize(),
			success: function(data) {
				$('#table_winners').html(data);
				$('#loading').hide(); 
				$('#table_winners').fadeIn('slow');
			}
		})
		return false;									 
	});

})
$(document).ready(function() {
	$('#users_cwid').change(function() {
		$('#loading2').show(); 
		$('#table_users').hide(); 								
		$.ajax({
			type: 'GET',
			cache: false,
			url: $('#form_users_ifrm').attr('action'),
			data: $('#form_users_ifrm').serialize(),
			success: function(data) {
				$('#table_users').html(data);
				$('#loading2').hide(); 
				$('#table_users').fadeIn('slow');
			}
		})
		return false;
	});
})
$(document).ready(function() {
	$('#statistics_cwid').change(function() {
		$('#loading6').show(); 
		$('#table_statistics').hide(); 								
		$.ajax({
			type: 'GET',
			cache: false,
			url: $('#form_statistics_ifrm').attr('action'),
			data: $('#form_statistics_ifrm').serialize(),
			success: function(data) {
				$('#table_statistics').html(data);
				$('#loading6').hide(); 
				$('#table_statistics').fadeIn('slow');
			}
		})
		return false;
	});
})

$(document).ready(function() {
	$('#dgotolottery').click(function() {
		$('#disablesys').fadeIn('slow');
	});
})
$(document).ready(function() {
	$('#gotolottery').click(function() {
		$('#noforsu').hide();
		$('#thnx').hide();
		$('#forsu3').hide();
		$('#gotolottery').hide();
		$('#leftpic').fadeIn('slow');
		$('#rightpic').fadeIn('slow');
		$('#forsu').fadeIn('slow');
		$('#gotonext1').fadeIn('slow');
		$('#sudiv').fadeIn('slow');
	});
})
$(document).ready(function() {
	function IsEmail(email) { 
		var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
		if (regex.test(email)) return false;
		else return true;
	}   
	function IsIDcode(idcode) { 
		var regex2 = /^[0-9]{10,10}$/; 
		if (regex2.test(idcode)) return false;
		else return true;
	}   
	function IsPhone(phone) { 
		var regex3 = /^[0-9]{0,}$/; 
		if (regex3.test(phone)) return false;
		else return true;
	}   
	$('#gotonext1').click(function() {
		if ($("#user_idcode").val() == '' ||
			$("#user_fname").val() == '' ||
			$("#user_lname").val() == '' ||
			$("#user_pname").val() == '' ||
			$("#user_cname").val() == '' ||
			$("#user_birthday").val() == '' ||
			$("#user_birthmonth").val() == '' ||
			$("#user_birthyear").val() == '' ||
			$("#user_mob").val() == '' )
				alert("لطفا تمامی فیلد ها ی ستاره دار را تکمیل نمایید");
		else if (IsIDcode($("#user_idcode").val()))  
			alert("کد ملی صحیح وارد نشده است.لطفا 10 رقم شماره ملی خود را (بدون خط تیره، فاصله و...) وارد فرمایید");  
		else if (IsPhone($("#user_mob").val()))  
			alert("لطفا شماره تماس خود را به صورت عددی (بدون خط تیره، فاصله، کد  و...) وارد نمایید ");  
		else if (IsEmail($("#user_email").val()) && $("#user_email").val() != '' )  
			alert("پرکردن فیلد «ایمیل» الزامی نمی باشد اما در صورت تمایل به تکمیل آن باید یک ایمیل معتبر وارد نمایید");  
		else {
			$('#loading5').show();
			$('#gotonext1').hide();
			$('#sudiv').hide();
			$('#gotonext1').hide();
			$('#forsu').hide();
			$('#sudiv2').fadeIn('slow');
			$('#forsu2').fadeIn('slow');
			$('#forsu3').fadeIn('slow');
			$('#loading5').hide();
		}
	});
})
$(document).ready(function() {
	$('#gotonext2').click(function() {
		if ($("#first_team_1").val() == 'انتخاب' ||
			$("#first_team_2").val() == 'انتخاب' ||
			$("#first_team_3").val() == 'انتخاب' ||
			$("#first_team_4").val() == 'انتخاب' ||
			$("#first_team_5").val() == 'انتخاب' ||
			$("#first_team_6").val() == 'انتخاب' ||
			$("#first_team_7").val() == 'انتخاب' ||
			$("#first_team_8").val() == 'انتخاب' ||
			$("#first_team_9").val() == 'انتخاب' ) 
				alert("لطفا تمامی بازی ها را پیشبینی نمایید");
		else{
			$('#loading5').show();
			$('#loading2').show();
			$('#sudiv').hide();
			$('#sudiv2').hide();
			$('#forsu2').hide();
			$('#forsu3').hide();
			$.ajax({
				type: 'POST',
				url: $('#myForm').attr('action'),
				data: $('#myForm').serialize(),
				success: function(data) {
					$('#thnx').html(data);
					$('#loading5').hide();
					$('#thnx').fadeIn('slow');
					$('#noforsu').fadeIn('slow');
					$('#gotolottery').fadeIn('slow');		
				}
			}) 
			$('#table_users').hide(); 	
			$.ajax({
				type: 'GET',
				cache: false,
				url: $('#form_users_ifrm').attr('action'),
				data: $('#form_users_ifrm').serialize(),
				success: function(data) {
					$('#table_users').html(data);
					$('#loading2').hide(); 
					$('#table_users').fadeIn('slow');
				}
			})
			return false;
		}
	});
})
$(document).ready(function() {
	$('#games_cwid').change(function() {
		$('#loading3').show(); 									
		$('#table_games').hide(); 
		$.ajax({
			type: 'GET',
			cache: false,
			url: $('#form_games_ifrm').attr('action'),
			data: $('#form_games_ifrm').serialize(),
			success: function(data) {
				$('#table_games').html(data);
				$('#loading3').hide(); 
				$('#table_games').fadeIn('slow');
			}
		})
		return false;
	});
})
$(document).ready(function() {
	$('#moreinfo1btn').click(function() {
		$('#moreinfo1btn').hide(); 									
		$('#moreinfo1').fadeIn('slow'); 									
	});
})

$(document).ready(function() {
	$('#oilofcar_cwid').change(function() {
			$('#loading8').show(); 
			$('#table_oilofcar_frm').hide();
			$('#table_oilofcar').hide(); 
			$.ajax({
				type: 'GET',
				url: $('#form_oilofcar_ifrm').attr('action'),
				data: $('#form_oilofcar_ifrm').serialize(),
				success: function(data) {
				$('#table_oilofcar').html(data);
				$('#loading8').hide(); 
				$('#table_oilofcar_frm').show();
				$('#table_oilofcar').fadeIn('slow');
			}
		})
		return false;
	});
})

