



var force_fill_once		=null;




	var arr_comment_items				=new Array();
	var curr_index_in_arr_comment_items	=0;
	var max_n_items_in_comment			=0;
	var max_per_page_in_comment			=20;
	

		
	

		
function test_submit_form(form_id){

	var error_for_empty='لطفا همه فیلدها را تکمیل نماييد';
	if(site_lang=='en')
		error_for_empty='please fill all entries.';
		

		for(i in arr_qst_titles2){
			
			qst_pattern			=arr_qst_titles2[i][2];
			
			if(qst_pattern==8)
				continue;
			
			str="var obj_table=talar_form_"+form_id;
			eval(str);
			
			str="obj_element=talar_form_"+form_id+".qst_"+i+"_"+qst_pattern+"_"+1;
			eval(str);

			//alert("form_id="+form_id+"   ,   qst_pattern="+qst_pattern+"       i="+i+"      ");

			ss='';
			for(m=0;m<obj_table.getElementsByTagName("input").length;m++){
				if(obj_table.getElementsByTagName("input")[m].getAttribute('type')=='file'){
					obj_element=obj_table.getElementsByTagName("input")[m];
					if(obj_element.value==''){
						alert(error_for_empty);
						obj_element.focus();
						return false;
					}
				}
			}

			//alert(obj_element);
			if(obj_element===undefined)
				continue;
				/*
			if(obj_element==undefined)
				alert('lkl');
				
			if(obj_element.value===null)
				alert('lkl');
			*/
			value=obj_element.value;
			

			if(qst_pattern==1){
				if(value==''){
					alert(error_for_empty);
					obj_element.focus();
					return false;
				}
			}
			if(qst_pattern==2){
				if(value==''){
					alert(error_for_empty);
					obj_element.focus();
					return false;				
				}
			}
			if(qst_pattern==3){
				if(value==0){
					alert(error_for_empty);
					obj_element.focus();
					return false;				
				}
			}
			if(qst_pattern==5){
				var is_it_ok=false;
				for(i=0;i<obj_element.length;i++){
					if(obj_element[i].checked){
						is_it_ok=true;
						break;
					}
					
				}

				if(!is_it_ok){
					alert(error_for_empty);
					obj_element[0].focus();
					return false;				
				}
			}				

			
		}		
		

	return true;
	
}
	function show_full_payam_class(url,id_element,n_qst){
		
		this.xmlhttp_1		=null;
		this.obj			=null;
		this.n_qst			=0;
		
		this.on_complete_1	=function(){
			
			var c_xml=this.xmlhttp_1;
			if(c_xml===false){
				alert('error 87');
				return;
			}

			x			=c_xml.childNodes;
			if(x.length==0 || x.length==null){
				alert('.این پيام فعال نمي باشد');
				return;
			}
	
			var obj55	=c_xml.getElementsByTagName("noskhe")[0];
			payam		=obj55.getElementsByTagName("qst_"+this.n_qst)[0].childNodes[0].nodeValue;
			
			
			this.obj.innerHTML=payam;
	
		};
		this.init = function(){
			this.url		=url;
			this.id_element=id_element;
			this.n_qst		=n_qst;
			
			eval("this.obj=document.getElementById('"+id_element+"')");
			//alert(id_element);
			this.obj.innerHTML="<img src='"+host_address+"/"+site_lang+"/pictures/loading2.gif'>";
			//alert('nnn');
			var self=this;
			var aj1	=new sack();
			
			aj1.requestFile		= url;
			aj1.onCompletion	= function(){  self.xmlhttp_1=this.responseXML;   self.on_complete_1();  };	
			aj1.runAJAX();		
		};
		this.init();		
	}
	
	
	function class3(url,on_compelete_func){
		
		this.xmlhttp			=null;
		this.url				='';
		this.on_compelete_func	='';
		
		this.on_complete3=function(){
			var c_xml=this.xmlhttp;
			if(c_xml===false){
				alert('error 87');
				return;
			}
			//alert(on_compelete_func);
			eval(this.on_compelete_func);
			
		};
		this.on_error1=function(){
			//alert('error in downloading ');
			eval(this.on_compelete_func);
			return(null);
		};
	
		this.init = function(){
			
			this.url				=url;
			this.on_compelete_func	=on_compelete_func;
			
			var self=this;
			var aj1	=new sack();
			//alert(url);
			aj1.requestFile		= this.url;	
			aj1.onCompletion	= function(){  self.xmlhttp=this.responseXML;   self.on_complete3();  };	
			aj1.onError			= function(){  self.on_error1();  };	
			aj1.runAJAX();		
		};
		this.init();
	}
		
	





