function MM_findObj(n, d) { 
	var p,i,x;  
	if(!d)d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length){
		d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all)x=d.all[n]; 
	for(i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  	for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);
  	if(!x && document.getElementById)x=document.getElementById(n); 
	return x;
}

function turnDiv(d){
	tmpObject=MM_findObj(d);
	if(tmpObject.style.display=='none'){
		tmpObject.style.display='';
	} else {
		tmpObject.style.display='none';
	}
}

function turnDivOn(d){
	tmpObject=MM_findObj(d);
	tmpObject.style.display='';
}

function turnDivOff(d){
	tmpObject=MM_findObj(d);
	tmpObject.style.display='none';
}

function bigpicview(piclink, width, height){
	x=(screen.width-width)/2;
	y=(screen.height-height)/2;
	window.open('/picview.php?pic='+piclink, 'bpv', 'width='+width+', height='+height+', left='+x+', top='+y+', resizeable=0, scrollbars=0');
}

function changeClass(ele,cls){
	row.className=cls;
}

function changeRowClass(ele,cls){
	row=document.getElementById(ele);
	row.className=cls;
}

function js_in_array(a,v){
	for(js_in_i=0;js_in_i<a.length;js_in_i++){
		if(a[js_in_i]==v)return true;
	}
	return false;
}


//cross frame spoofing
//if(parent!=self)top.location.href=location.href;

//fotoalbum
var albumpopUp='/photoalbum_popup.php';
var albumpopW=600;
var albumpopH=565;
//var albumpopUp='<? echo $cfg['site']['fotoalbum_popup']; ?>';
//var albumpopW=<? echo $cfg['site']['fotoalbum_popup_width']; ?>;
//var albumpopH=<? echo $cfg['site']['fotoalbum_popup_height']; ?>;

function fotoAlbum(albumid){
	winleft=(screen.width-albumpopW)/2;
	winUp=(screen.height-albumpopH)/2;
	winProp='width='+albumpopW+',height='+albumpopH+',left='+winleft+',top='+winUp+',scrollbars=0,resizable';
	Win=window.open(albumpopUp+'?id='+albumid, 'fotoAlbum', winProp);
}

function is_email(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    return false
	 }
	
	 if (str.indexOf(" ")!=-1){
	    return false
	 }

	 return true					
}

