
function win(url, name, width, height) {
        open(url,name,'height='+height+',width='+width+',resizable=1,scrollbars=yes,menubar=no,status=no');
}

function redirect(){
        if (document.redirecter.redirect_select.options[document.redirecter.redirect_select.selectedIndex].value != "none") { 
                location = document.redirecter.redirect_select.options[document.redirecter.redirect_select.selectedIndex].value;
        }
}

function val_market(theform) {

        var n = theform.name;
        var e = theform.email;
        var m = theform.mess;

        if (n.value == "") {
                alert('Напишите Ваше имя!');
                n.focus();
                return false;
        }

        if (e.value == "") {
                alert('Напишите Ваш адрес E-Mail!');
                e.focus();
                return false;
        }

        if (m.value == "") {
                alert('Напишите текст объявления!');
                m.focus();
                return false;
        }

        submit_once(theform);

        return true;
}

function val_search(theform) {
        var t = theform.search_text;
        var w = theform.search_where.options[theform.search_where.selectedIndex];

        if (t.value == "") {
                alert("Напишите текст для поиска!");
                t.focus();
                return false;
        }

        if (w.value == "none") { 
                alert('Укажите место поиска!');
                return false;
        }
        
        return true;
}

function val_mail(theform) {
        var e=theform.email;
        var i=e.value.indexOf('\@');

        if (i>0 && i<e.value.length-1) {

            var mail_win = win("", "mail_win", 350, 200);
                mail_win.focus(); mail_win.document.open();
                mail_win.document.write("<html><head><title>Рассылка</title></head>");
                mail_win.document.write("<body topmargin=0 bgcolor=#FFFFFF leftmargin=0 marginwidth=0 marginheight=0>");
                mail_win.document.write("<table width=100% height=100% align=center><tr><td align=center valign=middle><font face=Verdana size=2>Пожалуйста, подождите...</font></td></tr></table>");
                mail_win.document.write("</body></html>");
                mail_win.document.close();
        } else {
                if (e.value == "") {
                        alert('Напишите Ваш адрес E-Mail!');
                } else {
                        alert('Напишите правильный адрес E-Mail');
                }
                e.focus();
                return false;
        }

        return true
}


function val_vote_111(theform) {
        var r = theform.vote;

        var ch = false;

        for (i=0; i <r.length; i++) {
                if (r[i].checked) {
                        ch = true;
                }
        }

        if (!ch) {
                alert("Выберите один из пунктов!");
                return false;
        }

    var vote_win = win("", "vote_win", 250, 450);
        vote_win.focus(); vote_win.document.open();
        vote_win.document.write("<html><head><title>Голосование</title></head>");
        vote_win.document.write("<body topmargin=0 bgcolor=#FFFFFF leftmargin=0 marginwidth=0 marginheight=0>");
        vote_win.document.write("<table width=100% height=100% align=center><tr><td align=center valign=middle><font face=Verdana size=2>Пожалуйста, подождите...</font></td></tr></table>");
        vote_win.document.write("</body></html>");
        vote_win.document.close();

        return true;
}

function val_vote(theform) {
	var r = theform.vote;

	var ch = false;

	for (i=0; i <r.length; i++) {
		if (r[i].checked) {
			ch = true;
		}
	}

	if (ch == false) {
		alert("Выберите один из пунктов!");
		return false;
	}

    var vote_win = win("", "vote_win", 250, 450);

	return true;
}


function submit_once(theform) {
        if (document.all || document.getElementById) {
                for (i=0;i<theform.length;i++) {
                        var tempobj=theform.elements[i];
                        if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") {
                                tempobj.disabled=true;
                        }
                }
        }
}

 
function staticwindow(url)
 {
  window.open(url,"","width=720,height=480,toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no,location=no");
 }

function dinamicwindow(url)
 {
  window.open(url,"","width=600,height=500,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,location=no");
 }

function newImage(arg) {
        if (document.images) {
                rslt = new Image();
                rslt.src = arg;
                return rslt;
        }
}

function changeImages() {
        if (document.images && (preloadFlag == true)) {
                for (var i=0; i<changeImages.arguments.length; i+=2) {
                        document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
                }
        }
}

var preloadFlag = false;
function preloadImages() {
        if (document.images) {
                news_n = newImage("/images/menu/news_n.gif");
                team_n = newImage("/images/menu/team_n.gif");
                statutes_n = newImage("/images/menu/statutes_n.gif");
                prot_n = newImage("/images/menu/protocols_n.gif");
                gb_n = newImage("/images/menu/gb_n.gif");
                forum_n = newImage("/images/menu/forum_n.gif");
                contact_n = newImage("/images/menu/contact_n.gif");
		links_n = newImage("/images/menu/links_n.gif");
        
                preloadFlag = true;
        }    
}

window.status = "Сайт команды Красноярского Государственного Университета по спортивному ориентированию";