var nn4 = (document.layers) ? true : false;
var ie4 = (document.all) ? true : false;
var dom = (document.createTextNode)? true : false;

function openurl(obj){
	var url = obj.value;
    if ( url && url != '#' ) {
        eval("document.location='"+url+"'");
    }
}

function popupWindow(fileUrl, winW, winH, winN, scrollB) {
	var winWidth = winW;
	var winHeight = winH;
    
	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 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];
		}
	}
}

/**
* Генерация флэш
*/

function generateFlash(movie, width, height, id, align)
{
    document.write('<object type="application/x-shockwave-flash" data="'+movie+'" width="'+width+'" height="'+height+'" id="'+id+'" align="'+align+'">');
    document.write('<param name="movie" value="'+movie+'" />');
    document.write('<param name="wmode" value="transparent" />');
    document.write('<param name="autoStart" value="-1" />');
    document.write('</object>');
}

/**
* Обработка поля ввода
*/

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()
{
	//f = document.forms['feedback'];
//	msg = document.getElementById('con_msg');
	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;
}