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 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 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';
    if (inputId == 'searchtext') {
        this.defaultValue = 'Введите ваш запрос';
    }
    if (inputId == 'searchtext2') {
        this.defaultValue = 'Ваш E-mail';
    }
    
    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;
}

function showImage(image, w, h, title)
{
	//var im = new Image();
	//im.src = image;

	var w = Math.min(Math.ceil(screen.availWidth * 2 / 3), w);
	var h = Math.min(Math.ceil(screen.availHeight * 2 / 3), h);
    
	var x = Math.ceil((screen.availWidth - w) / 2);
	var y = Math.ceil((screen.availHeight - h) / 2);
    	
	var newwindow = window.open('', 'mywin', 'resizable=1, menubar=0, status=0, width='+w+', height='+h+', top='+y+', left='+x);
	newwindow.document.write('<html><head><title>'+title+'</title></head>');
	newwindow.document.write('<body style="margin:0;padding:0" onclick="window.close();"><a href="javascript:void(0);"><img src="'+image+'" border="0" title="Закрыть окно"></a></body></html>');
	newwindow.document.close();
}


