nn4 = (document.layers) ? true : false;
ie4 = (document.all) ? true : false;
dom = (document.createTextNode)? true : false;

function popupWindow(fileUrl, winW, winH, winN, scrollB) {
	var winWidth = (winW)? winW : 740;
	var winHeight = (winH)? winH : 520;
	var winName = (winN)? winN : 'popupWin'
	var scrollBars = (scrollB)? scrollB : 'auto'
	if (nn4 || ie4 || dom) {
		if (screen.width < winWidth + 50) { winWidth = screen.width - 50; scrollbars = 'yes' }
		if (screen.height < winHeight + 100) { winHeight = screen.height - 100; scrollbars = 'yes' }
		posX = Math.round((screen.width - winWidth) / 2);
		posY = Math.round((screen.height - winHeight) / 2);
		posCode = (nn4 || dom)? "screenX="+posX+",screenY="+posY : "left="+posX+",top="+posY;
	} else {
		posCode = "";
	}
	var popupWin = window.open(fileUrl, winName,"menubar=no,toolbar=no,scrollbars=" + scrollBars + ",status=yes,resizable=yes,width=" + winWidth + ",height=" + winHeight + "," + posCode);
	if (popupWin) popupWin.focus();
}

function generateFlash(movie, width, height, id, align, bgUrl)
{
  document.write('<div style="background:url(' + bgUrl + ') no-repeat left top;' + (width==0 ? '' : '" width="'+width) + (height==0 ? '' : '" height="'+height) + '">');
  document.write('<object type="application/x-shockwave-flash" data="'+movie+(width==0 ? '' : '" width="'+width)+(height==0 ? '' : '" height="'+height)+'" id="'+id+'" align="'+align+'">');
  document.write('<param name="movie" value="'+movie+'" />');
  document.write('<param name="wmode" value="opaque" />');
  document.write('<param name="autoStart" value="-1" />');
  document.write('</object>');
  document.write('</div>');
}

function twocolors() {
	var tables = document.getElementsByTagName("table");
	for ( var k = 0; k < tables.length; k++ ) {
		if (tables[k].className == 'twocolors') {
			var rows = tables[k].getElementsByTagName("tr");
			for ( var i = 0; i < rows.length; i += 2 )
			rows[i].className = rows[i].className + " darktr"
			for ( var i = 1; i < rows.length; i += 2 )
			rows[i].className = rows[i].className + " lighttr"
		}
	}			

	var tables = document.getElementsByTagName("ul");
	for ( var k = 0; k < tables.length; k++ ) {
		if (tables[k].className == 'twocolors') {
			var rows = tables[k].getElementsByTagName("li");
			for ( var i = 0; i < rows.length; i += 2 )
			rows[i].className = rows[i].className + " darktr"
			for ( var i = 1; i < rows.length; i += 2 )
			rows[i].className = rows[i].className + " lighttr"
		}
	}			
}


/*function openurl(){
	var url = document.selectNav.gotourl.options[document.selectNav.gotourl.selectedIndex].value;
    if ( url && url != '#' ) {
        eval("document.location='"+url+"'");
    }
}*/



/**
* Обработка поля ввода
*/

function inputController()
{

}

inputController.object = null;
inputController.button = null;
inputController.classActive = '';
inputController.classInactive = '';
inputController.defaultValue = '';
inputController.isSubmitable = ''; 

inputController.prototype.init = function(inputId, buttonId)
{
    // настройки
    this.classInactive = 'inputFieldInactive';
    this.classActive = 'inputFieldActive';
    this.defaultValue = 'Поиск на сайте';
    this.isSubmitable = false;

    this.object = document.getElementById(inputId);
    this.button = document.getElementById(buttonId);
    
    this.object.className = this.classInactive;
    this.object.value = this.defaultValue;
    
    
    
}

inputController.prototype.clear = function()
{
    if ( this.object.value == this.defaultValue) {
        this.object.value = '';
    }
    this.object.className = this.classActive;
}

inputController.prototype.lostFocus = function()
{
    if (this.object.value == '' ||  this.object.value == this.defaultValue) {
        this.object.value = this.defaultValue;
        this.object.className = this.classInactive;
    }
}

inputController.prototype.keyPressed = function()
{
    if (this.object.value != '') {
        this.isSubmitable = true;
    } else {
        this.isSubmitable = false;
    }
}

inputController.prototype.submit = function()
{
    if (this.isSubmitable) {
        return true;
    } 
    else return false;
}

function set_values()
{
	if (document.forms['feedback'].name.value == ""){
		document.forms['feedback'].name.value = "Ваше имя";
		document.forms['feedback'].name.className = 'com_in_inactive';
	}
	if (document.forms['feedback'].email.value == ""){
		document.forms['feedback'].email.value = "Ваш Email";
		document.forms['feedback'].email.className = 'com_in_inactive';
	}
	if(document.forms['feedback'].phone.value == "")
		document.forms['feedback'].phone.value = "Ваш телефон";
		document.forms['feedback'].phone.className = 'com_in_inactive';
	if (msg.value == ""){
		msg.value = "Текст сообщения";	
		msg.className = 'com_in_inactive';
	}
	return;
}


function reset_value(name)
{
	switch (name) {
		case 'name':
			if (document.forms['feedback'].name.value == "Ваше имя")
				document.forms['feedback'].name.value = '';
			break;
		case 'email':
			if (document.forms['feedback'].email.value == "Ваш Email")
				document.forms['feedback'].email.value = '';
			break;
		case 'phone':
			if (document.forms['feedback'].phone.value == "Ваш телефон")
				document.forms['feedback'].phone.value = '';
			break;
		case 'message':
			if (msg.value == "Текст сообщения")
				msg.value = '';
			break;
	}
	return;
}

document.write('<script type="text/javascript" src="/bitrix/template_files/js/shortcut.js"></script>');

function submitSubscribeForm()
{
	 if (subscribeFormText.value != '') {
        subscribeForm.submit();
    }
}

function submitSearchForm()
{
	 if (searchFormText.value != '') {
        searchForm.submit();
    }
}