var solo_mode=false;
var open_all=false;

function Plus_Minus(div_name, but_id){
	if(document.getElementById(div_name).style.display == 'none'){document.getElementById(but_id).src='images/ico-pls.gif'}
	else {document.getElementById(but_id).src='images/ico-min.gif'}
}


function ShowHide(div_name, but_id) {
	
	Effect.toggle(div_name,'slide',{duration:.5}); 

	if(document.getElementById(div_name).style.display == 'none'){document.getElementById(but_id).src='images/ico-min.gif'}
	else {document.getElementById(but_id).src='images/ico-pls.gif'}
	
	return false;
}

function QShowHide0(div_name, but_id) {

	if(document.getElementById(div_name).style.display == 'none')
	{
		document.getElementById(but_id).src='images/ico-min.gif';
		document.getElementById(div_name).style.display = 'block';
	}
	else 
	{
		document.getElementById(but_id).src='images/ico-pls.gif';
		document.getElementById(div_name).style.display = 'none';
	}
	
	return false;
}

function QShowHide(ban_num, ban_all) 
{
	var div_name_prefix = 'banner_';
	var but_name_prefix = 'but_more_';
	var i;

	div_name = div_name_prefix + ban_num;
	but_id = but_name_prefix + ban_num;

	for(i=1; i<=ban_all; i++)
	{
	
		if (i == ban_num) {
			if(document.getElementById(div_name).style.display == 'none')
			{
				document.getElementById(div_name).style.display = 'block';
				document.getElementById(but_id).src='images/ico-min.gif';
			}
			else {
				document.getElementById(div_name).style.display = 'none';
				document.getElementById(but_id).src = 'images/ico-pls.gif';
			}
		}
		else { 
		   if (solo_mode )
		   { 
			    document.getElementById(div_name_prefix + i).style.display = 'none';
			    document.getElementById(but_name_prefix + i).src = 'images/ico-pls.gif';
		   }
		}
	}

	return false;
}

function HideAll(nums) {

	var div_name_prefix = 'banner_';
	var but_name_prefix = 'but_more_';
	open_all=false;

	
	for(i=1;i<=nums;i++){
		div_name = div_name_prefix + i;
		but_name = but_name_prefix + i;
		document.getElementById(div_name).style.display = 'none';
		document.getElementById(but_name).src = 'images/ico-pls.gif';
	}
	return false;
}

function ShowAll(nums) {

	var div_name_prefix = 'banner_';
	var but_name_prefix = 'but_more_';
	open_all=true;
	
	for(i=1;i<=nums;i++){
		div_name = div_name_prefix + i;
		but_name = but_name_prefix + i;
		document.getElementById(div_name).style.display = 'block';
		document.getElementById(but_name).src = 'images/ico-min.gif';
	}
	return false;
}


// name - имя cookie
// value - значение cookie
// [expires] - дата окончания действия cookie (по умолчанию - до конца сессии)
// [path] - путь, для которого cookie действительно (по умолчанию - документ, в котором значение было установлено)
// [domain] - домен, для которого cookie действительно (по умолчанию - домен, в котором значение было установлено)
// [secure] - логическое значение, показывающее требуется ли защищенная передача значения cookie

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" : "")
        if (!caution || (name + "=" + escape(value)).length <= 4000)
                document.cookie = curCookie
        else
                if (confirm("Cookie превышает 4KB и будет вырезан !"))
                        document.cookie = curCookie
}

// name - имя считываемого cookie
function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return null
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}


function copy_in_form(form, name, tag) {
document.forms[form].elements[name].value += ' ';
document.forms[form].elements[name].value += tag;
return(false);
}

function copy_in_form2(form, name, tag) {
document.forms[form].elements[name].value = tag;
return(false);
}

function copyKeyword(keyword, name) {
document.forms["banadd"].elements[name].value += keyword;
document.forms["banadd"].elements[name].value += ' ';
return(false);
}


function copyEx(email, name) {
document.forms["orderform"].elements[name].value = email;
return(false);
}

function validEmail(email) {
			email = trim(email)
			invalidChars = "/:,;"
			if (email == "") {
				return false
			}
			for (i=0; i<invalidChars.length; i++) {
				badChar = invalidChars.charAt(i)
				if (email.indexOf(badChar,0) > -1) {
					return false
				}
			}
			atPos = email.indexOf("@",1)
			if (atPos == -1) {
				return false
			}
			if (email.indexOf("@",atPos+1) > -1) {
				return false
			}
			periodPos = email.indexOf(".",atPos)
			if (periodPos == -1) {
				return false
			}
			if (periodPos+3 > email.length)	{
				return false
			}
			return true
}

function isURL (url) {
  var urlPattern = /^(?:(?:ftp|https?):\/\/)?(?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)+(?:com|edu|biz|org|gov|int|info|mil|net|name|museum|coop|aero|[a-z][a-z])\b(?:\d+)?(?:\/[^;"'<>()\[\]{}\s\x7f-\xff]*(?:[.,?][^;"'<>()\[\]{}\s\x7f-\xff]+)*)?/;
  return urlPattern.test(url.toLowerCase());
}

function notemptystring (stringa) {
	if (stringa == "") {
		return false
	}
	return true
}
function trim(stringa) {
	while (stringa.charAt(0) == " ") {
			stringa = stringa.substring (1,stringa.length)
		}
	while (stringa.charAt(stringa.length-1) == " ") {
			stringa = stringa.substring (0,(stringa.length-1))
	}
	return stringa
}


