/*
Copyright (c) 2001, 2002 by Martin Tsachev. All rights reserved.
mailto:shaggy@members.evolt.org
http://members.evolt.org/shaggy/

This software is OSI Certified Open Source Software.

Redistribution and use in source and binary forms,
with or without modification, are permitted provided
that the conditions available at
http://www.opensource.org/licenses/bsd-license.html
are met.
*/

// generic validation functions
function validateString(str, warning, min, max) {
	if (!min) {
		min = 1;
	}
	if (!max) {
		max = 65535;
	}

	if (!str.value || str.value.length < min || str.value.length > max) {
		alert(unescape(warning));
		str.focus();
		str.select();
		return false;
	}

	return true;
}


function validateEmail(email) {
	if (!email.value) {
		return true;
	}

	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	if ( !re_mail.test(email.value) ) {
		alert('Incorrect email address');
		email.focus();
		email.select();
		return false;
	}

	return true;
}

function validateMatch(var1, var2, msg) {
	if (var1.value != var2.value) {
		alert(unescape(msg));
		var1.focus();
		var1.select();
		return false;
	}

	return true;
}

function addBookmark() { 
if (document.all)
	window.external.addFavorite('http://www.archeologia.ru', 'Портал "Археология России"') 
}
// site specific validation functions
function setCookie(name, value, expires, path, domain, secure) {
        var curCookie = name + "=" + escape(value) +
                ((expires) ? "; expires=" + expires.toGMTString() : "") +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "");
        document.cookie = curCookie;
}

function switchView(div_id, image_id) {
    cl = (document.getElementById(image_id).className == 'imageOpen') ? 'imageClose' : 'imageOpen';
    coo = (document.getElementById(image_id).className == 'imageOpen') ? '0' : '1';
   	display = (document.getElementById(image_id).className == 'imageOpen') ? 'close' : 'open';
    setCookie(div_id, coo);
    document.getElementById(image_id).className = cl;
    document.getElementById(div_id).className = display;
//	display = (document.getElementById(id).class == 'classOpen') ? 'classClose' : 'classOpen';
//    document.getElementById(id).class = display;
}

function CheckAll() {
  for (var i = 0; i < document.groupList.elements.length; i++) {
    if(document.groupList.elements[i].type == 'checkbox'){
      document.groupList.elements[i].checked =         !(document.groupList.elements[i].checked);
    }
  }
}

