function checkmail1(mailString)
{
	// Возвращает 0 - если пустое, 1 - если неправильно заполнено, 2 - если правильно
	if(mailString!="")
	{		
		re=/(\.@)|(^[\.\-]{1})|(\.\-\.+)|(@\.\-)|(@.*_)/;
		result = re.test(mailString);
		if(!result)		
		{
			re=/^[(\w)\.\-]+[@]{1}[(\w)\.\-]+[\.\-]{1}[^(\W|_|\.\-)]{2,3}$/;
			result = re.test(mailString);
			if(!result)
				return  1;
			return 2;	
		}
		return 1;
	}
	
	return 0;
}

function shol_TrySend(f)
{	
	var b=true;
	for (var i=0; i < necessarily_inputs.length; i++ )
	{
		if (document.forms[f].elements[necessarily_inputs[i]])		
			if (document.forms[f].elements[necessarily_inputs[i]].value == '') {b=false;}
			if (document.forms[f].elements[necessarily_inputs[i]].value == 'Выбрать') {b=false;}			
	}	
	if (b) {	

				if (checkmail1(document.getElementById('EMAIL').value)==2)
				{		
					document.forms[f].submit();
				} else {alert("Неверный e-mail!");}			
		//document.forms[f].submit();
	} 	
	else {alert("Внимание! Заполнены не все обязательные поля. Попробуйте еще раз.");}
}

function Send(f)
{	
  document.forms[f].submit();
}

function visibl(id) {
   var e = document.getElementById(id);
   if(e.style.display == 'block')
      e.style.display = 'none';
   else
      e.style.display = 'block';
}

function submitBasket(f) {
  for (var el = 0; el < document.forms['busket'].elements.length; el++) 
  {
    
    var nnn = document.forms['busket'].elements[el].name; 
    
    if (nnn == null) continue;

    if (nnn.substring(0,3) == "del") 
      if (document.forms['busket'].elements[el].checked == true) 
      {  
        var id = nnn.substring(3,1000);
        document.getElementById(id).value = 0;   
      }    
  }
  document.forms[f].submit();
} 

var cssmenuids=["cssmenu1"]; //Enter id(s) of CSS Horizontal UL menus, separated by commas
var csssubmenuoffset=-1; //Offset of submenus from main menu. Default is 0 pixels.

function createcssmenu2(){
for (var i=0; i<cssmenuids.length; i++){
  var ultags=document.getElementById(cssmenuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+csssubmenuoffset+"px"
    	var spanref=document.createElement("span")
			spanref.className="arrowdiv";
			spanref.innerHTML="";
			ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref)
    	ultags[t].parentNode.onmouseover=function(){
					this.style.zIndex=100
    	this.getElementsByTagName("ul")[0].style.visibility="visible"
					this.getElementsByTagName("ul")[0].style.zIndex=0
    	}
    	ultags[t].parentNode.onmouseout=function(){
					this.style.zIndex=0
					this.getElementsByTagName("ul")[0].style.visibility="hidden"
					this.getElementsByTagName("ul")[0].style.zIndex=100
    	}
    }
  }
}
if (window.addEventListener)
window.addEventListener("load", createcssmenu2, false)
else if (window.attachEvent)
window.attachEvent("onload", createcssmenu2)



function newWindow(s, w, h)
{
win=window.open(s, "win", "width="+w+",height="+h+",scrollbars=no,toolbar=no,location=no,statusbar=no,menubar=no,sizable=no")
}

function onPic(file_name)
{
window.open(file_name,"a","toolbar=no,location=no,statusbar=no,menubar=no,sizable=no, scrollbars=no")
}

function small_form_submit() {
	window.opener.location.reload();
	window.close();
}

function uploadImagePrwDialog(obj) {
var path="http://www.nring.ru/upload.aspx/uploadImagePrw?"+obj;
document.domain="www.nring.ru";
window.open(path,"gi","height=360,width=350,toolbar=no,menubar=no,location=no,scrollbars=no,focus=yes,top=50,left=50");
}