function get_table_of_pattern(pattern,number,index_nfile){

		if(arr_qst_width_height[number]==null || arr_qst_width_height[number]==undefined){
			width	=10;
			height	=10;
		}
		else{
			width	=arr_qst_width_height[number][0];
			height	=arr_qst_width_height[number][1];
		}
		
		
		value='';
		
		var i;
		for(i=0;i<arr_qst_defaults.length;i++){
			if(arr_qst_defaults[i][0]==number){
				value=arr_qst_defaults[i][1];
				break;
			}
		}
		
		
		//f_color=lable_normal_color;
		
		if(arr_submitted_values.length>0){
			//alert(arr_submitted_values);
			for(i=0;i<arr_submitted_values.length;i++){
				if(arr_submitted_values[i][2]==number){
					value		=arr_submitted_values[i][0];//value
				}
			}
			/*
			if(arr_submitted_values[number]!=null  && arr_submitted_values[number]!=undefined){
				value		=arr_submitted_values[number][0];//value
			}
			*/
		}
		

		
		switch(pattern){
			case "1":
				name="qst_"+number+"_"+pattern+"_1";
				answer_control="<input "+dir+" value='"+value+"'  name='"+name+"' style='font-family:tahoma;font-size:8pt;width:"+width+";'>";
				break;						
			case "2":
				name="qst_"+number+"_"+pattern+"_1";			
				answer_control="<textarea  "+dir+" name='"+name+"'  style='font-family:tahoma;font-size:8pt;width:"+width+";height:"+height+"'>"+value+"</textarea>";
				break;
			case "3":
				name="qst_"+number+"_"+pattern+"_1";			
				answer_control="<select "+dir+" name='"+name+"'   style='font-family:tahoma;font-size:8pt;width:"+width+"'>";
				count=arr_items.length;
				//alert("count="+count);
				
				for(p=0;p<count;p++){
					selected='';
					if(value==p)
						selected='selected';
					answer_control+="<option "+selected+" value='"+p+"'>"+arr_items[p];
				}
				answer_control+="</select>";
				break;		
			case "4":
							
				answer_control="";
				count=arr_items.length;
				for(p=0;p<count;p++){
					name="qst_"+number+"_"+pattern+"_"+p+"_0_0";
					answer_control+="<input  name='"+name+"'  type='checkbox' >"+arr_items[p];
				}
				break;
			case "5":
				name="qst_"+number+"_"+pattern+"_1_0_0";
				answer_control="";
				count=arr_items.length;
				for(p=0;p<count;p++){
					lable=arr_items[p];
					re=/ /gm;
					lable=lable.replace(re,"&nbsp; ");
					answer_control+="<input  name='"+name+"'  type='radio' value='"+p+"'>"+lable;
				}
				break;		
			case "6":
				name="qst_"+number+"_6_"+index_nfile+"_0_0";//qst_number_pattern_qstnumber2_number_index
				answer_control="";
				answer_control+="<input style='width:"+width+"' name='"+name+"'  type='file' value='' dir=ltr>";
				name="qst_"+number+"_1_"+index_nfile+"_0_0";
				answer_control+="<input type=hidden value='---' name='"+name+"' >";
				break;	
			case "7":
				name="qst_"+number+"_7_"+index_nfile+"_0_0";			
				answer_control="";
				answer_control+="<input style='width:"+width+"' name='"+name+"'  type='file' value='' dir=ltr>";
				name="qst_"+number+"_1_"+index_nfile+"_0_0";
				answer_control+="<input type=hidden value='---' name='"+name+"' >";				
				break;	
			case "8":
				name="qst_"+number+"_"+pattern+"_1";;			
				answer_control="<input  type=hidden name='"+name+"'  >";
				break;	
			case "9":
				//alert('999999999');
				answer_control="<select "+dir+" name=subject_second style='width:"+width+";font-family:tahoma;font-size:8pt'>";
				//alert(c_xml_node_list);
				//	alert(c_xml_node_list.xmlhttp);
				//if(c_xml_node_list==undefined || c_xml_node_list==null || c_xml_node_list===false || c_xml_node_list.xmlhttp==null || c_xml_node_list.xmlhttp==undefined){
				if(c_xml_node_list==undefined || c_xml_node_list==null  || c_xml_node_list===false ){
					//alert('ddd');
					answer_control+="<option value='0-10004'>ريشه</select>";
					break;
				}
				node_count	=c_xml_node_list.getElementsByTagName("sbj").length;
				sbj_count=c_xml_node_list.getElementsByTagName("sbj").length;
				selected="";
				//alert("sbj_count="+sbj_count);
				for(i=0;i<sbj_count;i++){
					if(i==0)
						continue;
					if(i==7)
						selected=" selected ";
					obj		=c_xml_node_list.getElementsByTagName("items")[0];
					n_node	=obj.getElementsByTagName("sbj")[i].getAttribute("node");
					count	=obj.getElementsByTagName("sbj")[i].getAttribute("count");
					//alert("n_node="+n_node);
					value	=c_xml_node_list.getElementsByTagName("sbj")[i].childNodes[0].nodeValue;
					answer_control+="<option "+selected+" value='10004-"+n_node+"'>"+value;
				}
				answer_control+="</select>";
				//alert(answer_control);
				break;				
			case "10":
				name1="qst_"+number+"_10_1";			
				name2="qst_"+number+"_1_1";			
				answer_control="";
				answer_control+="<div dir=ltr align=right><input style='width:"+width+"' name='"+name1+"'  type='file' value='' dir=ltr></div>";
				answer_control+="<input name='"+name2+"'  type='hidden' value='' dir=ltr>";
				break;	
			case "12":
				name="qst_"+number+"_"+pattern+"_1";			
				answer_control="<textarea  name='"+name+"'  style='font-family:tahoma;font-size:8pt;width:"+width+";height:"+height+"'></textarea>";
				break;
			case "13":
				ramz=randomString();
				//alert(Math.random());
				name="qst_"+number+"_"+pattern+"_1";
				answer_control="<input dir=ltr readonly  style='text-align:center;width:70;font-family:arial;font-weight:bold;font-size:12pt' type=text value='"+ramz+"' name='"+name+"' >";
			case "16":
				name="qst_"+number+"_"+pattern+"_1";
				answer_control="<input dir=ltr  type=password name='"+name+"' style='font-family:tahoma;font-size:8pt;width:"+width+";'>";
				break;						
						

				break;				
			default:
				answer_control="&nbsp;";
		}
		return answer_control;
			
}

function randomString() {
	var chars = "123456789abcdefghikmnpqrstuvwxyz";
	var string_length = 5;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return(randomstring);
}


function sortNumber(a,b){
	return b - a;
}
function show_full_payam(nfile,id_element){
	
	url		=host_address+"/"+site_lang+"/xml/board/"+nfile+".xml";
	c_xml	=new show_full_payam_class(url,id_element,5);
			
}
function show_full_payam2(nfile,id_element,n_qst,xml_folder){
	
	url		=host_address+"/"+site_lang+"/xml/"+xml_folder+"/"+nfile+".xml";
	c_xml	=new show_full_payam_class(url,id_element,n_qst);
			
}

function get_element_value(obj,element){
	
	if(obj==null)
		return('');

	x			=obj.childNodes;
	value		='';
	
	for (m=0;m<x.length;m++){
		if (x.item(m).nodeType==1){
			if(x.item(m).nodeName==element){
				
				cmd="var obj7=obj.getElementsByTagName(\""+element+"\")[0].childNodes";
				eval(cmd);				
				
				if(obj7.length==0)
					value="---";		
				else
					value=obj7[0].nodeValue;


				break;
			}
		}
	}
	
	if(value=='')
		return("---");
	else
		return value;

}

var arr_talar_items=new Array();
var curr_index_in_arr_talar_items=0;
var max_n_items_in_talar=0;
var max_per_page_in_talar=20;





	function feedback_submit_form(message,form_number){
			

		var have_error=false;
		for(i in arr_submitted_values){
			if(arr_submitted_values[i][1]!=''){
				have_error=true;
				break;
			}
		}
		
		var qst_numbers_that_have_error='';
		regexp=/arr_submitted_values\s+=new Array/g;
		
		if(have_error){
			
			if(site_lang=='en')
				alert("error in form submition!");
			else
				alert("! خطا در تکميل فرم");

				
			//alert(arr_submitted_values);
			//alert('h1');
			//alert(document.getElementById('feedback_error_section'));
			document.getElementById('feedback_error_section').innerHTML=make_error_string();
			//alert('h2');
			
			eval("show_new_empty_form_"+form_number+"('');");
			window.scroll(0,50);
			
			
		}else{

			document.getElementById('feedback_error_section').innerHTML="";
			cmd="document.getElementById('talar_form_section_div_"+form_number+"').innerHTML=message;";
			eval(cmd);
			arr_submitted_values=new Array();
			//window.scroll(0,50);
			
			
			//createCookie("form_"+form_number,"filled",10);
			
			
			eval("handling_cookie_if_needed_"+form_number+"('');");
			//form_properties		=c_xml_talar_form.getElementsByTagName("properties"			)[0].childNodes[0].nodeValue;
			//alert(form_properties);
		}
		
	}

		
		

	function make_error_string(){
	
	
		//alert(arr_submitted_values);
		var k=0;
		var arr_error=new Array();
		for(i in arr_submitted_values){
			//alert('i='+i);
			error=arr_submitted_values[i][1];
			
			if(error==undefined || error==null || error=='')
				continue;
				
			//alert(error);
			re=/\"([^\"]+)\"/gm;
			error=error.replace(re,"<font color='"+error_font_color2+"'>\" $1 \"</font>");
			//alert(error);		
			
			arr_error[k]=error;
			k++;
		}
		str=arr_error.join('<br>');
		//alert(str);
		str="<font style='font-size:8pt;line-height:200%' color='"+error_font_color1+"'>"+str+"</font><br><br>";
		//alert(str);
		return str;
	}

	







	
