// JavaScript Document
var r = new Date().getTime(); 
$(document).ready(function(){
	get_qn();
	get_sites();
//*****************************************************888//
$(".care_img").mouseenter(function() {
	//$("#main_ved_txt").stop().fadeTo('normal', .8).show();
	$(this).stop().animate({
 		opacity: 0.7,
		},300);
  }).mouseleave(function() {
	$(this).stop().animate({
 		opacity: 1,
		},300);
  });
//*****************************************************888//
$("#share_imgs img").mouseenter(function() {
	var url=$(this).attr('id');
	var nurl='hover_'+url;
	$(this).attr('src','imgs/'+nurl+'');
	$(this).attr('style','margin-top:5px');

	}).mouseleave(function() {
	var url=$(this).attr('id');
	$(this).attr('src','imgs/'+url+'');
	$(this).attr('style','margin-top:7px');
  });

//*****************************************************888//
$("#go_up").mouseenter(function() {
	$(this).stop().animate({
		height: '31px'
		},150);
	}).mouseleave(function() {
	$(this).stop().animate({
		height: '17px'
		},150);
  });
//*****************************************************888//
$("#bmb").mouseenter(function() {
	$("#bg_div2").stop().fadeTo('normal', .5).show();
	$("#bm").stop().fadeTo('normal', 1).show();
	}).mouseleave(function() {
	$("#bm").stop().fadeTo('normal', 0).hide();
	$("#bg_div2").stop().fadeTo('normal', 0).hide();
  });
//*****************************************************888//
$("#get_gb_p td").click(function() {
	var num=$(this).html();
	if(num!=''){
			tt=parseInt(num);
			$("#wait").hide().fadeIn(500);
			get_gb_page(tt);
			
	}
  });
  

///////////////////////////////////////////////////////////////////////////////////////////////
$("#daily_days td").click(function() {
	$("#daily_days td").css('background','url(imgs/daily_in_07.png) top center no-repeat');
	$("#daily_days td").css('height','18px');	
	$("#daily_days td").css('width','42px');	
	$(this).css('height','25px');	
	$(this).css('width','55px');	
	$(this).css('background','url(imgs/daily_in_05.png) top center no-repeat');
  });


///////////////////////////////////////////////////////////////////////////////////////////////
$("#daily_content_title li").click(function() {
$("#daily_content_title li").attr('class','daily_content_titles2');
$(this).attr('class','daily_content_titles1');
  });

	});
//*****************************************************888//



function reset_h(){
	var g=$("#tags_ban").height();
	g=parseInt(g);
	g=g-100;
	var lw=$("#ln").height();
	lw=parseInt(lw);
	lw=lw+g;
	$("#ln").height(lw);

	}

function hide_me(div){
	//$("#"+div+"").fadeOut(500);
	$("#"+div+"").slideUp(300);
}



function get_qn(){
var r = new Date().getTime(); 
	setTimeout(function() {
		var url="funcs.php?do=qn&r="+r;
		$.get(url, function(msg) {
			if(msg!='null'){
					var url1="funcs.php?do=chcqn&r="+r;
					$.get(url1, function(msg1) {
						if(msg1=='0'){
							$("#pop_td").html(msg);
							pop_qn();
						}
					});
					if($("#qn_td").html()=='..'){
					$("#qn_td").html(msg);
					$("#q1").slideDown(300);
					}
					else if($("#qn_td").html()!=msg && $("#qn_td").html()!='..'){
						$("#qn_td").hide().fadeIn(300).html(msg);
						$("#q1").slideDown(300);
					}
					else{
						$("#qn_td").html(msg);
						}
			} 
			else if(msg=='null'){
					if($("#qn_td").html()!='..'){
					$("#q1").slideUp(300);
					close_pop_qn();
					}
					setTimeout(function() {
					$("#qn_td").html('..');
					}, 310);
					}
		});
		get_qn();
	}, 5000);
}
//####################################################################//
function get_sites(){
var r = new Date().getTime(); 
	setTimeout(function() {
		var url="sites.php?r="+r;
		$.get(url, function(msg) {
		});
		get_sites();
	}, 10000);
}
//####################################################################//
function pop_qn(){
	$("#bg_div").hide().fadeIn(300);
	$("#pop_div").slideDown(300);
	$("#q1").slideDown(300);
}
function close_pop_qn(){
	$("#pop_div").slideUp(300);
	setTimeout(function(){
	$("#bg_div").fadeOut(500);
	},600);
	}
