var ms = navigator.appVersion.indexOf("MSIE");
var macness = navigator.appVersion.indexOf("Macintosh");
ie4 = (ms>0) && (parseInt(navigator.appVersion.substring(ms+5, ms+6)) >= 4);

function open_window(link) {
//   w=window.open(link,'alpha','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizeable=0,width=600,height=500');
	w=window.open(link,'alpha','resizable=yes,menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,width=600,height=500');
	if (!w)	{
		alert('Please disable your \"Pop-up blocker\" to see contents.\n\n');
	}
	else if (w.blur) {
		w.focus();
	}
	w.moveTo(screen.availWidth/2-270,0);
	w.focus();
}

function open_image(url,img_width) {
   var scr_width = screen.availWidth;
   var wnd_height = screen.availHeight-100;
   if (img_width + 40 > scr_width) {
   	wnd_width = scr_width - 10;
   }
   else {
   	wnd_width = img_width + 40;
   }
   wnd=window.open(url,"alpha","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizeable=1,width="+wnd_width+",height="+wnd_height);
//wnd=window.open(link,'alpha','resizable=yes,menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,width='+wnd_width+',height='+wnd_height);
	if (!wnd)	{
		alert('Please disable your \"Pop-up blocker\" to see contents.\n\n');
	}
	else if (wnd.blur) {
	   wnd.moveTo(0,0);
	   wnd.focus();
  	}
}


function check_field(obj) {
	if(!ie4) return true;
	style_bad="border: 1px solid #FF0000; ";
	if (obj.value == "") {
		obj.style.cssText = style_bad;
		result = false;
	}
	else {
		obj.style.cssText = "";
		result = true;
	}
	return result;
}

function check_fields(form_name,msg) {
	if(!ie4) return true;
	result = true;
	for (index=0; index <= document.forms(form_name).all.length-1; index++) {
		el = document.forms(form_name).all[index];
		if (el.required) {
			if (!check_field(el)) result = false;
		}
	}
	if ((!result) && (msg)) alert('Please, fill all fields.');
	return result;
}

function clear_input(obj)
{
	obj.value = "";
	//alert(obj.value);
}

function StatusMsg(msgStr) {
	status=msgStr;
	document.returnValue = true;
}