var plugin=(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;

function flash(arg,w,h,path,img) {

if ( plugin ) {
        plugin=parseInt(plugin.description.substring(plugin.description.indexOf(".")-1))>=6;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
   && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
        document.write('<SCRIPT LANGUAGE=VBScript\> \n');
        document.write('on error resume next \n');
        document.write('plugin=( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))\n');
        document.write('</SCRIPT\> \n');
}
if ( plugin ) {

        document.write('<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
        document.write('  codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"  ');
        document.write(' width="'+w+'" height="'+h+'" id="'+arg+'" align="middle">');
        document.write(' <PARAM NAME=movie VALUE="'+path+arg+'.swf"> <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF>  ');
        document.write(' <param name="allowScriptAccess" value="sameDomain" />');
        document.write(' <EMBED src="'+path+arg+'.swf" menu=false quality=high bgcolor=#FFFFFF  ');
        document.write(' swLiveConnect=FALSE WIDTH='+w+' height='+h+' name="'+arg+'" align="middle" allowScriptAccess="sameDomain" ');
        document.write(' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> ');
        document.write(' </EMBED><br></OBJECT>');

}
else {
        document.write('<IMG SRC="'+path+img+'" WIDTH="'+w+'" HEIGHT="'+h+'" BORDER= "0" ALT = "" ><br>');
}
}
 
function trim(str) {
    var newstr = str.replace(/^\s*(.+?)\s*$/, "$1");
    if (newstr == " ") {
        return "";
    }
    return newstr;
}
function drop_spaces(str) {
    var newstr = trim(str); 
    return newstr.replace(/(\s)+/g, ""); 
}
function isValidEmail(email) {
    var template = /^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z])+$/;
    email = drop_spaces(email); 
    if (template.test(email)) {
        return true;
    }
    return false; 
}

function toupper() {                     
        var error = 0;
        var msg = "Ошибка!\n\n";
        seach_text = document.msearch.seach_text.value;
        if(!seach_text) { error = 1; msg += " - Не ввели параметры поиска\n"; }
        if(!error) { 
         document.msearch.seach_text.value = seach_text.toUpperCase() ;
	  document.msearch.submit(); 
        }
        else { alert(msg); }
             
}

// смена картинок
function animate(tagId,alfa,step){
 div = document.getElementById(tagId);
 var items = new Array();
 //Выбираем все рисунки слайдшоу
 for(c=i=0;i<div.childNodes.length;i++){
  if (div.childNodes[i].tagName=="A"){
   items[c] = div.childNodes[i];
   c++;
  }
 }
 last = items[items.length-1];
 next = items[items.length-2];
 //делаем верхний в стопке(текущий) рисунок более прозрачным
 last.style.opacity= alfa/100;
 last.style.filter= "progid:DXImageTransform.Microsoft.Alpha(opacity="+alfa+")";
 last.style.filter= "alpha(opacity="+alfa+")";

 if ((alfa-step)>0){
  //если еще не достигли полной прозрачности верхнего рисунка - продолжаем анимацию
   setTimeout("animate('"+tagId+"',"+(alfa-step)+","+step+");",50);
 }else{
  //если достигли полной прозрачности верхнего рисунка
  //делаем абсолютно непрозрачным следующий рисунок
  next.style.opacity= 1;
  next.style.filter= "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
  next.style.filter= "alpha(opacity=100)";
  // а верхний рисунок перемещаем в низ стопки
  tmp = last;
  div.removeChild(last);
  div.insertBefore(tmp,items[0]);
  tmp.style.opacity= 1;
  tmp.style.filter= "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
  tmp.style.filter= "alpha(opacity=100)";

  setTimeout( "slideSwitch('"+tagId+"',1000)", 8000 );
 }
}
//эта функция делает видимым блок с рисунками для слайдшоу (изначально он невидим, чтобы избежать мерцания во время загрузки картинок) и запускает анимацию
function slideSwitch(tagId,speed){
 div = document.getElementById('slideshow');
 if (div.style.visibility!="visible"){
      div.style.visibility = "visible";
 }
 items = div.getElementsByTagName('img');
 if (items.length>0){
  animate(tagId,100,1);
 }
}

// -- печать картинки--------------

function makepage(src) {
  return "<html>\n" +
    "<head>\n" +
    "<script>\n" +
    "var i=0;\n" +
    "function resize() {\n" +
    "   if (navigator.appName == 'Netscape') i=40;\n" +
    "   if (document.images[0]) window.resizeTo(document.images[0].width +30, document.images[0].height+60-i);\n" +
    "   self.focus();\n" +
    "    step1();\n" +
    "}\n" +
    "function step1() {\n" +
    "  setTimeout('step2()', 10);\n" +
    "}\n" +
    "function step2() {\n" +
    "  window.print();\n" +
    "  window.close();\n" +
    "}\n" +
    "</scr" + "ipt>\n" +
    "</head>\n" +
    "<body onLoad='resize()'>\n" +
    "<img src='" + src + "'/>\n" +
    "</body>\n" +
    "</html>\n";
}
function printpic(src) {
  link = "about:blank";
  var pw = window.open(link,"_new");
  pw.document.open();
  pw.document.write(makepage(src));
  pw.document.close();
}

