function uniqueId(input) 
{
    re = /[A-Za-z0-9]/g;
    myArray = input.match(re);
    output = "";
    for (i=0;i<myArray.length;i++) {
        output = output + myArray[i];
    }
    return output;
}



function ShowFullGoods(path, wd, ht, explanation) 
{ 
  WindowName = uniqueId(path);
  wdf = wd + 18;
  htf = ht + 77;
  s = 'status=no,resizable=yes,scrollbars=yes,left=1,top=1' + ',width=' + wdf + ',height=' + htf;
  secWnd = window.open('', WindowName, s);
  with (secWnd)
   {
       
     document.write('<HTML><head><title>' + explanation + '</title>' + "\n");
     document.write('<META http-equiv=Content-Type content="text/html; charset=windows-1251">' + "\n");

     document.write('<script type="text/javascript">' + "\n");
     document.write('<!--' + "\n");
     document.write('var wd = ' + wd + ';' + "\n");
     document.write('var ht = ' + ht + ';' + "\n");


     document.write('focus();' + "\n");

     document.write('function getClientWidth()' + "\n");
     document.write('{' + "\n");
     document.write("	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;" + "\n");
     document.write('}' + "\n");

     document.write('function getClientHeight()' + "\n");
     document.write('{' + "\n");
     document.write("	return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;" + "\n");
     document.write('}' + "\n");

     document.write('function imageSize()' + "\n");
     document.write('{' + "\n");
     document.write('	widthBrowser = getClientWidth() -3;' + "\n");
     document.write('	heightBrowser = getClientHeight() -4;' + "\n");
	
	
     document.write('NewWidth = widthBrowser;' + "\n");
     document.write('NewHeight = Math.round(widthBrowser/wd*ht);' + "\n");

     document.write('if (NewWidth <= wd)' + "\n");
     document.write(' {' + "\n");
     document.write('   document.BigImage.width = NewWidth;' + "\n");
     document.write('   document.BigImage.height = NewHeight;' + "\n");
     document.write(' }' + "\n");
     document.write(' else ' + "\n");
     document.write(' {' + "\n");
     document.write('   document.BigImage.width = wd;' + "\n");
     document.write('   document.BigImage.height = ht;' + "\n");
     document.write(' }' + "\n");

     document.write("	setTimeout('imageSize()', 1000);" + "\n");
     document.write('}' + "\n");

     document.write('-->' + "\n");
     document.write('</script>' + "\n");

     document.write('</head>' + "\n");

     document.write('<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginheight="0" marginwidth="0" bgcolor="#F5D355" onLoad="imageSize()">' + "\n");
     document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">' + "\n");
     document.write('<tr><td align=center valign=top><IMG name="BigImage"  SRC="' + path + '" BORDER="0"></td></tr></table>' + "\n");

     document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background: #28730A;" height="77">' + "\n");
     document.write('<tr><td valign="center" align="center"><p style="margin: 2px 4px"><font size="3" color="#FFFFFF">' + explanation + '</font></p>' + "\n");
     document.write('<a href="#" onclick="javascript: window.close();"><p style="margin: 2px 4px" ><b><font size="3" color="#FFFFFF">Закрыть</font></b></p></a></td>' + "\n");
     document.write('</table>' + "\n");

     document.write('</BODY></HTML>' + "\n");  
       
     document.close();
     focus();
   }
}

function ShowObject(FullFileObjectName, FileType, wd, ht, explanation)
{
   WindowName = uniqueId(FullFileObjectName); 
   s = 'status=no,resizable=yes,scrollbars=yes,left=1,top=1';
   switch (FileType)
   {
     case 1: window.open(FullFileObjectName, WindowName, s);  break;        // Посмотреть картинку
     case 2: document.location.href=FullFileObjectName;  break;             // Скачать архив
     case 3: ShowVideoMOV(FullFileObjectName, wd, ht, explanation); break;  // Посмотреть видеоролик MOV
     case 4: document.location.href=FullFileObjectName;  break;             // Посмотреть видеоролик AVI
     case 5: ShowFlash(FullFileObjectName, wd, ht, explanation); break;     // Посмотреть Flash ролик swf
     case 6: document.location.href=FullFileObjectName;  break;             // Послушать mp3, wav   
     case 7: document.location.href=FullFileObjectName;  break;             // Документ Microsoft Word  
     case 8: document.location.href=FullFileObjectName;  break;             // Документ Microsoft Excel
     case 9: window.open(FullFileObjectName, WindowName, s);  break;        // Посмотреть текст       
   } 
}