//####################################################################//
function add_vote(vid){
	var val=$('input:radio[name=vote_val]:checked').val();
	var x=$('input:radio[name=vote_val]:checked').length;
	if(x !='0'){
		$('input:radio[name=vote_val]').attr("disabled", "disabled"); 
		$("#vote_sub").attr("disabled", "disabled"); 
		$("#vote_status").hide().fadeIn(300).html('الرجاء الإنتظار <img src="imgs/loader.gif" width="16" height="16" align="baseline">');
		var url="funcs.php?do=add_vote&val="+ val +"&r="+r;
		$.get(url, function(msg) {
			if(msg== '1'){
						$("#vote_status").hide().fadeIn(300).html('تم التصويت بنجاح.. شكرا لك');
				get_vote(vid,val);
				}
				else if(msg== '2'){
						$("#vote_status").hide().fadeIn(300).html('خطأ .!!');
					}
				else if(msg== '3'){
						$("#vote_status").hide().fadeIn(300).html('لقد قمت بالتصويت مسبقا');
					}
		});
	}
	else{
	$("#vote_status").hide().fadeIn(300).html('تأكد من اختيار خيار التصويت');
		}
}
//####################################################################//
function get_vote(vid,sid){
		var url="funcs.php?do=get_vote&val="+ vid +"&sid="+ sid +"&r="+r;
		$.get(url, function(msg) {
			$("#vote_body").hide().fadeIn(300).html(msg);
		});
}
//####################################################################//
function ban_tab(val){
	x=0;
	while(x<4){
		x++;
	$("#ban_tab_"+x).hide().fadeOut(500);
	$("#lm_"+x).hide().fadeOut(500);
		$("#tab"+x).attr('class','l_ban_title'+ x);
		}
		var c=$("#tab"+val).attr('class');
		$("#tab"+val).attr('class',''+ c +' bbg');
	$("#ban_tab_"+val).fadeIn(500);
	$("#lm_"+val).fadeIn(500);
}
//####################################################################//
function ch_tab(val){
	ban_tab(val);
	v=parseInt(val);
	v=v+1;
	if(v>2){
		v=1;
		}
	setTimeout(function(){
	ch_tab(v);
	},10000);
}


//####################################################################//
function ad_tag(){
	$("#bg_div").hide().fadeIn(300);
	$("#ad_tag").slideDown(300);
}
function close_ad_tag(){
	$("#ad_tag").slideUp(300);
	setTimeout(function(){
	$("#bg_div").fadeOut(500);
	},600);
	}
//####################################################################//
function save_tag(){
	$("#pop_msg1").slideDown(300);
	$("#ad_tag").hide().fadeOut(300);
	var name=$("#t1").val();
	var email=$("#t2").val();
	var addr=$("#t3").val();
	var txt=$("#t4").val();
	var subj=$("#subj").val();
	
	
		$.post("funcs.php?do=save_tag&r="+r+"",{ name: $("#t1").val(),    
		email: $("#t2").val(), addr: $("#t3").val(), txt: txt , subj: $("#subj").val()}, function(msg) {
		setTimeout(function(){
		 done_tag();
		},2000);
		
	});

		
}
function done_tag(){
	$("#pop_msg2").slideDown(300);
	$("#pop_msg1").hide().fadeOut(300);
	setTimeout(function(){
	$("#pop_msg2").hide().fadeOut(600);
	$("#bg_div").fadeOut(600);
	},2000);

}
/*****************************************************/	

function ts(val){
	$("#txt_in").css("font-size",val+'pt');
	}
	
	
