// JavaScript Document
function Select_Value_Set(SelectName, Value) {

  eval('SelectObject = document.' + SelectName + ';');
  for(index = 0; index < SelectObject.length; index++) {
      if(SelectObject[index].value == Value)
          SelectObject.selectedIndex = index;
  }
}



function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = objContElm.getElementsByTagName(strTag);
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (var i = 0, j = objColl.length; i < j; i++) {
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]);
          break comparisonLoop;
        }
      }
    }
  }
  return arr;
}


// Popup Window functions ------------
 //url string encoding
 function encodeUrl(url)  
 {  
     if (url.indexOf("?")>0)  
     {  
         encodedParams = "?";  
         parts = url.split("?");  
         params = parts[1].split("&");  
         for(i = 0; i < params.length; i++)  
         {  
             if (i > 0)  
             {  
                 encodedParams += "&";  
             }  
             if (params[i].indexOf("=")>0) //Avoid null values  
             {  
                 p = params[i].split("=");  
                 encodedParams += (p[0] + "=" + escape(encodeURI(p[1])));  
             }  
             else  
             {  
                 encodedParams += params[i];  
             }  
         }  
         url = parts[0] + encodedParams;  
     }  
     return url;  
 } 
  
 function openPopupWindow(url, name, width, height,myPopupWindow)  
 {  
     //Remove special characters from name  
     name = name.replace(/\/|\-|\./gi, "");  
   
     //Remove whitespaces from name  
     var whitespace = new RegExp("\\s","g");  
     name = name.replace(whitespace,"");  
   
     //If it is already open  
     if (!myPopupWindow.closed && myPopupWindow.location)  
     {  
         myPopupWindow.location.href = encodeUrl(url);  
     }  
     else  
     {  
         myPopupWindow= window.open(encodeUrl(url),name, "location=no, scrollbars=yes, resizable=yes, toolbar=no, menubar=no, width=" + width
             + ", height=" + height );  
         if (!myPopupWindow.opener) myPopupWindow.opener = self;  
     }  
   
        //If my main window has focus - set it to the popup  
         if (window.focus) {myPopupWindow.focus();}  
 }

