var is = new detectBrowser(); // this is for the browser detection
//-------------------------------------------------------------------------------------------
// detailed browser detection - browser name, version, platform
function detectBrowser() { 
  var agent = navigator.userAgent.toLowerCase();
  this.major = parseInt(navigator.appVersion);
  this.minor = parseFloat(navigator.appVersion);
  this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
  this.ns2 = (this.ns && (this.major == 3));
  this.ns3 = (this.ns && (this.major == 3));
  this.ns4b = (this.ns && (this.minor < 4.04));
  this.ns4 = (this.ns && (this.major >= 4));
  this.ie = (agent.indexOf("msie") != -1);
  this.ie3 = (this.ie && (this.major == 2));
  this.ie4 = (this.ie && (this.major >= 4));
  this.op3 = (agent.indexOf("opera") != -1);
  this.win = (agent.indexOf("win")!=-1);
  this.mac = (agent.indexOf("mac")!=-1);
  this.unix = (agent.indexOf("x11")!=-1);
}
//-------------------------------------------------------------------------------------------
var newwindow = '';



// opens new window in the center of the screen. - if NN 3.0, doesn't center window
// called by [ openwindow('file.html','title','width','height') ]
function openwindow(theurl,winname,wWidth,wHeight) { 



winname = 'photo';

if (theurl.indexOf("?")!=-1)
{  theurl = theurl.substring(26)  }

var winheig;
var winwidt;



if (is.ns4 || is.ie4)  {
if (wWidth=='') wWidth='600';
if (wHeight=='') wHeight='600';
 sHeight=screen.height;
 sWidth=screen.width;
 pftop = (sHeight - wHeight) / 2;
 pfleft = (sWidth - wWidth) / 2;
 winparam='directories=no,menubar=no,resizable=yes,status=no,scrollbars=no,width='+wWidth+',height='+wHeight+',top='+pftop+',left='+pfleft;

} else {
 winparam='directories=no,menubar=no,resizable=yes,status=no,scrollbars=no,width='+wWidth+',height='+wHeight;
}



if (!newwindow.closed && newwindow.location) {
		newwindow.location.href = theurl;
	}
	else {
		newwindow=window.open(theurl,winname,winparam);
		if (!newwindow.opener) newwindow.opener = self;
	}


// newwindow=window.open(theurl,winname,winparam);

newwindow.focus();

}
//-------------------------------------------------------------------------------------------
// opens new window in the center of the screen. - if NN 3.0, doesn't center window
// called by [ openwindow('file.html','title','width','height') ]
function openwindow2(theurl,winname,wWidth,wHeight) { 
if (is.ns4 || is.ie4)  {
 sHeight=screen.height;
 sWidth=screen.width;
 pftop = (sHeight - wHeight) / 2;
 pfleft = (sWidth - wWidth) / 2;
 winparam='directories=no,menubar=no,resizable=yes,status=no,scrollbars=yes,width='+wWidth+',height='+wHeight+',top='+pftop+',left='+pfleft;
} else {
 winparam='directories=no,menubar=no,resizable=yes,status=no,scrollbars=yes,width='+wWidth+',height='+wHeight;
}
window.open(theurl,winname,winparam);
}
//-------------------------------------------------------------------------------------------
// mouseover swap image function - works under NN 3.0 and higher, Opera, IE 4.0 and higher
function swapImg(imgName, imgSwapName) {
if (is.op3 || is.ns3 || is.ns4 || is.ie4) 
 {
  document.images[imgName].src = eval(imgSwapName + ".src");
 }
}
//-------------------------------------------------------------------------------------------
// FORM PART
//-------------------------------------------------------------------------------------------
function checkEmail(formname) {
form = eval('document.'+formname);
    if (form.email.value == '') {
	alert('\nВы не заполнили поле "E-mail".')
    form.email.select();
    form.email.focus();
	return false;
	}
	if (form.email.value.indexOf('@',0)==-1 || form.email.value.indexOf('.',0)==-1) {
    alert('\nE-mail адрес не действителен.\nПожалуйста, введите действительный адрес.')
    form.email.select();
    form.email.focus();
    return false;
    }
}
//-------------------------------------------------------------------------------------------
function doForm(formname) {
this.form = eval('document.'+formname);
}
function sendAll(formname) {
form = eval('document.'+formname);
form.date.value = getTheDate();
form.time.value = getTheTime();
form.referer.value = location.href;
if ((form.defaultsubscribe.value == 'no') && (form.subscribe.value == 'yes') && (form.subscribe.checked == true)) {
    form._send_email_subscribe.value = 'send_subscribe.txt';
    form._out_file_subscribe.value = 'writefile_subscribtion.txt';
}
    if (form.s_name.value == '') {
	alert('\nВы не заполнили поле "Имя".\nПожалуйста, введите Ваше имя.')
    form.s_name.select();
    form.s_name.focus();
	return false;
	}
    if (form.s_email.value == '') {
	alert('\nВы не заполнили поле "E-mail".\nЗаполните это поле, чтобы мы могли связаться с вами.')
    form.s_email.select();
    form.s_email.focus();
	return false;
	}
    if (form.s_email.value.indexOf('@',0)==-1 || form.s_email.value.indexOf('.',0)==-1) {
    alert('\nE-mail адрес не действителен.\nПожалуйста, введите действительный адрес.')
    form.s_email.select();
    form.s_email.focus();
    return false;
    }
}
//-------------------------------------------------------------------------------------------
// TIME PART
//-------------------------------------------------------------------------------------------
function getTheDate() // returns DATE variable
{
   shortDays = new shortDayArray();
   shortMonths = new shortMonthArray();
   d = new Date();
   day = d.getDate();
   month = d.getMonth();
	year = d.getYear();
    date = shortDays[d.getDay()] + " " + shortMonths[month] +". " + day + ", "+getLongYear(year);
	return date;
}
function getLongYear(year)
{
  if (year > 1900) return year
  return year+1900;
}
function shortMonthArray() {
	this[0] = "Jan";	this[1] = "Feb";	this[2] = "Mar";
	this[3] = "Apr";	this[4] = "May";	this[5] = "Jun";
	this[6] = "Jul";	this[7] = "Aug";	this[8] = "Sep";
	this[9] = "Oct";	this[10] = "Nov";	this[11] = "Dec";
        return (this);
}
function shortDayArray() {
	this[0] = "Sun"; this[1] = "Mon"; this[2] = "Tue"; this[3] = "Wed";
	this[4] = "Thu"; this[5] = "Fri"; this[6] = "Sat";
        return (this);
}
//-------------------------------------------------------------------------------------------
function getTheTime() //returns TIME variable
{
   d = new Date();
   hour=d.getHours();
   min=d.getMinutes();
   sec=d.getSeconds();
   if (hour < 10) hour = "0"+hour;
   if (min < 10) min = "0"+min;
   if (sec < 10) sec = "0"+sec;
   time = hour+":"+min;
   return time;
}