/*****************************************************/	
function get_ved(vid){
	$("#bg_div").hide().fadeIn(300);
	$("#ved_tab").html('<br><br><br><br><br><br><img src="imgs/load.gif" width="16" height="11" /><br> .. جاري التحميل  ');
	$("#ved_div").animate({"height": "toggle"}, { duration: 500 });
		var url="ved.php?pid="+ vid +"r="+r;
		$.get(url, function(msg) { 
			setTimeout(function(){
				$("#ved_tab").hide().fadeIn(500).html(msg);
			},1000);
		});
}
function get_ved2(vid){
	$("#bg_div").hide().fadeIn(300);
	$("#ved_tab").html('<br><br><br><br><br><br><img src="imgs/load.gif" width="16" height="11" /><br> .. جاري التحميل  ');
	$("#ved_div").animate({"height": "toggle"}, { duration: 500 });
		var url="ved2.php?pid="+ vid +"r="+r;
		$.get(url, function(msg) { 
			setTimeout(function(){
				$("#ved_tab").hide().fadeIn(500).html(msg);
			},1000);
		});
}
function close_ved(){
	$("#ved_div").animate({"height": "toggle"}, { duration: 500 });
	setTimeout(function(){
	$("#bg_div").fadeOut(500);
	},600);
	}
	
/*****************************************************/	
function get_img(img){
	$("#bg_div").hide().fadeIn(300);
	$("#imgs_des .img").attr('src','uploads/'+img);
	$("#imgs_des").hide().fadeIn(500).html(msg);
}
function close_img(){
	$("#imgs_des").animate({"height": "toggle"}, { duration: 500 });
	setTimeout(function(){
	$("#bg_div").fadeOut(500);
	},600);
	}
/*****************************************************/





	
function scrollWin(val){
$('html,body').animate({
scrollTop: $("#"+val+"").offset().top
}, 2000);
}
/*****************************************************/	
function news_control(val){
	if(val=='right'){$("#mrq").attr('scrollamount','4').attr('direction','right');}
	if(val=='left'){$("#mrq").attr('scrollamount','4').attr('direction','left');}
	if(val=='stop'){$("#mrq").attr('scrollamount','0')}
	}
/****************************************************/
function get_ho(val,val2){
	var nurl="hover_"+val2
	$("#"+val).attr('src','imgs/'+nurl+'')
	}function re_ho(val,val2){
	$("#"+val).attr('src','imgs/'+val2+'')
	}
/****************************************************/
function cha_car(val,val2){
	$("#care_img").attr('src',val);
	$("#care_txt").html(val2);
	}
	
	
/****************************************************/
/****************************************************/
function ad_gb(){
	$("#bg_div").hide().fadeIn(300);
	$("#ad_gb").slideDown(300);
}
function close_ad_gb(){
	$("#ad_gb").slideUp(300);
	setTimeout(function(){
	$("#bg_div").fadeOut(500);
	},600);
	}
function save_gb(){
	$("#pop_msg1").slideDown(300);
	$("#ad_gb").hide().fadeOut(300);
	var name=$("#gt1").val();
	var email=$("#gt2").val();
	var addr=$("#gt3").val();
	var txt=$("#gt4").val();

	$.post("funcs.php?do=save_gb&r="+r+"",{ name: $("#gt1").val(),    
email: $("#gt2").val(), addr: $("#gt3").val(), txt: txt}, function(msg) {
			setTimeout(function(){
			 done_gb();
			},2000);
			
		});
}
function done_gb(){
	$("#pop_msg2").slideDown(300);
	$("#pop_msg1").hide().fadeOut(300);
	setTimeout(function(){
	$("#pop_msg2").hide().fadeOut(600);
	$("#bg_div").fadeOut(600);
	},2000);

}
//####################################################################//
function get_gb_page(num){
	var url="funcs.php?do=get_gb_page&page="+ num +"&r="+r;
	$.get(url, function(msg) { 
		setTimeout(function(){
			$("#gb_ban").hide().fadeIn(500).html(msg);
			$("#wait").fadeOut(500).hide();
		},1000);
	});
	
	
				
			$("#gb_n").val(num);

}

//####################################################################//
function check_val(){
			setTimeout(function(){


	var num=$("#gb_n").val();
	var cont=$("#gb_count").val();
	cont=parseInt(cont);
	num=parseInt(num);
	if(num=='1'){
		$("#gg1").html('1');
		if(cont>10){$("#gg2").html('2');}else{$("#gg2").html('');}
		if(cont>20){$("#gg3").html('3');}else{$("#gg3").html('');}
		if(cont>30){$("#gg4").html('4');}else{$("#gg4").html('');}
		$("#gg5").html('');
		$("#gg6").html('');
		$("#gg7").html('');
		$("#gb_n").val(num);

	}
	
	if(num>'1'){
			var x=parseInt(num*10);
			$("#gg1").html(num);

			if(cont>x){$("#gg2").html(num+1);}else{$("#gg2").html('');}
			if(cont>x+10){$("#gg3").html(num+2);}else{$("#gg3").html('');}
			if(cont>x+20){$("#gg4").html(num+3);}else{$("#gg4").html('');}
			
			if(num-1>0){$("#gg5").html(num-1);}else{$("#gg5").html('');}
			if(num-2>0){$("#gg6").html(num-2);}else{$("#gg6").html('');}
			if(num-3>0){$("#gg7").html(num-3);}else{$("#gg7").html('');}
	}


		},100);

	
	

	}