function submit_form(id,form_id,style_submit){


	

eval(id+".submit();");		



	
	
	
	
	
	return false;
	


}
var arr_qst_titles			=new Array();
var arr_qst_width_height	=new Array();
var arr_items				=new Array();
var arr_qst_defaults		=new Array();

function get_qst_widths(str_properties){
	var result=new Array();
	var re;
	var arr;
		
	re=/^(\d+)=(\d+)(-(\d+)){0,1}/mg;
	//re=/^(\d+)=/mg;
	while ((arr = re.exec(str_properties)) != null){
		n=arr[1];
		if(Number(n)>500)
			continue;
		//alert("n="+n);
		//alert("2="+arr[2]);
		//alert("3="+arr[3]);
		//alert("4="+arr[4]);
		result[n]=new Array();
		result[n][0]=arr[2];
		result[n][1]=arr[4];
		//alert(arr);
	}

	
	return result;
}
function get_form_properties(str_properties){
	var result=new Array();
	var re;
	var arr;
	
	
	//alert('d1');
/*
	------- document: -------
	0=99 	table_w-first_td_w
	1=98	excepts
*/	

	//var str_properties="99=350-150,920-90";

	//re=/^99=(.+)/mg;
	//re=/99=(.+)/;

	var re = new RegExp("^99=(.+)","mg");
	arr = re.exec(str_properties);

	//alert(arr);
	
	s=arr[1];
	result[0]=s.split("-");
	
	
	
	var re = new RegExp("^98=([^,]+)","mg");
	//re=/^98=([^,]+)/mg;
	arr = re.exec(str_properties);
	//alert(arr);
	if(arr!=null){
		s=arr[1];	
		result[1]=s.split("-");
	}else
		result[1]=0;
	
	//alert('d3');
	
	var re = new RegExp("^504=([^,]+)","mg");
	//re=/^504=([^,]+)/mg;
	arr = re.exec(str_properties);
	if(arr!=null){
		result[2]=arr[1];
	}else
		result[2]='';
	
		
	//alert("str_properties="+str_properties);
	//re=/^512=([^,]+)/mg;
	var re = new RegExp("^512=([^,]+)","mg");
	//re=/512=(.*)/mg;
	//re=/\d+=([^,]+)/mg;
	arr = re.exec(str_properties);
	
	//alert(str_properties);
	//alert(arr);
	
	if(arr!=null){
		result[3]=arr[1];
	}else
		result[3]='';
	
		
	var re = new RegExp("^518=([^,]+)","mg");
	//re=/^518=([^,]+)/mg;
	arr = re.exec(str_properties);
	if(arr!=null){
		result[4]=arr[1];
	}else
		result[4]='';
	
	
	
	return (result);
}
function show_talar_form(form_id,relations,style_form,style_submit,form_bgcolor,style_function){
	//alert('start show_talar_form='+form_id);
	eval("var loading_logo_for_ajax=document.getElementById('loading_logo_for_ajax_"+form_id+"')");
	eval("var talar_form_section_div=document.getElementById('talar_form_section_div_"+form_id+"')");
	eval("var c_xml_talar_form=c_xml_talar_form_"+form_id);
	
	
	loading_logo_for_ajax.style.visibility='hidden';
	
	talar_form_section_div.innerHTML="";
	var my_table=document.createElement("TABLE");
	var tbody=document.createElement("TBODY");
	my_table.appendChild(tbody);
	
	talar_form_section_div.appendChild(my_table);
	my_table.cellSpacing=0;
	my_table.cellPadding=0;
	
	my_table.width='100%';	
	
	//alert('4');
	
	
	//xmlDoc_for_talar=loadxml2("form/"+form_id+".xml");
	
	main_title_number		=c_xml_talar_form.getElementsByTagName("main_title_number"	)[0].childNodes[0].nodeValue;
	main_body_number		=c_xml_talar_form.getElementsByTagName("main_body_number"	)[0].childNodes[0].nodeValue;
	form_title			=c_xml_talar_form.getElementsByTagName("title"				)[0].childNodes[0].nodeValue;
	form_properties		=c_xml_talar_form.getElementsByTagName("properties"			)[0].childNodes[0].nodeValue;
	form_number			=form_id;
	//form_noskhe			=c_xml_talar_form.getElementsByTagName("form_noskhe"		)[0].childNodes[0].nodeValue;


	//alert(form_title);
	
	submit_lable='ارسال';
	this_dir='rtl';
	this_align='left';
	if(site_lang=='en'){
		this_dir='ltr';
		this_align='right';
		submit_lable='&nbsp;send&nbsp;';
	}
	
	re=/<br \/>/gm;
	form_properties=form_properties.replace(re,"\n");

	
	//alert('6');
	//alert(form_properties);
	
	arr=get_form_properties(form_properties);
	
	//alert(form_properties);
	
	table_width	=arr[0][0];
	title_width	=arr[0][1];
	email		=arr[2];
	

	
	//alert("email="+email);
	qst_excepts		=arr[1];
	qst_seq			=arr[3];
	qst_defaults	=arr[4];
	
	
	//alert("qst_seq="+qst_seq);
	
	
	a					=qst_defaults.split("-");
	for(i=0;i<a.length;i++){
		s=a[i];
		a2=s.split("=");
		arr_qst_defaults[i]=new Array();
		arr_qst_defaults[i][0]=a2[0];
		arr_qst_defaults[i][1]=a2[1];
	}	



	
	
	
	
	//alert(qst_excepts);
	
	//alert('7');
	
	
	arr_qst_width_height=get_qst_widths(form_properties);
	if(form_bgcolor==undefined)
		form_bgcolor="#CE6538";
	
	var result="<form method='POST' id='talar_form_"+form_id+"' target='upload_target_"+form_id+"' action='"+host_address+"/app5.php' ENCTYPE='multipart/form-data'>";
	

	//alert('8');
	
	result+="<input type='hidden' name='func' 				value='68'>";
	result+="<input type='hidden' name='subsite' 			value="+subsite+" >";
	result+="<input type='hidden' name='subject' 			value='10004-0'>";
	result+="<input type='hidden' name='actual_name' 		value=''>";
	result+="<input type='hidden' name='form_relations' 	value='"+relations+"'>";
	result+="<input type='hidden' name='lang' 				value='"+site_lang+"'>";
	result+="<input type='hidden' name='home_nodes' 		value=''>";
	result+="<input type='hidden' name='submit_from_client' value='yes'>";
	result+="<input type='hidden' name='username' 			value='visitor'>";
	result+="<input type='hidden' name='form_number' 		value='"+form_number+"'>";
	result+="<input type='hidden' name='email' 				value='"+email+"'>";

	
	
	qst_count			=c_xml_talar_form.getElementsByTagName("qst").length;
	
	//alert("qst_count="+qst_count);
	
	qst_row=new Array();
	var i=0;
	


	
	
	
	obj					=c_xml_talar_form.getElementsByTagName("noskhe")[0];
	obj0				=obj.getElementsByTagName("questions")[0];
			
	
	for(i=0;i<qst_count;i++){
		
		obj					=obj0.getElementsByTagName("qst")[i];
		
		
		number				=obj.getAttribute("number");
		
		
		
		//alert("number1="+number);
		
		flag=false;
		for(m in qst_excepts){
			if(qst_excepts[m]==number){
				flag=true;
				break;
			}
		}
		if(flag){
			//alert('break for='+i);
			continue;
		}
			
		qst_tozih='';
		
		

		
		
		qst_title			=obj.getElementsByTagName("title"	)[0].firstChild.data;
		qst_lang			=obj.getElementsByTagName("lang"	)[0].firstChild.data;
		qst_pattern			=obj.getElementsByTagName("pattern"	)[0].firstChild.data;
		qst_ertefa			=obj.getElementsByTagName("ertefa"	)[0].firstChild.data;
		qst_gozineha		=obj.getElementsByTagName("gozineha")[0];
		qst_gozineha_count	=qst_gozineha.getElementsByTagName("item").length;
		
		
		
		
		arr_qst_titles[i]=qst_title;
		
		//alert(qst_lang);
		
		if(qst_lang=='farsi')
			dir=' dir=rtl ';
		else
			dir='dir=ltr ';
			
		//alert("qst_gozineha_count="+qst_gozineha_count);
		
		arr_items=new Array();
		for(j=0;j<qst_gozineha_count;j++){
			s=qst_gozineha.getElementsByTagName("item")[j].childNodes[0].nodeValue;
			arr_items[j]=s;
			//alert("s="+s);
		}
		
		
		c=1;

		answer_control=get_table_of_pattern(qst_pattern,number,c);

		//alert('num='+number);
		c=qst_row.length;
		qst_row[c]=new Array();
		qst_row[c][0]=answer_control;
		qst_row[c][1]=qst_title;
		qst_row[c][2]=qst_pattern;
		qst_row[c][3]=qst_tozih;
		qst_row[c][4]=number;
		//qst_row[number][4]=value;

		
		
		//alert("number2="+number);
		//alert("number="+number+" , qst_count="+qst_count +" , i="+i);
		arr_qst_titles2=qst_row;
	}

	bgcolor2='#F0F5FC';
	bgcolor2='#D6D7D9';
	
	//alert("2");
	//alert("style_function="+style_function);
	
	if(style_function!="" && style_function!=undefined){
		eval("result+="+style_function+";");
		//alert('xxx---');
		
		var my_row	=document.createElement("TR");
		var my_td	=document.createElement("TD");
		tbody.appendChild(my_row);
		my_row.appendChild(my_td);


		my_td.innerHTML=result;
		//alert('ddd');
		return;
	}
		
	//alert('ddddd 6666 dddddddd');

	






	if(style_submit==undefined)
		style_submit=0;
		
	
	
	//result="fffff";

	var my_row	=document.createElement("TR");
	var my_td	=document.createElement("TD");
	tbody.appendChild(my_row);
	my_row.appendChild(my_td);

	//alert(result);
	
	my_td.innerHTML=result;

	//show_answers_for_a_feedback(id,page);
		
}



