	/*
		validate the data befor post
	*/
	function validate_to_submit(Lang)
	{
		if( Lang=="En")
		{
			$text1 = "Please select Presence time" ;
			$text2 = "Please fill Talk about your self box";
			$text3 = "Please select the Country for your match";
			$text4 = "Please select the Nationality for your match";
			$text5 = "Please select the Religion for your match";
			$text6 = "File is not within these types (JPEG,GIF)";
			$text7 = "File is not within these types (mpeg, dat, wmv, avi, mov, mpg, flv,rm)";
			$text8 = "Your Talk about your self exceeded 50 character";
			$text9 = 'You should upload your video first then publish it ';
			$text10  = 'You should upload your photo first then publish it ';   
		}
		else
		{
 			$text1 = "الرجاء اختيار وقت التواجد بالموقع";
			$text2 = "الرجاء تكلم/تكلمي عن نفسك";
			$text3 = "الرجاء اختيار بلد الاقامة لشريك حياتك";
			$text4 = "الرجاء اختيار الجنسية لشريك حياتك"  ;
			$text5 = "الرجاء اختيار الديانة لشريك حياتك";
			$text6 = "الملف يجب ان يكون من نوع(JPEG,GIF)";
			$text7 = "الملف يجب ان يكون من نوع(mpeg, dat, wmv, avi, mov, mpg, flv,rm)";
			$text8 = "الوصف الخاص بك تجاوز 50حرفا";
			$text9 = 'الرجاء تحميل ملف الفيديو قبل النشر';
			$text10 = 'الرجاء تحميل الصورة  قبل النشر';
		}
		//****presence time
		 if ( document.getElementById("presence_time").value=="none" )
		 {
		 	alert($text1);
		 	document.getElementById("presence_time").focus();
		 	return false;
		 }
		 //****user desc
		 if ( document.getElementById("user_desc").value=="" )
		 {
		 	alert($text2);
		 	document.getElementById("user_desc").focus();
		 	return false;
		 }
		 if ( document.getElementById("user_desc").value.length > 50 )
		 {
		 	alert($text8);
		 	document.getElementById("user_desc").focus();
		 	return false;
		 }
		 //**************
		 //*************country
		 if ( document.getElementById("country").value=="none" )
		 {
		 	alert($text3);
		 	document.getElementById("country").focus();
		 	return false;
		 }
		 //**********************
		 //***********natio
		 if ( document.getElementById("natio").value=="none" )
		 {
		 	alert($text4);
		 	document.getElementById("natio").focus();
		 	return false;
		 }
		 //**********************
		 //**********religion
		 if ( document.getElementById("religion").value=="none" )
		 {
		 	alert($text5);
		 	document.getElementById("religion").focus();
		 	return false;
		 }
			//****see if the box checkes
			if ( document.getElementById("photo_checkbox").checked )
			{
			//**************************
			//**********************photo
			str 	= document.getElementById("photo_id").value;
			photo_file	= document.getElementById("photo_file_exist").value;
			if(str != "")
				{
				    pos=str.lastIndexOf(".");
					if(pos == -1) 
					{
						window.alert($text6);
						document.getElementById("photo_id").focus();
						return false;
					}
					ext = str.substr(pos+1)
					if(!In_Ph_Array(ext))
					{
						window.alert($text6);
						document.getElementById("photo_id").focus();
						return false;
					}
				}
				else
				{
					if(photo_file == 0)
					{
						window.alert($text10);
						document.getElementById("photo_id").focus();
						return false;
					}
				}
			}
		 //***************************
		 //**********************video
		 //********************video check box
		 if ( document.getElementById("video_checkbox").checked )
		 {
			str 		= document.getElementById("video_id").value;
			video_file	= document.getElementById("video_file_exist").value;
			if(str != "")
				{
				    pos=str.lastIndexOf(".");
					if(pos == -1) 
					{
						window.alert($text7);
						document.getElementById("video_id").focus();
						return false;
					}
					ext = str.substr(pos+1)
					if(!In_video_Array(ext))
					{
						window.alert($text7);
						document.getElementById("video_id").focus();
						return false;
					}
				}
				else
				{
					if(video_file == 0)
					{
						window.alert($text9);
						document.getElementById("video_id").focus();
						return false;
					}
				}
		 }
		/*
		 document.getElementById("video_id").value = "";
		 document.getElementById("photo_id").value = "";	
		 */   
		 //***************************
		 
		 
	}
	/*
		the function that will upload the photo
	*/
	function upload_photo(Lang)
	{
		//*********form handler
			form_handler = document.getElementById('maktoobTV_id');
		//*********************
		form_handler.target = 'photo_upload';
		form_handler.action = "maktoobTV_upload.php?Lang="+Lang;
		//*********call wait display function
			wait_display_photo(Lang); 
		//***********************************
		//******upload type
			document.getElementById('upload_type_id').value = 1;
		//*****************
		form_handler.submit();
	}
	/*
		the function that will display wait msg to the user
	*/
	function wait_display_photo(Lang)
	{
		txt_to_display = "<font color='red'><b>الرجاء الانتظار...</b></font>"
		if(Lang == "En")
		{
			txt_to_display = "<b><font color='red'>wait for the upload please...</font></b>";
		}
		document.getElementById('uploaded_photo').innerHTML = txt_to_display;
	}
	/***
		display the returned text to the user
		from the photo upload
	***/
	function display_retuned_text_for_photo (text ,  state)
	{
		/*
		   state 3 means that we have error and we display it 
		   else the picture will be displayed
		*/
		if(state == '3')
		{
			document.getElementById('uploaded_photo').innerHTML = "<b><font color='red'>" + text + "</font></b>";
		}
		else
		{	
			random = 6*(Math.random()+7);
			document.getElementById('uploaded_photo').innerHTML ="<img src='../General/maktoobTV/maktoobTV-images/tmp-imgs/"+text+"_img.jpg?"+random+"' width='111' height ='131'/><br /> <b><font color='red'>"+state+"</font></b>";
		}
		//*********form handler
			form_handler = document.getElementById('maktoobTV_id');
		//*********************
		//****return thr form to the correct action
			form_handler.target = '_self';
			Lang = document.getElementById('page_lang').value;
			form_handler.action = "maktoobTVSubmit.php?Lang="+Lang;
		//*******************************************
		enable_submit();
	}

	//****************video upload 
	function upload_video(Lang)
	{
		//*********form handler
			form_handler = document.getElementById('maktoobTV_id');
		//*********************
		form_handler.target = 'video_upload';
		form_handler.action = "maktoobTV_upload.php?Lang="+Lang;
		//*********call wait display function
			wait_display_video(Lang); 
		//***********************************
		//******upload type
			document.getElementById('upload_type_id').value = 2;
		//*****************
		form_handler.submit();
	}
	/*
		the function that will display wait msg to the user
	*/
	function wait_display_video(Lang)
	{
		txt_to_display = "<font color='red'><b>الرجاء الانتظار...</b></font>"
		if(Lang == "En")
		{
			txt_to_display = "<font color='red'><b>wait for the upload please..</b></font>.";
		}
		document.getElementById('uploaded_video').innerHTML = txt_to_display;
	}
	/***
		display the returned text to the user
		from the photo upload
	***/
	function display_retuned_text_for_video (text ,  state)
	{
		/*
		   state 3 means that we have error and we display it 
		   else the picture will be displayed
		*/
		if(state == '3')
		{
			document.getElementById('uploaded_video').innerHTML = "<b><font color='red'>" + text + "</font></b>";
		}
		else
		{	
			random = 6*(Math.random()+7);
			document.getElementById('uploaded_video').innerHTML ="<a href=\"javascript:mplayer_popup('"+text+"','2')\"><img src='../General/maktoobTV/maktoobTV-videos/tmp-vids/"+text+"_vid.jpg?"+random+"' width='111' height ='131' border='0' accesskey='1'/></a><br /> <b><font color='red'>"+state+"</font></b>";
		}
		/*return the form to the correct action*/
			form_handler.target = '_self';
			Lang = document.getElementById('page_lang').value;
			form_handler.action = "maktoobTVSubmit.php?Lang="+Lang;
		//***********************************************
		enable_submit();
	}
	/*
		the types of the images
	*/
	function In_Ph_Array(type) 
	{
		if(type.toLowerCase()=="jpeg"){
		return true;
		}
		else if(type.toLowerCase()=="jpg"){
		return true;
		}
		else if(type.toLowerCase()=="gif"){
		return true;
		}
		else{
		return false;
		}
	}
	/*
		video types
	*/	
	function In_video_Array(type) 
	{
		if(type.toLowerCase()=="mpeg"){
		return true;
		}
		else if(type.toLowerCase()=="dat"){
		return true;
		}
		else if(type.toLowerCase()=="wmv"){
		return true;
		}
		else if(type.toLowerCase()=="avi"){
		return true;
		}
		else if(type.toLowerCase()=="mov"){
		return true;
		}
		else if(type.toLowerCase()=="mpg"){
		return true;
		}
		else if(type.toLowerCase()=="flv"){
		return true;
		}
		else if(type.toLowerCase()=="rm"){
		return true;
		}					
		else{
		return false;
		}
	}
	/*
		hide the browser for photo/video upload
	*/
	function hide_show_brows_photo_button()
	{
		if(document.getElementById('photo_checkbox').checked)
		{
			document.getElementById('photo_td').style.visibility="visible";
		}
		else
		{
			document.getElementById('photo_td').style.visibility="hidden";
		}
		enable_submit();
	}
	//*****video check box 
		function hide_show_brows_video_button()
	{
		if(document.getElementById('video_checkbox').checked)
		{
			document.getElementById('video_td').style.visibility="visible";
		}
		else
		{
			document.getElementById('video_td').style.visibility="hidden";
		}
		enable_submit();
	}
	//**************the video mplayer pop window
	function mplayer_popup(flvid,flvpath)
	 {
	 	window.open('flv_mplayer.php?flvid='+flvid+'&file_path='+flvpath,'hhhh','toolbar=0,location=0,status=0,scrollbars=1,resizable=0,left=100,top=10,width=500,height=350');
	 }
	 /******when any information change in the page
	 		the save butoon should be enabled
	 ********/
	 function enable_submit()
	 {
	 	document.getElementById('save_button').disabled=false;
	 }
	 /*** calculate the user desc characters and trem them
	 	  more than the max value specified	 
	 **/
	 /** @param 
	 	field - the string field, 
	 	count - the field for remaining characters number 
	 	max - the maximum number of characters
	 **/	
		function CountLeft() {
		//***enble the submit enabled
			enable_submit();
		//***************************	
		// if the length of the string in the input field is greater than the max value, trim it
		max		= 50 ;
		field	= document.getElementById("user_desc");
		count	= document.getElementById("counter"); 
		if (field.value.length > max)
		field.value = field.value.substring(0, max);
		else
		// calculate the remaining characters
		count.value = max - field.value.length;
		}