//####################################################################//
function newPopup(url,w,h) {
	popupWindow = window.open(
		url,'popUpWindow','height='+h+',width='+w+',left=0,top=0,resizable=no,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no')
}
//####################################################################//

function get_prog_content(day,time){
	var url="funcs.php?do=prog_content&day="+day+"&time="+time+"&r="+r;
	$.get(url, function(msg) { 
		$("#daily_content").hide().fadeIn(200).html(msg);
	});
	}

//####################################################################//

function get_day_content(day){
	var url="funcs.php?do=day_content&day="+day+"&r="+r;
	$.get(url, function(msg) { 
		$("#contents").hide().fadeIn(200).html(msg);
	});
	}
//####################################################################//
function send_msg(){
	$("#msg_val").html('<img src="imgs/load.gif" width="16" height="11" />  الرجاء الإنتظار ');
	var txt=$("#t5").val();
	$.post("funcs.php?do=send_message&r="+r+"",{ y_name: $("#t1").val(),    
y_email: $("#t2").val() , f_name: $("#t3").val(),    
f_email: $("#t4").val(),    
rr: $("#rr").val() , y_msg: txt}, function(msg) {
			$("#msg_val").html(msg);
		});
}

//####################################################################//
function get_simg(val){
	var x=$("#pic_val").val();
	x=parseInt(x);

	$("#pic_"+val).fadeIn(600);
	$("#g_pic_"+val).attr("class","c_pic_img");
	$("#pic_"+x).fadeOut(600);
	$("#g_pic_"+x).attr("class","g_pic_img");
	$("#pic_val").val(val);
}


function get_pic(val){
	var x=$("#pic_val").val();
	var n=$("#pics_num").val();
	x=parseInt(x);
	n=parseInt(n);
	n=n+1;
	if(val=='next'){
		y=x+1;
		if(y<n){
			$("#pic_val").val(y);
			$("#pic_"+y).fadeIn(400);
			$("#g_pic_"+y).attr("class","c_pic_img");
			$("#pic_"+x).fadeOut(400);
			$("#g_pic_"+x).attr("class","g_pic_img");
		}
		else{
			$("#pic_val").val("0");
			get_pic('next');
			$("#g_pic_5").attr("class","g_pic_img");
			$("#pic_5").fadeOut(400);
			}
	}
	
	if(val=='last'){
		y=x-1;
		if(y>0){
			$("#pic_val").val(y);
				$("#pic_"+y).fadeIn(400);
				$("#g_pic_"+y).attr("class","c_pic_img");
				$("#pic_"+x).fadeOut(400);
				$("#g_pic_"+x).attr("class","g_pic_img");
		}
		else{
			$("#pic_val").val("6");
			get_pic('last');
			$("#g_pic_1").attr("class","g_pic_img");
			$("#pic_1").fadeOut(400);
			}
	}
}

//####################################################################//
function cont(){
	$("#bg_div").hide().fadeIn(300);
	$("#send_msg").slideDown(300);
}
function close_cont(){
	$("#send_msg").slideUp(300);
	setTimeout(function(){
	$("#bg_div").fadeOut(500);
	},600);
	}
//####################################################################//
function save_cont(){
	$("#cont_msg").hide().fadeIn(300).html('');
	var name=$("#ct1").val();
	var email=$("#ct2").val();
	var title=$("#ct3").val();
	var msg=$("#ct4").val();

	$.post("funcs.php?do=contact&r="+r+"",{ name: name,    
	email: email, title: title, msg: msg }, function(data) {
	$("#cont_msg").hide().fadeIn(300).html(data);
	if(data=='<center><font color=green>شكرا لك .. تم إرسال رسالتك بنجاح</font></center>'){
	setTimeout(function(){
		close_cont();
	},1000);
		}
	});

		
}