var my_this_page=0;


function write_goto_page_link(n_file,max_n_items,n_item_this_page){
	
	//alert(max_n_items+" "+n_item_this_page);	
	goto_page_links2.innerHTML="";
	//alert('1');
	var n_page=Math.ceil(max_n_items/n_item_this_page);
	//alert(n_page);
	
	var result="<table border=0 align=center cellpadding=0 cellspacing='1'><tr ><td>";
	result+="<table align=right border='0' cellspacing='1' bgcolor='silver' style='font-family:tahoma;font-size:8pt;line-height:180%' dir='rtl'><tr bgcolor=white>";
	for(i=1;i<=n_page;i++){
		//alert(i);
		bgcolor='white';
		//alert("this_page="+this_page);
		//alert(i);
		//alert('h1');
		if(i>1){
			//alert('h2');
			if(((i-1)%20)==0){
				//alert('h3');
				result+="</tr></table></td></tr><tr><td><table align=right border='0' cellspacing='1' bgcolor='silver' style='font-family:tahoma;font-size:8pt;line-height:180%' dir='rtl'><tr bgcolor=white>"
			}
		}
		//this_page
		if(i==my_this_page)
			bgcolor="LightSkyBlue";
		result+="<td title='رجوع به صفحه شماره "+i+"' width=23 bgcolor='"+bgcolor+"' align=center dir=ltr onmouseover=over_td(this); onmouseout=out_td(this); style='cursor:hand' onmousedown=show_a_feedback("+n_file+","+i+")>"+i+"</td>";	
	}
	
	result+="</tr></table></td></tr></table>";
	//goto_page_links1.innerHTML=result;
	goto_page_links2.innerHTML=result;
	
				
}

function over_td(obj){
	var x=obj.innerText;
	if(x==my_this_page)
		obj.bgColor='LightSkyBlue';
	else
		obj.bgColor='#d7eeff';
		
}		
function out_td(obj){
	var x=obj.innerText;
	if(x!=my_this_page)
		//obj.bgColor='LightSkyBlue';		
	obj.bgColor='white';
	
}	





var my_this_page=1;



function write_goto_page_link_in_talar(max_n_items,n_item_this_page,node,nform,this_page){
	
	//alert("this_page="+this_page);	
	//goto_page_links2.innerHTML="";
	//alert('1');
	var n_page=Math.ceil(max_n_items/n_item_this_page);
	//alert(n_page);
	
	var result="<table border=0 align=right cellpadding=0 cellspacing='1'><tr><td colspan=2 height=20></td></tr><tr ><td>";
	result+="<table border=0 align=right cellpadding=0 cellspacing='1'><tr ><td>";
	result+="<table align=right border='0' cellspacing='1' bgcolor='silver' style='font-family:tahoma;font-size:8pt;line-height:180%' dir='rtl'><tr bgcolor=white>";
	for(i=1;i<=n_page;i++){
		//alert(i);
		bgcolor='white';
		//alert("this_page="+this_page);
		//alert(i);
		//alert('h1');
		if(i>1){
			//alert('h2');
			if(((i-1)%30)==0){
				//alert('h3');
				result+="</tr></table></td></tr><tr><td><table align=right border='0' cellspacing='1' bgcolor='silver' style='font-family:tahoma;font-size:8pt;line-height:180%' dir='rtl'><tr bgcolor=white>"
			}
		}
		//this_page
		if(i==this_page)
			bgcolor="LightSkyBlue";
		result+="<td title='رجوع به صفحه شماره "+i+"' width=23 bgcolor='"+bgcolor+"' align=center dir=ltr onmouseover=over_td(this); onmouseout=out_td(this); style='cursor:hand' onmousedown=f18("+i+","+node+")>"+i+"</td>";	
	}
	
	result+="</tr></table></td></tr></table>";
	result+="</td><td width=120 align=left valign=top dir=rtl style='font-family:tahoma;font-size:8pt;color:green'>رجوع به صفحه شماره:</td></tr><tr><td colspan=2 height=20></td></tr></table>";
	
	return(result);
	//goto_page_links1.innerHTML=result;
	//goto_page_links2.innerHTML=result;
	
				
}







 
 
