function get_flash(idflash,path,width,height,codebase_version,classid)
{
        var tagflash = document.getElementById(idflash);
        var codeflash = '';

        codeflash = '<object classid="clsid:'+classid+'" width="'+width+'" height="'+height+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+codebase_version+'">';
        codeflash += '<param name="movie" value="'+path+'"><param name="play" value="true"><param name="loop" value="true"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent">';
        codeflash += '<embed src="'+path+'" wmode="transparent" loop="true" quality="high" menu="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="'+width+'" height="'+height+'"></embed></object>';
        tagflash.innerHTML = codeflash;
        //alert(tagflash.);
        //tagflash.innerHTML="1";
}
function checkaddphoto()
{
	name = document.getElementById("name_foto").value;
	info = document.getElementById("info_foto").value;
 	userfile2 = document.getElementById("userfile_big").value;
    if(name=='')
    {
        alert('Наименование обязательно.');
        return false;
    }
    if(info=='')
    {
        alert('Описание обязательно.');
        return false;
    }
    if(userfile2=='')
    {
        alert('Фотография обязательна.');
        return false;
    }
    if((name!='') && (info!='') && (userfile2!='')){document.getElementById('addFotoForm').submit();}
}
function testeditdata(frm)
{
        if (frm.reg_name.value!='' && frm.reg_login.value!='' && frm.reg_email.value!='' && frm.reg_lastname.value!='')
        {
             frm.submit();
        }
        else
        {
             alert("Заполните все обязательные поля!");
        }
}
function answer(frm)
{
       answer0 = 'document.getElementById("an'+frm+'").style.display';
       answer1 = eval(answer0);
       if(answer1=="none"){
          ans = 'document.getElementById("an'+frm+'").style.display=""';
          eval(ans);
       }
       else
       {
          ans = 'document.getElementById("an'+frm+'").style.display="none"';
          eval(ans);
       }
}
function testregdata(frm)
{
        if (frm.reg_name.value!='' && frm.reg_login.value!='' && frm.reg_email.value!='' && frm.reg_lastname.value!='' && frm.reg_pwd.value!='' && frm.reg_cppwd.value!='')
        {
                if(frm.reg_pwd.value==frm.reg_cppwd.value){
                     frm.submit();
                }
                else{
                     alert("Проверьте правильность ввода пароля!");
                }
        }else
        {
             alert("Заполните все обязательные поля!");
        }
}
function file(id)
{
        window.open("uploadfilefor"+id+".html",'myFilePlus', 'width=450,height=180,status=no,toolbar=no,menubar=no,scrollbars=no');
}
function checkfileupload()
{
        name = document.getElementById('name').value;
        file = document.getElementById('file').value;

    if(file=='')
    {
       alert('Пожалуйста, выберете файл для загрузки');
       return false;
    }
}
function testdata()
{
	if(document.getElementById("firstname").value!='' && document.getElementById("email").value!='' && document.getElementById("lastname").value!='' && document.getElementById("txtmes").value!='')
    {
    	document.getElementById("sendForm").submit();
    }else
    {
    	alert("Заполните все поля!");
    }
}
function checkmailnews() {
      if (!(/^[a-zA-Z][a-z0-9\-\_\.]{1,20}@[a-z0-9\-\_\.]{5,30}$/.test(document.getElementById("sendasknews").value))) {
            alert("Проверьте E-mail адрес!");
            return false;
      }
      return true;
}
function chk()
{
    if (document.searchForm.keyword.value == "") {
        alert('Введите ключевое слово или фразу!');
        return false;
    }
    if (document.searchForm.keyword.value.length<=2) {
        alert('Введите более 2 символов!');
        return false;
    }
    return true;
}

function editsubuser(id)
{
        window.open("tools_admin/editsub.php?action=editsubuser&id="+id,'myWin', 'width=450,height=150,status=no,toolbar=no,menubar=no,scrollbars=no');
}

function addpmenu(id)
{
        window.open("tools_admin/editmenu.php?action=addme&idpm="+id,'myWin', 'width=450,height=150,status=no,toolbar=no,menubar=no,scrollbars=no');
}
function addinnermenu(id)
{
        window.open("tools_admin/actinnermenu.php?action=addme&idpm="+id,'myWin', 'width=450,height=150,status=no,toolbar=no,menubar=no,scrollbars=no');
}
function editmenu(id)
{
        window.open("tools_admin/editmenu.php?action=editmenu&idmenu="+id,'myWin', 'width=450,height=150,status=no,toolbar=no,menubar=no,scrollbars=no');
}
function editinnermenu(id)
{
        window.open("tools_admin/actinnermenu.php?action=editmenu&idmenu="+id,'myWin', 'width=450,height=150,status=no,toolbar=no,menubar=no,scrollbars=no');
}
function addanswer(id)
{
        window.open("tools_admin/admguest.php?action=addoneanswer&idquest="+id,'addanswer', 'width=450,height=365,status=no,toolbar=no,menubar=no,scrollbars=no');
}
function editanswer(id)
{
        window.open("tools_admin/admguest.php?action=editoneanswer&idquest="+id,'editanswer', 'width=450,height=375,status=no,toolbar=no,menubar=no,scrollbars=no');
}
function addcat(id)
{
        window.open("tools_admin/editcat.php?action=addcat&idcat="+id,'myWin', 'width=450,height=150,status=no,toolbar=no,menubar=no,scrollbars=no');
}
function editcat(id)
{
        window.open("tools_admin/editcat.php?action=editcat&idcat="+id,'myWin', 'width=450,height=144,status=no,toolbar=no,menubar=no,scrollbars=no');
}
function addgoods(id)
{
    window.open("tools_admin/editgoods.php?action=addgoods&idcat="+id,'addgoods', 'width=450,height=235,status=no,toolbar=no,menubar=no,scrollbars=no');
}
function info(id)
{
    window.open("infogoods.php?idgoods="+id,'infogoods', 'width=500,height=550,status=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes');
}
function big(id) {
        window.open("building.php?id="+id,'building'+id, 'width=750,height=520,status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes');
}

function checkmessage(frm)
{
        if (frm.title.value!='' && frm.message.value!='')
        {
            frm.submit();
        }
        else
        {
             alert("Заполните все поля!");
        }
};

function createwin(wname,name,w,h)
{
    myWin= window.open(name, wname, 'location=0,menubar=0,toolbar=0,resizable=0,scrollbars=0,width='+w+',height='+h+'');
    myWin.focus();
}
function createwinse(wname,name,w,h)
{
    myWin= window.open(name, wname, 'scrollbars=no,resizable=yes,status=no,width='+w+',height='+h+'');
    myWin.focus();
}
function checkeditphoto()
{
	name = document.getElementById("name_foto").value;
	info = document.getElementById("info_foto").value;

    if(name=='')
    {
        alert('Наименование обязательно.');
        return false;
    }
    if(info=='')
    {
        alert('Описание обязательно.');
        return false;
    }
    if((name!='') && (info!='')){document.getElementById('editFotoForm').submit();}
}
function resize_win(img_width, img_height) {
	var dy = 100;
	var dx = 28;

	// Fit window
	fit_width = img_width - win_width;
	fit_height = img_height - win_height;

	if (fit_width > 0) {
		self.resizeTo(img_width + dx, win_height);
		win_width = img_width + dx;
	}

	if (fit_height > 0) {
		self.resizeTo(win_width, img_height + dy);
		win_height = img_height + dy;
	}

	// Center window
	x = (screen.width / 2) - (win_width / 2);
	y = (screen.height / 2) - (win_height / 2);
	self.moveTo(x, y);
}
function close_win()
{
    myWin= close();
}
