// JavaScript Document

function ejlasScroll(nbflag){
	if(nbflag){
		if(ejlFirst+3 < ejlasArr.length){
			ejlFirst++;
		}else{
			return;
		}
	}else{
		if(ejlFirst > 0){
			ejlFirst--;
		}else{
			return;
		}
	}
	for(i=0;i<3;i++){
		if(ejlasArr[ejlFirst+i][2]) cName=['x',1]; else cName=['m',0];
		document.getElementById("ejlas_"+i).name=ejlFirst+i
		document.getElementById("ejlas_"+i).src=imageArr[ejlFirst+i][cName[1]].src ;
		document.getElementById("ejlas_"+i+"_l").className="ejlname_"+cName[0]+"l";
		document.getElementById("ejlas_"+i+"_m").className="ejlname_"+cName[0]+"m";
		document.getElementById("ejlas_"+i+"_r").className="ejlname_"+cName[0]+"r";	
	}	
}


function ejlsDefault(id,name){
	if(name==ejlasId || name==100) return ;
	for(i=0;i<3;i++){
		if(document.getElementById("ejlas_"+i).name==ejlasId){
			document.getElementById("ejlas_"+i).src=imageArr[ejlasId][0].src;			
			document.getElementById("ejlas_"+i+"_l").className="ejlname_ml";
			document.getElementById("ejlas_"+i+"_m").className="ejlname_mm";
			document.getElementById("ejlas_"+i+"_r").className="ejlname_mr";	
		}
	}
	
	document.getElementById('main_boss').innerHTML = "استاد ميهمان :<br> "+ejlasArr[name][3];
	document.getElementById('ymsgr_link').href = 'ymsgr:sendim?'+ejlasArr[name][4]+'&m=خوش آمديد';
	document.getElementById('ymsgr_img').src = 'http://opi.yahoo.com/online?u='+ejlasArr[name][4]+'&m=g&t=8';
	
	document.getElementById(id).src=imageArr[name][1].src;			
	document.getElementById(id+"_l").className="ejlname_xl";
	document.getElementById(id+"_m").className="ejlname_xm";
	document.getElementById(id+"_r").className="ejlname_xr";
	document.getElementById("ejlas_titr").innerHTML = '<div class="ejl_maintitr" unselectable="On"> موضوع اجلاس '+ejlasArr[name][1]+' </div>';
	ejlasArr[name][2]=true;
	ejlasArr[ejlasId][2]=false;
	
	next(name,0);
}


function arrow_next(arwType){
	
	if( arwType ){
		arwNum=ejlItamNum+1;
		if( arwNum>document.getElementById('ejl_itemcount').value ) return; else next(arwNum,2);	
	}else{
		arwNum=ejlItamNum-1;
		if( arwNum==0 ) return; else next(arwNum,2);	
	}



/*	if (document.getElementById('ejl_itemcount').value<11) return;
	
	if(arwFlag){
		arwnext=document.getElementById('ejl_arrow2').name;
		if ( document.getElementById('ejl_itemcount').value<=arwnext ) return;
		arwnext++ ;
		arwItmId=10 ;
		for (i=arwnext ; i>arwnext-10 ; i--){
			itemClass=document.getElementById('ejl_inum'+arwItmId).className;
			document.getElementById('ejl_itm_num'+arwItmId).innerHTML='<p id="ejl_inum'+arwItmId+'" onClick="next('+i+',2)" class="'+itemClass+'" >'+i+'</p>';
			arwItmId--;
		}
	}else{
		arwnext=document.getElementById('ejl_arrow1').name;
		if ( arwnext<=1 ) return;
		arwnext-- ;
		arwItmId=1 ;
		for (i=arwnext ; i<arwnext+10 ; i++){
			itemClass=document.getElementById('ejl_inum'+arwItmId).className;
			document.getElementById('ejl_itm_num'+arwItmId).innerHTML='<p id="ejl_inum'+arwItmId+'" onClick="next('+i+',2)" class="'+itemClass+'" >'+i+'</p>';
				arwItmId++;
		}						
	}*/
}


function ejlas_pic(picId) {
	back_pic=document.getElementById('ejl_pic_0').name;
	if(back_pic==picId) return;
	document.getElementById('ejl_dpic_'+back_pic).className='ejl_box_mpic';
	document.getElementById('ejl_dpic_'+picId).className='ejl_box_xpic';
	countOcity=-1
	picset=setInterval('opacityf('+picId+')',50);
	document.getElementById("Layer3").style.display="inline";
}

