var dom = document.getElementById;
var iex = document.all;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var safari = ((navigator.userAgent.indexOf("Safari")>-1) ) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;
var main;

var work_test;

function getElement ( name ){
	var el = dom ? document.getElementById(name) : iex ? document.all[name] : ns4 ? eval ( 'document.' + name ) : false;
	return el;
	}
	
function open_photo( tmp ) {
	ff = window.open("/scripts/picture.php?picture_path=" + tmp.getAttribute( "big_file" ) + "&picture_caption=" + tmp.getAttribute( "my_caption" ),"Фото","resizable=no,scrollbars=no,width=420,height=600");
	ff.focus();
	} 

function open_photo_by_name ( el ) {
	var parts = /([^\/]+)\.(\w+)$/.exec(el.src);
	var el_file = parts[ 1 ];
	var el_extension = parts[ 2 ];
	var big_name = el_file + "_big.jpg";
	var tmp_img = new Image();
	tmp_img.src = "/img_out/" + big_name;
	
	if( tmp_img.width > 0 ) {
		open_photo_by_name_load( tmp_img , big_name ,  el.alt , el.getAttribute( "print" ) );
		}
	else {
		tmp_img.onload = function(){ open_photo_by_name_load( tmp_img , big_name , el.alt , el.getAttribute( "print" ) ) };
		}
	} 
function open_photo_by_name_load( el , img_src , tmp_caption , print ) { 
	ff = window.open("/scripts/picture.php?picture_path=" + img_src + "&picture_caption=" + tmp_caption + "&print=" + ( print == "yes" ? "visible" : "hidden" ),"Фото","resizable=no,scrollbars=no,width=" + ( el.width + 20 ) + ",height=" + ( el.height + 63 ) + "");
	if( !ff ) {
		alert( 'Вероятно, в Вашем браузере заблокированы всплывающие окна' );
		}
	else {
		ff.focus(); 
		}
	}
	
function common_checkEmail ( address )
	{
	return /^\w[\w.\-\&]+\@\w[\w.\-]*\w{2,}/.test(address); 
	//return re.test(address);
	}

function common_checkHref ( address )
	{
	var re =/^http\:\/\/[\w.\-]+\.\w{2,}\/?\??/;
	//return false;
	//return true;
	return re.test(address);
	}