function CheckEmail(e){
	e = e.toLowerCase();
	var ch="@";
	var count=0;
	var error=false;
	
	for (var i=0; i<e.length; i++){
		if(e.charAt(i)==ch || e.charAt(i)=="."){
			error = (count==0) ? true : error;
			ch = (ch==".") ? 0 : ch;
			ch = (e.charAt(i)=="@") ? "." : ch;
			count=0;
			continue;
		}
		count++;
	
		if((e.charAt(i)<"a" || e.charAt(i)>"z") && (e.charAt(i)<"0" || e.charAt(i)>"9") && e.charAt(i)!="_" && e.charAt(i)!="-"){
			error = true;
			break;
		}
	}
	error = (count==0) ? true : error;
	error = (ch==0) ? error : true;
	return !error;
}

function cr(){
	stroka=document.mainfrm["email"].value;
	if (CheckEmail(stroka)){
		document.mainfrm.submit();
	}
	else{
		alert('Вы ввели некорректный e-mail адрес');
	}
}

function ShowPhoto(photoname, w, h) {
	url = "/showphoto.php?img="+photoname;
	h += 70;
	if (h > 600) {
		h = 600
	}
	w += 40;
	Win=window.open(url, 'viewPhoto',  'toolbar=0,scrollbars=1,location=0,directories=0,status=0,menubar=0,resizable=1,width='+w+',height='+h+',border=thin,top=50,left=50,help=0');
	Win.focus();
}

function ShowMap (photoname) {
	url = "/showmap.php?img=" + photoname;
	w = 600;
	h = 400;
	Win=window.open(url, 'viewPhoto',  'toolbar=0,scrollbars=1,location=0,directories=0,status=0,menubar=0,resizable=1,width='+w+',height='+h+',border=thin,top=50,left=50,help=0');
	Win.focus();
}

function GoURL(url, target) {
	var w;
	if (target == "_blank") {
		w = window.open(url,"w","");
		w.focus();
	}	else {
		document.location = url;
	}
	return false;
}

function ShowForum(name) {
	url = "/support/q-and-a/hot/"+name+"/";
	w = 800;
	h = 600;
	Win=window.open(url, 'viewForum',  'toolbar=0,scrollbars=1,location=0,directories=0,status=0,menubar=0,resizable=1,width='+w+',height='+h+',border=thin,top=50,left=50,help=0');
	Win.focus();
	return false;
}