var setOpacity=100;
var countOcity=-1
function opacityf(picOcity){
	setOpacity+=countOcity*5;
	document.getElementById('ejl_pic_0').style.filter='alpha(opacity='+setOpacity+')';
	document.getElementById('ejl_pic_0').style.MozOpacity=""+(setOpacity/100);

	if(setOpacity==10){
		document.getElementById('ejl_pic_0').src=document.getElementById('ejl_pic_'+picOcity).src;
		document.getElementById('ejl_pic_0').name=picOcity;
		countOcity=1
	}
	if(setOpacity==100){
		clearInterval(picset);
		document.getElementById("Layer3").style.display="none";		
	}
}

// set size of layer
function setLayer(){
	document.getElementById("Layer1").style.width = screen.availWidth-21;
	document.getElementById("Layer1").style.height = screen.availHeight-150;
	document.getElementById("Layer3").style.width = screen.availWidth-21;
	document.getElementById("Layer3").style.height = screen.availHeight-150;
}

//set the box of new comment or respod
function setComment(idCom,typeCom){
	
	document.getElementById("comBox").className = "main_box_"+typeCom ;
	document.getElementById("comBanner").className = "banner_box_"+typeCom ;
	document.getElementById("save").focus() ;
	document.getElementById("titleCom").select();
	document.getElementById("titleCom").focus() ;
	if( idCom==0 ){
		document.getElementById("comBanner").innerHTML = '<span class="box_com_titr_f" > اظهار نظر جديد </span>' ;
		document.getElementById("fatherId").value = '0' ;
	}else{
		document.getElementById("comBanner").innerHTML = '<span class="box_com_titr_c" > پاسخ به '+idCom+' </span>' ;
		document.getElementById("fatherId").value = idCom ;
	}


}


//check the regular
var regular = [ /^.{2,}\s.{2,}$/g , /^[0-9]{7,11}$/g , /^[0-9]{4}([-/][0-9]{2}[-/][0-9]{2})?$/g , /^.{2,}$/g , /^\w{3,32}$/g ];
var regItem = [[['userName','userTel'],[0,1],['لطفا نام ونام خانوادگی خود را به طور صحيح وارد نماييد','لطفا تلفن خود را به صورت صحيح وارد كنيد']] , [['userName','userDate','userEdu','userJob','userTel','userAdd','user','pass'],[0,2,3,3,1,0,4,4],['لطفا نام و نام خانوادگی خود را به طور صحيح وارد نماييد','لطفا تاريخ تولد خود را به صورت صحيح وارد كنيد','لطفا تحصيلات خود را به صورت صحيح وارد كنيد','لطفا شغل خود را به صورت صحيح وارد كنيد','لطفا تلفن خود را به صورت صحيح وارد كنيد','لطفا آدرس خود را به صورت صحيح وارد كنيد','لطفا نام كاربری خود را به صورت صحيح وارد كنيد و از حروف فارسی نيز استفاده ننماييد','لطفا رمز عبور خود را به صورت صحيح وارد كنيد و از حروف فارسی نيز استفاده ننماييد']] , [['titleCom','mainCom'],[3,3],['لطفا عنوان نظر را به وارد نماييد','لطفا متن نظر را به وارد نماييد']]];

function reg_check(jobName){
	var cuntReg=regItem[jobName][0].length;
	for( i=0 ; i<cuntReg  ; i++ ){
	//alert( document.getElementById(regItem[jobName][0][i]).value.search(regular[regItem[jobName][1][i]])  );
		if( document.getElementById(regItem[jobName][0][i]).value.search(regular[regItem[jobName][1][i]])==-1 ){
			document.getElementById('boxAns').innerHTML = '<span style="font-family:tahoma; font-size:12px; color:red; padding-left:3px">'+regItem[jobName][2][i]+'</span><br>';
				//alert(4);

			return false
		}
	}
	//alert(i);
	return true;
}


/*

function ejlas_pic(picId) {
	back_pic=document.getElementById('ejl_pic_0').name;
	if(back_pic==picId) return;
	document.getElementById('ejl_dpic_'+back_pic).className='ejl_box_mpic';
	document.getElementById('ejl_dpic_'+picId).className='ejl_box_xpic';
	opacityf(-1,picId);
	alert(picId);
}

var setOpacity=100;
function opacityf(countOcity,picOcity){
	setOpacity+=countOcity*10;

	document.getElementById('ejl_pic_0').style.filter='alpha(opacity='+setOpacity+')';
	document.getElementById('ejl_pic_0').style.MozOpacity=""+(setOpacity/100);	//alert(aaz);

	setOcity="opacityf("+countOcity+','+picOcity+")";
	if(setOpacity==10){
		document.getElementById('ejl_pic_0').src=document.getElementById('ejl_pic_'+picOcity).src;
		document.getElementById('ejl_pic_0').name=picOcity;
		countOcity=1
		setOcity="opacityf("+countOcity+','+picOcity+")";
		picset=setTimeout(setOcity, 150); 
	}
	if(setOpacity==100){
		clearTimeout(picset);
	}else{
		picset=setTimeout(setOcity, 150); 
	}
}


*/