var fadebgcolor="#004967";
 
////NO need to edit beyond here/////////////
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, onetime, displayorder,element_id){
this.flag=0
this.onetime=onetime
this.element_id=element_id;
 
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=5 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
 
var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2

if (iebrowser&&dom||dom){ //if IE5+ or modern browsers (ie: Firefox)

//alert('x3');

	if(element_id==undefined)
		document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:10;-moz-opacity:10;-khtml-opacity:10;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:10;-moz-opacity:10;background-color:'+fadebgcolor+'"></div></div>')
	else{
		//alert('x4');
		cmd="var mo_obj=document.getElementById('"+element_id+"');";
		eval(cmd);
		//alert(mo_obj);
		mo_obj.innerHTML=('<div align=left id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:10;-moz-opacity:10;-khtml-opacity:10;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:10;-moz-opacity:10;background-color:'+fadebgcolor+'"></div></div>')
		//alert('x5');
	}
}
else{
	
	//document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
	cmd="var mo_obj=document.getElementById('"+this.element_id+"');";
	eval(cmd);
	mo_obj.innerHTML=('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>');
	
}
 
if (iebrowser&&dom||dom){ //if IE5+ or modern browsers such as Firefox
	//alert('s6');
	this.startit();
}
else{
	this.curimageindex++
	
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}
 
function fadepic(obj){
	//mohammad:89-7-1
	try{
		if (obj.degree<100){
			obj.degree+=2.5 
			if (obj.tempobj.filters&&obj.tempobj.filters[0]){
				if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
					obj.tempobj.filters[0].opacity=obj.degree
				else //else if IE5.5-
					obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
			}
			else if (obj.tempobj.style.MozOpacity)
				obj.tempobj.style.MozOpacity=obj.degree/101
			else if (obj.tempobj.style.KhtmlOpacity)
				obj.tempobj.style.KhtmlOpacity=obj.degree/100
			else if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
				obj.tempobj.style.opacity=obj.degree/101
		}
		else{
			clearInterval(fadeclear[obj.slideshowid])
			obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
			obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
			if(obj.flag&&obj.onetime)
				return;
				
			//alert("obj.postimages.length="+obj.postimages.length);
			if(obj.nextimageindex==obj.postimages.length-1)
				obj.flag=1;
			//alert("obj.nextimageindex="+obj.nextimageindex);
			obj.populateslide(obj.tempobj, obj.nextimageindex)
			obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
			setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
		}
	}
	catch(e){
		return;
	}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
	var slideHTML=""
	if (this.theimages[picindex][1]!=""){ //if associated link exists for image
		//alert(picindex);
		slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
	}
	slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
	if (this.theimages[picindex][1]!="") //if associated link exists for image
		slideHTML+='</a>'
	picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(){
	//mohammad 89-7-1:
	try{
		if (this.pausecheck==1) //if pause onMouseover enabled, cache object
		var cacheobj=this
		if (this.mouseovercheck==1)
			setTimeout(function(){cacheobj.rotateimage()}, 100)
		else if (iebrowser&&dom||dom){
			this.resetit();
			var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
			crossobj.style.zIndex++;
			fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
			this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
		}
		else{
			var ns4imgobj=document.images['defaultslide'+this.slideshowid]
			ns4imgobj.src=this.postimages[this.curimageindex].src
		}
		this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
	}
	catch(e){
		return;
	}
}
 
fadeshow.prototype.resetit=function(){
	this.degree=10;
	
	//mohammad:89-7-1:
	//if(crossobj.filters==null || crossobj.filters==undefined)
	//	return;
	try{
		var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
		if (crossobj.filters&&crossobj.filters[0]){
			if (typeof crossobj.filters[0].opacity=="number") //if IE6+
			crossobj.filters(0).opacity=this.degree
			else //else if IE5.5-
			crossobj.style.filter="alpha(opacity="+this.degree+")"
		}
		else if (crossobj.style.MozOpacity)
			crossobj.style.MozOpacity=this.degree/101
		else if (crossobj.style.KhtmlOpacity)
			crossobj.style.KhtmlOpacity=this.degree/100
		else if (crossobj.style.opacity&&!crossobj.filters)
			crossobj.style.opacity=this.degree/101;
	}
	catch(e){
		return;
	}
}
 
 
fadeshow.prototype.startit=function(){
	//alert('startit this.curimageindex='+this.curimageindex);
	var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
	this.populateslide(crossobj, this.curimageindex)
	if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
		var cacheobj=this
		var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
		crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
		crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
	}
	this.rotateimage()
}
 
 
 




	
	function class_show_one_image(nfile,element_id,image_folder){
		this.nfile			=0;
		this.xmlhttp		=null;
		this.pic_obj		=null;
		this.pic_obj_link	=null;
		this.image_folder	='w100';
		


		this.show_picture=function(){
			var c_xml=this.xmlhttp;			
			
			obj_pic		=c_xml.getElementsByTagName("noskhe")[0];
			pic_title	=get_element_value(obj_pic,'qst_1');
			pic_name	=get_element_value(obj_pic,'qst_2');
			
			//alert(this.image_folder);

			if(this.image_folder!='w100'){
	    		this.pic_obj.style.filter="blendTrans(duration=1)";
	   			this.pic_obj.filters.blendTrans.Apply();
	   			
				if (this.pic_obj.filters){
					this.pic_obj.filters.blendTrans.Play();
				}			
			}
			//this.pic_obj.border=1;
			this.pic_obj.src=host_address+"/gallery/"+this.image_folder+"/"+pic_name;	
			if(this.pic_obj_link==null || this.pic_obj_link==undefined){
				//alert('dddddd');
				return;
			}
			this.pic_obj_link.href=host_address+"/gallery/"+pic_name;	
			//url2=host_address+"/gallery/"+pic_name;	
			//this.pic_obj.onclick="this.location='"+url2+"'";
			//this.pic_obj.src = imageFile;

  			
			
		}

		
		

		this.init_class=function(){
			//alert(' ');
			this.nfile			=nfile;
			this.image_folder	='w100';
			
			this.image_folder	=image_folder.toLowerCase();
			
		
			if(element_id!='' && element_id!=undefined)
				eval("this.pic_obj=document.getElementById('"+element_id+"')");
			else
				eval("this.pic_obj=document.getElementById('my_picture_"+this.nfile+"')");

			
			eval("this.pic_obj_link=document.getElementById('my_picture_"+this.nfile+"_link')");
			
			
			url					=host_address+"/"+site_lang+"/xml/pictures/"+nfile+".xml";
			var self=this;
			var aj1	=new sack();
			
			//alert(url);
			
			aj1.requestFile		= url;
			aj1.onCompletion	= function(){  self.xmlhttp=this.responseXML;   self.show_picture();  };	
			aj1.runAJAX();	
			
		};
	
		this.init_class();
	
	
	
	}
	
	
	var array_for_cache_pages=new Array();
	
	function class_fetch_page(url,element_id,callback_func){
		this.url			=null;
		this.xmlhttp		=null;
		this.element_id		=null;
		this.callback_func	=null;
		


		this.show_page=function(){
			var c_xml=this.xmlhttp;		
				
			re=new RegExp( "\\s", "g" ), 
			c_xml	=c_xml.replace(re," ");
			c_xml=c_xml.replace(/\"/g, '\\\"');			
			
			c=array_for_cache_pages.length;
			array_for_cache_pages[c]	=new Array();
			array_for_cache_pages[c][0]	=this.url;
			array_for_cache_pages[c][1]	=c_xml;
			

			this.write_in_element(c_xml);


			
			
			
		};
		this.write_in_element=function(c_xml){
			cmd="document.getElementById('"+this.element_id+"').innerHTML=\""+c_xml+"\";";
			eval(cmd);	
			
			if(this.callback_func!=''){
				//alert('dddddddddddd');
				eval(""+this.callback_func+"");
			}
		};

		
		

		this.init_class9=function(){
			//alert(' ');
			this.url			=url;
			this.element_id		=element_id;
			this.callback_func	=callback_func;


			for(i in array_for_cache_pages){
				if(array_for_cache_pages[i][0]==url){
					
					s=array_for_cache_pages[i][1];
					this.write_in_element(s);
					return;
				}
			}
			
			//alert('new');
						
			var self=this;
			var aj1	=new sack();
			
			
			aj1.requestFile		= url;
			aj1.onCompletion	= function(){  self.xmlhttp=this.response;   self.show_page();  };	
			aj1.runAJAX();	
			
		};
	
		this.init_class9();
	}
		
	
	
	
	
	
	
	
	
	
	
	
	
	
	
var myajx;	
	
	
	
	
//var mo_arr00=new Array();	
	
	
var dynamicContent_ajaxObjects = new Array(); 
var jsCache = new Array();
var enableCache = false; 

function ajax_loadContent(divId,pathToFile,pic_folder,href,npic,old_ajaxIndex){
	
	var divId		=""+divId;
	var pathToFile	=""+pathToFile;
	var pic_folder	=""+pic_folder;
	var href		=""+href;
	var npic		=npic;
	
	if(enableCache && jsCache[pathToFile]){
		//alert(divId);
		document.getElementById(divId).innerHTML = jsCache[pathToFile];
		return;
	}
	
	

			
	
	//alert("divId="+divId+"      pathToFile="+pathToFile+"    pic_folder="+pic_folder+"  href="+href+"   npic="+npic);
	
	if(old_ajaxIndex==0){
		var ajaxIndex = dynamicContent_ajaxObjects.length;
		dynamicContent_ajaxObjects[ajaxIndex] = new Array();
	}else{
		ajaxIndex=old_ajaxIndex;
		//alert("eeeee");
	}
	

	dynamicContent_ajaxObjects[ajaxIndex][0] = new sack();
	dynamicContent_ajaxObjects[ajaxIndex][0].requestFile	= pathToFile;
	dynamicContent_ajaxObjects[ajaxIndex][0].onCompletion	= function(){ ajax_showContent(divId,ajaxIndex,pathToFile); };  
	dynamicContent_ajaxObjects[ajaxIndex][0].onError		= function(){ ajax_showContent_error(divId,pathToFile,pic_folder,href,npic,ajaxIndex); };  
	
	
	dynamicContent_ajaxObjects[ajaxIndex][1]=divId;
	dynamicContent_ajaxObjects[ajaxIndex][2]='';//mean: pic_name
	dynamicContent_ajaxObjects[ajaxIndex][3]='';//mean: pic_title
	dynamicContent_ajaxObjects[ajaxIndex][4]='';//mean: pic_width
	dynamicContent_ajaxObjects[ajaxIndex][5]='';//mean: pic_height
	dynamicContent_ajaxObjects[ajaxIndex][6]=pic_folder;//mean: pic_folder
	dynamicContent_ajaxObjects[ajaxIndex][7]=href;//mean: pics_url

	dynamicContent_ajaxObjects[ajaxIndex][0].runAJAX();
	
	

	
} 

function ajax_showContent_error(divId,pathToFile,pic_folder,href,npic,old_ajaxIndex){
	//alert('on_error index='+pathToFile);
	
	var divId		=divId;
	var pic_folder	=pic_folder;
	var pathToFile	=pathToFile;
	var href		=href;
	var npic		=npic;	
	
	//var i=index;
	nform	=1;
	//n_news	=arr_ajax[index][2];
	
	//alert("ajax_showContent_error\n   divId="+divId+"      pathToFile="+pathToFile+"    pic_folder="+pic_folder+"   npic="+npic);
	
	url				=host_address+"/app5.php";
	myajx			=new sack();
	myajx.setVar("subsite"	, subsite);
	myajx.setVar("lang"		, site_lang);
	myajx.setVar("nform"	, nform);
	myajx.setVar("nfile"	, npic);
	myajx.setVar("method"	, 16);
	myajx.setVar("nqsts"	, 'qst_1-qst_2-qst_3-qst_4');
	myajx.setVar("grp"		,1);
	myajx.requestFile		=url;
	myajx.onCompletion		=function(){    ajax_loadContent(divId,pathToFile,pic_folder,href,npic,old_ajaxIndex);  };
	myajx.runAJAX();

		
}



function ajax_showContent(divId,ajaxIndex,pathToFile){
	
	
	//var c_xml=dynamicContent_ajaxObjects[ajaxIndex][0].response;
	//alert("00 pathToFile="+pathToFile+"      c_xml="+c_xml +"       divId="+divId);

	
			
	var divId=divId;
	var ajaxIndex=ajaxIndex;
	var pathToFile=pathToFile;

	
	try{
		var c_xml=dynamicContent_ajaxObjects[ajaxIndex][0].responseXML;
	}catch(e){
		//alert('xxxxxxxxx');
		return;	
	}
	

	
		
	
	obj_pic		=c_xml.getElementsByTagName("noskhe")[0];
	pic_title	=get_element_value(obj_pic,'qst_1');
	pic_name	=get_element_value(obj_pic,'qst_2');
	pic_width	=get_element_value(obj_pic,'qst_3');
	pic_height	=get_element_value(obj_pic,'qst_4');
	
	dynamicContent_ajaxObjects[ajaxIndex][2]=pic_name;
	dynamicContent_ajaxObjects[ajaxIndex][3]=pic_title;
	dynamicContent_ajaxObjects[ajaxIndex][4]=pic_width;
	dynamicContent_ajaxObjects[ajaxIndex][5]=pic_height;
	
	
	if(enableCache){
		jsCache[pathToFile] = dynamicContent_ajaxObjects[ajaxIndex][0].responseXML;
	}
	dynamicContent_ajaxObjects[ajaxIndex][0] = false;
	
	

	
	
	if(is_fimished_downloading_all_pics_for_a_news(divId)){
		//alert('is_fimished_downloading_all_pics_for_a_news');
		show_pics_for_a_news(divId,ajaxIndex);
	}
	
}	
	

function is_fimished_downloading_all_pics_for_a_news(divId){
	//alert(dynamicContent_ajaxObjects.length);
	for(i=0;i<dynamicContent_ajaxObjects.length;i++){
		if(dynamicContent_ajaxObjects[i][1]==divId){
			if(dynamicContent_ajaxObjects[i][0]!=false){
				return(false);
			}
		}
	}
	
	return true;
}

var all_fadeimages=new Array();
var fadebgcolor="#ffffff";


function show_pics_for_a_news(divId,ajaxIndex){
	
	var count_of_imgs			=0;
	
	for(i=0;i<dynamicContent_ajaxObjects.length;i++){
		if(dynamicContent_ajaxObjects[i][1]==divId)
			count_of_imgs++;
	}
	
	

		


	
	
	
	
	
			
	//if(divId=='news_picture_8282')
		//alert(count_of_imgs);
	
	var html='';
	if(count_of_imgs==1){
		
	

		name		=dynamicContent_ajaxObjects[ajaxIndex][2];
		title		=dynamicContent_ajaxObjects[ajaxIndex][3];
		pic_folder	=dynamicContent_ajaxObjects[ajaxIndex][6];
		news_url	=dynamicContent_ajaxObjects[ajaxIndex][7];	
		
		
		
		
		var tiny_width=""+pic_folder+"";
		var re=/(w|h)(\d+)/g;
		
		//var a3=re.exec(tiny_width);
		//alert(a);
		//return;
		
		var tiny_width2	=tiny_width;
		tiny_width2		=tiny_width2.replace(/(w|h)/i, "");
		var w_or_h2		=tiny_width.replace(/\d+/i, "");
		var tiny_w_h2	=Number(tiny_width2);
		
		//w_or_h	=a[1];
		//wh_value=a[2];		
		
		if(w_or_h2=='w')
			w_or_h2=" width='"+tiny_w_h2+"' ";
		else
			w_or_h2=" height='"+tiny_w_h2+"' ";
				
			
			
		url			=host_address+"/gallery/"+pic_folder+"/"+name;
		if(news_url=='')
			news_url=host_address+"/gallery/"+name;
			
		html		="<a href='"+news_url+"'><img "+w_or_h2+" class=div_for_slideshow align=left vspace=0 hspace=0  title='"+title+"' src='"+url+"'></a>";
		//break;

		
		
		

			
	}else{
		var k=0;
		c=all_fadeimages.length;
		all_fadeimages[c]=new Array();
		var max_height	=0;
		var tiny_width	=100;
		var max_w_h		=0;

						
		
		for(i=0;i<dynamicContent_ajaxObjects.length;i++){
			//alert(dynamicContent_ajaxObjects[i][1]);
			if(dynamicContent_ajaxObjects[i][1]==divId){
				width		=dynamicContent_ajaxObjects[i][4];
				height		=dynamicContent_ajaxObjects[i][5];
				pic_folder	=dynamicContent_ajaxObjects[i][6];
				
				
				var tiny_width=pic_folder;
				var re=/(w|h)(\d+)/gm;
				
				var a=re.exec(tiny_width);
				
				
				//alert("width="+width+"    height="+height);
				
				
				var tiny_width2	=tiny_width;
				tiny_width2		=tiny_width2.replace(/(w|h)/i, "");
				var w_or_h2		=tiny_width.replace(/\d+/i, "");
				var tiny_w_h2	=Number(tiny_width2);
								
				w_or_h	=w_or_h2;
				wh_value=tiny_w_h2;
				

				
				tiny_w_h=Number(wh_value);

				
				if(w_or_h=='w'){
					height=Math.ceil((height*tiny_w_h)/width);
					if(height>max_w_h)
						max_w_h=height;
				}else{
					width=Math.ceil((width*tiny_w_h)/height);
					if(width>max_w_h)
						max_w_h=width;
				}

			}
		}		
		//alert("max_w_h="+max_w_h);
		for(i=0;i<dynamicContent_ajaxObjects.length;i++){
			if(dynamicContent_ajaxObjects[i][1]==divId){
				name		=dynamicContent_ajaxObjects[i][2];
				title		=dynamicContent_ajaxObjects[i][3];
				width		=dynamicContent_ajaxObjects[i][4];
				height		=dynamicContent_ajaxObjects[i][5];
				pic_folder	=dynamicContent_ajaxObjects[i][6];
				news_url	=dynamicContent_ajaxObjects[i][7];
				
				url			=host_address+"/gallery/"+pic_folder+"/"+name;
				if(news_url=='')
					news_url=host_address+"/gallery/"+name;				
				
				k=all_fadeimages[c].length;
				if(news_url=='' || news_url==undefined)
					news_url='';
				
				all_fadeimages[c][k]=[url,news_url,""];

			}
		}
		
		

			
		if(w_or_h=='h'){
			max_height=tiny_w_h;
			tiny_width=max_w_h;
		}
				
		if(w_or_h=='w'){
			max_height=max_w_h;
			tiny_width=tiny_w_h;
		}
		
	}
		
	//alert(html);
	document.getElementById(divId).innerHTML =html;
	//دو خط پایین تر باید با کمی مکث اجرا شود یعنی اگر در ایف بالایی میزاشتم چون سریع ران میشد خطا میداد برای همین جداش کردم آو.ردم زید ایینر اچ تی ام ال:
	if(count_of_imgs>1){
		//alert("divId="+divId);
		new fadeshow(all_fadeimages[c], tiny_width, max_height, 0, 3000, 0, 0,undefined,divId);
	}
	
	
}




function f_mohammad(element_id,nfiles,pic_folder,href){


	if(nfiles=='')
		return;
	//alert(nfiles);
	//return;


	
	var arr_nfiles			=nfiles.split('-');
	var i;
	var url;

		
	if(document.getElementById(element_id)==null || document.getElementById(element_id)==undefined){
		//alert('vvvvvvvv');
		return;
	}
		
	
	document.getElementById(element_id).innerHTML ="<img title='در حال نمایش عکس' border=0 src='"+host_address+"/"+site_lang+"/pictures/loading2.gif'>";
			
	var i=0;
	for(i=0;i<arr_nfiles.length;i++){
		nfile	=Number(arr_nfiles[i]);
		if(nfile==0)
			continue;
			
		url		=host_address+"/"+site_lang+"/xml/pictures/"+nfile+"_1.xml";

		ajax_loadContent(element_id,url,pic_folder,href,nfile,0);	


	}
	
	if(i==1){
		document.getElementById(element_id).innerHTML ="";
		document.getElementById(element_id).className ="";
	}
	
	


}
	



	

	
	function gether_name_title_for_a_npic(element_id,c){
		alert(c);
	}
	
	
	function class_show_counter(){

		this.show=function(){
			var counter=this.xmlhttp;			
			
			//counter		=c_xml.getElementsByTagName("variables")[0].getElementsByTagName("counter")[0].childNodes[0].nodeValue;
			//alert(counter);
			document.getElementById('counter_section').innerHTML=counter;
			//alert(counter);
		}
		this.init_class=function(){
			
			url					=host_address+"/app5.php";
			var self=this;
			var aj1	=new sack();
			
			//alert("subsite="+subsite+ "    lang="+site_lang);
			
			aj1.method = 'GET';
			aj1.setVar("subsite"	, subsite);
			aj1.setVar("lang"		, site_lang);
			aj1.setVar("method"		, 15);
			aj1.requestFile		= url;
			aj1.onCompletion	= function(){  self.xmlhttp=this.response;   self.show();  };	
			aj1.runAJAX();	
			
		};
	
		this.init_class();
	}
	

/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.left)>(this.visibledivtop+2)){
this.visiblediv.style.left=parseInt(this.visiblediv.style.left)-2+"px"
this.hiddendiv.style.left=parseInt(this.hiddendiv.style.left)-2+"px"
setTimeout(function(){scrollerinstance.animateup()}, 10)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.left=this.visibledivtop+"px"
div2.style.left=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 000)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}	

	
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

 




