﻿var arr = document.getElementsByName("cat_link");
function window_onload() 
{
	MM_preloadImages('images/on.gif','images/off.gif');
	for(var i=0;i<arr.length;i++){
		if(document.location.href == arr[i].href)
			arr[i].className = 'level_b';
	}	
}


function openWindow(url_link, new_window)
{
	if(new_window)
		window.open(url_link);
	else{
		window.location=url_link;
		return(false);
	}
}

function sendMail(url)
{
	var sName = new String(document.all.textName.value);
	var sNameUTF ='';
	if(sName.length > 2){
		for(var i=0;i<sName.length;i++){
			sNameUTF += sName.charCodeAt(i);
			if(i<(sName.length-1)) sNameUTF += ',';
		}
	}
	var sPrefix = new String(document.all.prefix.options[document.all.prefix.selectedIndex].text);
	var sPhone = new String(document.all.textPhone.value);
	
	url += '?name=' + sNameUTF + '&pref=' + sPrefix + '&phone=' + sPhone;
	document.all.textName.value='';
	document.all.prefix.selectedIndex=0;
	document.all.textPhone.value='';

	//window.open(url,'SendMail','toolbar=no, status=no, scrollbars=no, width=300, height=150');
	if((sName.length>2)&&(sPhone.length==7))
		window.showModelessDialog(url,"SendMail",'scroll:0;status:0;help:0;resizable:0;dialogWidth:300px;dialogHeight:200px');
	else alert("Введите имя и номер телефона");
}

// validate function
function validateName()
{
	var sText = new String(document.all.name.value);
	if(sText.length<3){
		alert("Неверное имя");
		return false;
	}
	return true;
}
function validatePhone()
{
	var sPhone = new String(document.all.textPhone.value);
	if((Number(sPhone)!= Number.NaN)&&(sPhone.length == 7))
		return true;
	else{
		alert("Неверный номер телефона");
		return false;
	}
}

function openTeacher(url)
{
	//window.open(url,"Кидум - Учителя",'toolbar=no, status=no, scrollbars=no, width=330, height=285');
	window.showModelessDialog(url,"Наши преподователи",'scroll:0;status:0;help:0;resizable:0;dialogWidth:330px;dialogHeight:310px');
}



