// popup window reference, so we can ensure we only open one pop-up
var objWin = null;

// open a popup window, and format us per params
function popupWindow(pURL, pName, pWidth, pHeight, pScroll, pResize, pToolbar, pMenu){
 var strParams='';
 intLeft = (screen.width) ? (screen.width-pWidth)/2 : 0;
 intTop = (screen.height) ? (screen.height-pHeight)/2 : 0;
 strParams+='height=' + pHeight + ', ';
 strParams+='width=' + pWidth + ', ';
 strParams+='top=' + intTop + ', ';
 strParams+='left=' + intLeft;
 
 (pScroll) ? strParams+=', scrollbars=yes' : '';
 (pResize) ? strParams+=', resizable=yes' : '';
 (pToolbar) ? strParams+=', toolbar=yes' : '';
 (pMenu) ? strParams+=', menubar=yes' : '';

 if (pURL!='')
  objWin = window.open(pURL, pName, strParams);
 
 if(objWin.window.focus)
  objWin.window.focus();
}

function trim(pText){
  return pText.replace(/^\s{1,}/, "").replace(/\s{1,}$/, "");
}

function gotoURL(url){
  location.href = url;
}

function confirmDelete(){
 return confirm('Delete the current record.\n\nAre you sure?');
}

function isEmail(objSource, objArgs){
 text = document.all("txtEmail").value;
 objArgs.IsValid = ((text.length > 0) && isValid(isEmailAddress, text));
}
function disabledDelete(){
 button = document.getElementById('btnDelete');
 if(button != null )
  button.disabled = true;
}

var FLUID = 'Fluid Design';
var FIXED = 'Fixed Width Design';

function fnToggleDesign(){
  if(getActiveStyleSheet()==FLUID)
    setActiveStyleSheet(FIXED);
  else
    setActiveStyleSheet(FLUID);  
}

function setActiveStyleSheet(title) {  var i, a, main, oChg;  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {      a.disabled = true;      if(a.getAttribute("title") == title){        a.disabled = false;        oChg = document.getElementById("sizerLink");
        if( oChg != null){
          oChg.blur();
          if(title==FLUID)
            oChg.className = 'fixed';          else            oChg.className = 'flexible';        }      }    }  }}function getActiveStyleSheet() {  var i, a;  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");  }  return null;}function getPreferredStyleSheet() {  var i, a;  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {    if(a.getAttribute("rel").indexOf("style") != -1       && a.getAttribute("rel").indexOf("alt") == -1       && a.getAttribute("title")       ) return a.getAttribute("title");  }  return null;}function createCookie(name,value,days) {  if (days) {    var date = new Date();    date.setTime(date.getTime()+(days*24*60*60*1000));    var expires = "; expires="+date.toGMTString();  }  else expires = "";  document.cookie = name+"="+value+expires+"; path=/";}function readCookie(name) {  var nameEQ = name + "=";  var ca = document.cookie.split(';');  for(var i=0;i < ca.length;i++) {    var c = ca[i];    while (c.charAt(0)==' ') c = c.substring(1,c.length);    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);  }  return null;}window.onload = function(e) {  var cookie = readCookie("style");  var title = cookie ? cookie : getPreferredStyleSheet();  setActiveStyleSheet(title);}window.onunload = function(e) {  var title = getActiveStyleSheet();  createCookie("style", title, 365);}var cookie = readCookie("style");var title = cookie ? cookie : getPreferredStyleSheet();setActiveStyleSheet(title);











function fnToggleDesignOLD(){
  var fixed = 'fixed_0_1';
  var flexible = 'flexible_0_1';
  oLnk = document.getElementById("cssLayout");
  oChg = document.getElementById("sizerLink");
  if( oLnk != null && oChg != null){
    oChg.blur();
    if( oLnk.href.indexOf(fixed) > 0 ){
      oChg.className = 'fixed';
    }
    else
    {
      oChg.className = 'flexible';
    }
  }
}