function mo_addEvent(el, ev, f) {
if(el.addEventListener)
el.addEventListener(ev, f, false);
else if(el.attachEvent)
el.attachEvent("on" + ev, f);
else
el['on' + ev] = f;
}

	
	function class_correct_links(element_id){
		this.xmlhttp		=null;
		this.element_id		=null;
		this.nfile			=0;
		


		this.correct_link=function(){
			var c_xml=this.xmlhttp;		
				
			
			
			obj_hyper		=c_xml.getElementsByTagName("noskhe")[0];
			n_title			=get_element_value(obj_hyper,'qst_1');
			n_folder		=get_element_value(obj_hyper,'qst_2');
			n_file0			=get_element_value(obj_hyper,'qst_3');
			
			n_file			=Number(n_file0);
			
			cmd="var obj=document.getElementById('"+this.element_id+"')";
			eval(cmd);			
			
			if(isNaN(n_file) || n_folder==0){

				obj.href=n_file0;
				obj.style.fontFamily='arial';
				obj.style.fontSize='11pt';
				obj.style.textDecoration='none';
				obj.style.color='blue';
				obj.style.fontWeight='bold';
				obj.style.borderBottom='#E3EDF8 1px solid';
				
				obj.innerHTML= n_title;//htstring.replace(/(<([^>]+)>)/ig,""); 

							
				return;
			}

			if(n_folder==1)
				n_folder='news';
			if(n_folder==2)
				n_folder='page';
			if(n_folder==3)
				n_folder='gallery';

			url=host_address+"/"+site_lang+"/"+n_folder+"/"+n_file+".htm";
					
			obj.href=url;
			obj.style.fontFamily='arial';
			obj.style.fontSize='11pt';
			obj.style.textDecoration='none';
			obj.style.color='blue';
			obj.style.fontWeight='bold';
			obj.style.borderBottom='#E3EDF8 1px solid';


		
		}

		
		

		this.init_class_10=function(){
			this.element_id		=element_id;
			
			re=/mylink_(\d+)_(\d+)/gm;
			
			a=re.exec(element_id);
			nfile=Number(a[1]);
			
			
			//alert(nfile);
			
			if(isNaN(nfile))
				return;
			if(nfile==0)
				return;
				
			this.nfile=nfile;
				
			url					=host_address+"/"+site_lang+"/xml/hypers/"+nfile+".xml";
			var self=this;
			var aj1	=new sack();
			
			
			aj1.requestFile		= url;
			aj1.onCompletion	= function(){  self.xmlhttp=this.responseXML;   self.correct_link();  };	
			aj1.runAJAX();	
			
		};
	
		this.init_class_10();
	}
                
 /*
function startTicker()
{
// Define run time values
 theCurrentStory = -1;
 theCurrentLength = 0;
 // Locate base objects
 if (document.getElementById) { 
 theAnchorObject = document.getElementById("tickerAnchor");
 runTheTicker(); 
 }
 else {
 document.write("<code>.ticki{display:none;}.ticko{border:0px; padding:0px;}</code>");
 return true;
 }
 }
 // Ticker main run loop
 function runTheTicker()
 {
 var myTimeout; 
 // Go for the next story data block
 if(theCurrentLength == 0)
 {
 theCurrentStory++;
 theCurrentStory = theCurrentStory % theItemCount;
 theStorySummary = theSummaries[theCurrentStory].replace(/&quot;/g,'"'); 
 theTargetLink = theSiteLinks[theCurrentStory];
 theAnchorObject.href = theTargetLink;
 thePrefix = "<span class=\"tickls\" color:#010006 >" + theLeadString + "</span>";
 }
 // Stuff the current ticker text into the anchor
 theAnchorObject.innerHTML = thePrefix +
 theStorySummary.substring(0,theCurrentLength) + whatWidget();
 // Modify the length for the substring and define the timer
 if(theCurrentLength != theStorySummary.length)
 {
 theCurrentLength++;
 myTimeout = theCharacterTimeout;
 }
 else
 {
 theCurrentLength = 0;
 myTimeout = theStoryTimeout;
 }
 // Call up the next cycle of the ticker
 setTimeout("runTheTicker()", myTimeout);
 }
 // Widget generator
 function whatWidget()
 {
 if(theCurrentLength == theStorySummary.length)
 {
 return theWidgetNone;
 }

 if((theCurrentLength % 2) == 1)
 {
 return theWidgetOne;
 }
 else
 {
 return theWidgetTwo;
 }
 }
*/