function ShowFlash(Filename, wd, ht, explanation)   
{
  WindowName = uniqueId(Filename);
  wdf = wd + 18;
  htf = ht + 77;
  s = 'status=no,resizable=yes,scrollbars=yes,left=1,top=1' + ',width=' + wdf + ',height=' + htf;
  secWnd = window.open('', WindowName, s);
  with (secWnd)
   {
       
     document.write('<HTML><head><title>' + explanation + '</title></head>'+"\n");
     document.write('<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginheight="0" marginwidth="0" bgcolor="#F5D355" onload="focus()">'+"\n");
     document.write('<table width="' + wd + '" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">'+"\n");
     document.write('<tr><td align=center valign=top>'+"\n");
         
     document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + wd + '" height="' + ht + '" id="flash" align="middle">'+"\n");
     document.write('<param name="allowScriptAccess" value="sameDomain">'+"\n");
     document.write('<param name="movie" value="' + Filename + '">'+"\n");
     document.write('<param name="quality" value="high">'+"\n");
     document.write('<embed src="' + Filename + '" quality="high" width="' + wd + '" height="' + ht + '" name="flashka" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+"\n");
     document.write('</object>'+"\n");

     document.write('</td></tr></table>');

     document.write('<table width="' + wd + '" border="0" cellspacing="0" cellpadding="0" style="background: #28730A;" height="77">');
     document.write('<tr><td valign="center" align="center"><p style="margin: 2px 4px"><font size="3" color="#FFFFFF">' + explanation + '</font></p>');
     document.write('<a href="#" onclick="javascript: window.close();"><p style="margin: 2px 4px" ><b><font size="3" color="#FFFFFF">Закрыть</font></b></p></a></td>');
     document.write('</table>');

     document.write('</BODY></HTML>');      document.close();
     focus();
   }    
}



function ShowVideoMOV(Filename, wd, ht, explanation)
{
  WindowName = uniqueId(Filename);
  wdf = wd + 18;
  htf = ht + 77;
  s = 'status=no,resizable=yes,scrollbars=yes,left=1,top=1' + ',width=' + wdf + ',height=' + htf;
  secWnd = window.open('', WindowName, s);
  with (secWnd)
   {
       
     document.write('<HTML><head><title>' + explanation + '</title></head>'+"\n");
     document.write('<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginheight="0" marginwidth="0" bgcolor="#F5D355" onload="focus()">'+"\n");
     document.write('<table width="' + wd + '" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">'+"\n");
     document.write('<tr><td align=center valign=top>'+"\n");

     document.write('<OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ');
     document.write('WIDTH="' + wd + '" HEIGHT="' + ht + '" ');
     document.write('CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0">'+"\n");
     document.write('   <PARAM NAME="controller" VALUE="TRUE">'+"\n");
     document.write('   <PARAM NAME="type" VALUE="video/quicktime">'+"\n");
     document.write('   <PARAM NAME="autoplay" VALUE="true">'+"\n");
     document.write('   <PARAM NAME="target" VALUE="myself">'+"\n");
     document.write('   <PARAM NAME="src" VALUE="' + Filename + '">'+"\n");
     document.write('   <PARAM NAME="pluginspage" VALUE="http://www.apple.com/quicktime/download/">'+"\n");
     document.write('   <EMBED WIDTH="' + wd + '" HEIGHT="' + ht + '" ');
     document.write('   CONTROLLER="TRUE" ');
     document.write('   SRC="' + Filename + '" ');
     document.write('   type="video/quicktime" TARGET="myself" BGCOLOR="#000000" BORDER="0" ');
     document.write('   PLUGINSPAGE="http://www.apple.com/quicktime/download/"> ');
     document.write('   </EMBED>'+"\n");
     document.write('</OBJECT>');     
     
     document.write('</td></tr></table>');

     document.write('<table width="' + wd + '" border="0" cellspacing="0" cellpadding="0" style="background: #28730A;" height="77">');
     document.write('<tr><td valign="center" align="center"><p style="margin: 2px 4px"><font size="3" color="#FFFFFF">' + explanation + '</font></p>');
     document.write('<a href="#" onclick="javascript: window.close();"><p style="margin: 2px 4px" ><b><font size="3" color="#FFFFFF">Закрыть</font></b></p></a></td>');
     document.write('</table>');

     document.write('</BODY></HTML>');  
       
     document.close();
     focus();
   }    
}