function uploadFileDialog(obj) {
var path="http://www.nring.ru/upload.aspx/uploadArtWork?"+obj;
document.domain="www.nring.ru";
window.open(path,"gi","height=360,width=350,toolbar=no,menubar=no,location=no,scrollbars=no,focus=yes,top=50,left=50");
}

function uploadImageDialog(obj) {
var path="http://www.nring.ru/upload.aspx/uploadImage?"+obj;
document.domain="www.nring.ru";
window.open(path,"gi","height=360,width=350,toolbar=no,menubar=no,location=no,scrollbars=no,focus=yes,top=50,left=50");
}


// Конвертируем дату
function convert_to_time(secs)
{
	secs = parseInt(secs);	
	hh = secs / 3600;	
	hh = parseInt(hh);	
	mmt = secs - (hh * 3600);	
	mm = mmt / 60;	
	mm = parseInt(mm);	
	ss = mmt - (mm * 60);	
		
	if (hh > 23)	
	{	
	   dd = hh / 24;	
	   dd = parseInt(dd);	
	   hh = hh - (dd * 24);	
	} else { dd = 0; }	
		
	if (ss < 10) { ss = "0"+ss; }	
	if (mm < 10) { mm = "0"+mm; }	
	if (hh < 10) { hh = "0"+hh; }	
	if (dd == 0) { return (hh+":"+mm+":"+ss+"<div class='hms'><span>часов<\/span><span>минут<\/span><span>секунд</span><\/div>"); }	
	else {	
	   if (dd < 10) { dd = "0"+dd; }	
	   return (dd+"&nbsp;"+hh+":"+mm+":"+ss+"<div class='hms'><span>дней<\/span><span>часов<\/span><span>минут<\/span><span>секунд<\/span><\/div>"); 
		/*if (dd > 1) { return (dd+" дней "+hh+":"+mm+":"+ss); }
		else { return (dd+" день "+hh+":"+mm+":"+ss); }*/
	}	
}
// создаем счетчик
function do_cd()
{
	if (countdown < 0)	
	{ 	
		//document.write("<div id='cd'>Событие наступило!<\/div>");	
    //document.getElementById('cd').innerHTML = "<div class='svsob'>Перейти к событию<\/div>";	
    document.getElementById('cdblock').style.display = "none";	
	}	
	else	
	{	
		document.getElementById('cd').innerHTML = convert_to_time(countdown);
		setTimeout('do_cd()', 1000);
	}	
	countdown = countdown - 1;	
}

// Конвертируем дату
function convert_to_time2(secs)
{
	secs = parseInt(secs);	
	hh = secs / 3600;	
	hh = parseInt(hh);	
	mmt = secs - (hh * 3600);	
	mm = mmt / 60;	
	mm = parseInt(mm);	
	ss = mmt - (mm * 60);	
		
	if (hh > 23)	
	{	
	   dd = hh / 24;	
	   dd = parseInt(dd);	
	   hh = hh - (dd * 24);	
	} else { dd = 0; }	
		
	if (ss < 10) { ss = "0" + ss;}	
	if (mm < 10) { mm = "0" + mm;}	
	if (hh < 10) { hh = "0" + hh;}	
	if (dd == 0) { return (hh+":"+mm+":"+ss+"<div class='hms'><span>hours<\/span><span>min.&nbsp;&nbsp;<\/span><span>sec.<\/span><\/div>"); }	
	else {	
	   if (dd < 10) { dd = "0"+dd; }	
	   return (dd+"&nbsp;"+hh+":"+mm+":"+ss+"<div class='hms'><span>days<\/span><span>hours<\/span><span>min.&nbsp;&nbsp;<\/span><span>sec.<\/span><\/div>"); 
	}	
}
// создаем счетчик
function do_cd2()
{
	if (countdown < 0)	
	{ 		
    //document.getElementById('cd').innerHTML = "<div class='svsob'>Go to event<\/div>";
    document.getElementById('cdblock').style.display = "none";	
	}	
	else	
	{	
		document.getElementById('cd').innerHTML = convert_to_time2(countdown);
		setTimeout('do_cd2()', 1000);
	}	
	countdown = countdown - 1;	
}