// Ticker startup
function startTicker()
{
	// Define run time values
	theCurrentStory     = -1;
	theCurrentLength    = 0;
	// Locate base objects
	if (document.getElementById) {	
		    theAnchorObject     = document.getElementById("tickerAnchor");
			runTheTicker();   	
		 }
	else {
            document.write("<style>.ticki{display:none;}.ticko{border:0px; padding:0px;}</style>");
            return true;
	}
}
// Ticker main run loop
function runTheTicker()
{
	var myTimeout;  
	// Go for the next story data block
	if(theCurrentLength == 0)
	{
		theCurrentStory++;
		theCurrentStory      = theCurrentStory % theItemCount;
		theStorySummary      = theSummaries[theCurrentStory].replace(/&quot;/g,'"');		
		theTargetLink        = theSiteLinks[theCurrentStory];
		theAnchorObject.href = theTargetLink;
		thePrefix 	     = "<span class=\"tickls\">" + theLeadString + "</span>";
	}
	// Stuff the current ticker text into the anchor
	theAnchorObject.innerHTML = thePrefix + 
	theStorySummary.substring(0,theCurrentLength) + whatWidget();
	// Modify the length for the substring and define the timer
	if(theCurrentLength != theStorySummary.length)
	{
		theCurrentLength++;
		myTimeout = theCharacterTimeout;
	}
	else
	{
		theCurrentLength = 0;
		myTimeout = theStoryTimeout;
	}
	// Call up the next cycle of the ticker
	setTimeout("runTheTicker()", myTimeout);
}
// Widget generator
function whatWidget()
{
	if(theCurrentLength == theStorySummary.length)
	{
		return theWidgetNone;
	}

	if((theCurrentLength % 2) == 1)
	{
		return theWidgetOne;
	}
	else
	{
		return theWidgetTwo;
	}
}


