function winopen(sUrl, iWidth, iHeight,resizable,scroll) {
   var Win = window.open(sUrl,"view",'width=' + iWidth + ',height=' + iHeight + ',resizable='+ resizable +',scrollbars='+ scroll +',menubar=no' );
   Win.moveTo(150,150)
   Win.creator=self
   Win.focus();
   }

function okno(sUrl, iWidth, iHeight, titel) {
var oknoString=""+
"<html>"+
"<head>"+
"<title>::: POB EFEKT Gorzów Wlkp. "+ titel +" :::</title>"+
"</head>"+
"<body  bgcolor='yellow'><center><img align='center' src='"+ sUrl +"' border='0' /></center>"+
"<script language='JavaScript'>window.focus();</script><body></head>";
var Win = window.open("","view",'width=' + iWidth + ',height=' + iHeight + ',resizable=no,scrollbars=no,menubar=no' );
Win.document.open();
Win.document.write(oknoString);
Win.document.close();
Win.focus()
Win.resizeTo(iWidth,iHeight)
}


function email(user, host, css){
document.write('e-mail: <A class="'+css+'" HR' + 'EF="mai' + 'lto:' + user + '\x40' + host  + '">');
document.write(user + '\x40' + host + '</A>');
}


function displayWindow(sUrl, iWidth, iHeight) {
   var Win = window.open(sUrl,"view",'width=' + iWidth + ',height=' + iHeight + ',resizable=no,scrollbars=no,menubar=no' );
}

function screenSize(){
   var w = screen.width;
   if (w <=  640)     document.write('<link rel="stylesheet" type="text/css" href="style640.css">');
   else if (w <=  800)     document.write('<link rel="stylesheet" type="text/css" href="style800.css">');
   else  document.write('<link rel="stylesheet" type="text/css" href="style1024.css">')
}


function checkText(sText, sName, bAllowEmpty, iMaxLength)
{
   var sErrorMsg = "";
   if(!bAllowEmpty && sText == "")
   {
      sErrorMsg = "- " + sName + " ist leer!!! \n";
   }
   else if(sText != "")
   {  sText = trim(sText);
      if(iMaxLength != null && sText.length > iMaxLength)
         sErrorMsg += "- " + sName  + " zu lang!!! \n";
   }
   return sErrorMsg;
}


function checkFileExt(sFilePath, arrExtensions, sName)
{
   var sErrorMsg = "";
   if(sFilePath == "")
   {
      sErrorMsg = "- " + sName + " wählen !!!\n";
   }
   else if(sFilePath != "")
   {
      sFilePath = trim(sFilePath);
      var sThisExt = sFilePath.slice(sFilePath.lastIndexOf(".") + 1);
      var bFound   = false;
      var sAllExt  = "";

      for(var i = 0; i < arrExtensions.length; i++)
      {
         if(arrExtensions[i].toLowerCase() == sThisExt.toLowerCase())
            bFound = true;
         sAllExt += "\"" + arrExtensions[i] + "\", ";
         if(i == arrExtensions.length-1)
            sAllExt = sAllExt.slice(0,sAllExt.length-2);
      }


      if(!bFound)
         sErrorMsg = "- " + sName + " ist falsch !!!\n";

   }
   return sErrorMsg;
}


function checkEMail(sEmail, sName)
{
   var exclude   =/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
   var check     =/@[\w\-]+\./;
   var checkend  =/\.[a-zA-Z]{2,3}$/;
   var sErrorMsg = "";

   if(sEmail == "")
   {
      sErrorMsg = "";
   }
   else if(sEmail != "")
   {
     sEmail = trim(sEmail);
      if(((sEmail.search(exclude) != -1) ||
          (sEmail.search(check)) == -1) ||
          (sEmail.search(checkend) == -1))
      {
         sErrorMsg = "";
      }
   }
   return sErrorMsg;
}


function checkSelect(oFormObj, sName)
{
   var sErrorMsg = "";

   if(oFormObj.multiple)
   {
      sErrorMsg = "- " + sName + " wählen !!!\n";
      for(var i=0; i<oFormObj.options.length; i++)
      {
         if(oFormObj.options[i].selected)
         {
            sErrorMsg = "";
            break;
         }
      }
   }
   else
   {
      if(oFormObj.options[oFormObj.selectedIndex].value == "0" ||
         oFormObj.options[oFormObj.selectedIndex].value == "")
      {
         sErrorMsg = "- " + sName + " ";
      }
   }
   return sErrorMsg;
}



function ltrim(sValue)
{
   while(1)
   {
      if(sValue.substring(0, 1) != " ")
         break;
      sValue = sValue.substring(1, sValue.length);
   }
   return sValue;
}

function rtrim(sValue)
{
   while(1)
   {
      if(sValue.substring(sValue.length - 1, sValue.length) != " ")
         break;
      sValue = sValue.substring(0, sValue.length - 1);
   }
   return sValue;
}


function trim(sValue)
{
   var sTemp = ltrim(sValue);
   return rtrim(sTemp);
}
