<!--

//////////////////
// GET APP URL //
/////////////////
if(!window.appUrl) { window.appUrl = ''; }

/////////////////////
// PRELOAD IMAGES //
////////////////////
function imgPreloader() 
{
 var image;
 images = new Array();
 images[0]=+window.appUrl+'images/tab-bg-on.jpg';
 images[1]=window.appUrl+'images/tab-left-on.jpg';
 images[2]=window.appUrl+'images/tab-right-on.jpg';
 for(i=0;i<=(images.length-1);i++)
 {
  image = images[i];
  images[i] = new Image();
  images[i].src = image;
 }
}

////////////////////////////
// LINK BAR MOUSE EVENTS //
///////////////////////////
function linkbar(i,event)
{
 if(typeof(i)=='number')
 {
  var li = document.getElementById('lb'+i);
  if(event=='mouseover')
  {
   li.style.backgroundImage = 'url('+window.appUrl+'images/tab-bg-on.jpg)';
   li.getElementsByTagName('a')[0].style.color = "#ffffff";
   getClassElements('tableft',li)[0].style.backgroundImage = 'url('+window.appUrl+'images/tab-left-on.jpg)';
   getClassElements('tabright',li)[0].style.backgroundImage = 'url('+window.appUrl+'images/tab-right-on.jpg)';
  }
  else if(event=='mouseout')
  {
   li.style.backgroundImage = 'url('+window.appUrl+'images/tab-bg.jpg)';
   li.getElementsByTagName('a')[0].style.color = "#000000";
   getClassElements('tableft',li)[0].style.backgroundImage = 'url('+window.appUrl+'images/tab-left.jpg)';
   getClassElements('tabright',li)[0].style.backgroundImage = 'url('+window.appUrl+'images/tab-right.jpg)';
  }
 }
}

/////////////////////
// BUTTON ACTIONS //
////////////////////
function buttonAction(event,node,action,form,formURL)
{
 var x;
 var selectCount = 0;
 var checkBox = getClassElements('checkAll',document.getElementById(node));
 for(x in checkBox) { if(checkBox[x].checked==true) { selectCount++; } }
 if(selectCount>0)
 {
  if(event=='delete')
  {
   if(deleteconfirm())
   {
    document.getElementById(action).value = 'delete';
    document.getElementById(form).submit();
   }
  }
  if(event=='edit')
  {
   if(formURL) { document.getElementById(form).action = formURL; }
   document.getElementById(action).value = 'edit';
   document.getElementById(form).submit();
  }
 }
 else { alert("You must select at least one item to "+event+"!"); }
}

////////////////////////
// OPEN VIDEO WINDOW //
///////////////////////
function videoWindow(vid)
{
 window.open(window.appUrl+'func/video-demo.php?video='+vid,'video-demo','height=344,width=425,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0');
 return false;
}

/////////////////////////////////
// SINGLE FORM ACTION BUTTONS //
////////////////////////////////
function singleAction(id,event,node,action,form,formURL)
{
 if(!formURL) { formURL = ''; }
 var checkBox = getClassElements('checkAll',document.getElementById(node));
 for(x in checkBox) { checkBox[x].checked = false; }
 document.getElementById(id).checked = true;
 buttonAction(event,node,action,form,formURL);
 return false;
}

/////////////////////////////
// CHECK ALL & UNCHECK ALL //
/////////////////////////////
function checkUncheck(id,node)
{
 var x;
 var checkBox = getClassElements('checkAll',document.getElementById(node));
 if(document.getElementById(id).checked==true)
 {
  for(x in checkBox) { checkBox[x].checked = true; }
 }
 else
 {
  for(x in checkBox) { checkBox[x].checked = false; }
 }
}

////////////////////////////
// GET ELEMENTS BY CLASS //
///////////////////////////
function getClassElements(classname,node)
{
 if(!node) node = document.getElementsByTagName("body")[0];
 var a = [];
 var re = new RegExp('\\b' + classname + '\\b');
 var els = node.getElementsByTagName("*");
 for(var i=0,j=els.length; i<j; i++)
 { if(re.test(els[i].className))a.push(els[i]); }
 return a;
}

/////////////////////
// DELETE CONFIRM //
/////////////////////
function deleteconfirm()
{
 if(confirm("Confirm delete of item(s)?")) { return true; }
 else { return false; }
}

//////////////////////
// WINDOW REDIRECT //
/////////////////////
function redirect(loc)
{
 window.location = loc;
}

/////////////////
// PRINT PAGE //
////////////////
function printPage(page)
{
 if(!page && window.iframe2print) { page = ''; content = getIFrameDocument(window.iframe2print).body.innerHTML; }
 var URL = window.appUrl+'func/print.php?page='+page;
 day = new Date();
 id = day.getTime();
 var printPage = eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=0,width=800,height=500,left = 240,top = 150');");
 if(content)
 {
  printPage.document.write(content);
  printPage.stop();
 }
 printPage.print();
}

////////////////////////
// HIDE SHOW ELEMENT //
///////////////////////
function hideShow(elm,forced)
{
 if(!forced)
 {
  if(document.getElementById(elm).style.display=='block') { document.getElementById(elm).style.display = 'none'; }
  else { document.getElementById(elm).style.display = 'block'; }
  return false;
 }
 else
 {
  if(forced=='show') { document.getElementById(elm).style.display = 'block'; }
  else { document.getElementById(elm).style.display = 'none'; }
 }
}

//////////////////////////
// GET IFRAME FUNCTION //
/////////////////////////
function getIFrameDocument(aID)
{
 if (document.getElementById(aID).contentDocument)
 { return document.getElementById(aID).contentDocument; }
 else { return document.frames[aID].document; }
}

///////////////////////
// DHTML POPUP OPEN //
//////////////////////
function openPopup(t,v)
{
 if(t) { document.getElementById('popuptop').innerHTML = t+'<div id="popupclose"><a href="#" onclick="return closePopup();return false;"><img src="'+window.appUrl+'images/popup-close.png" width="27" height="19" border="0" alt="close"/></a></div>'; }
 if(v) { document.getElementById('popupinner').innerHTML = v+'<div id="popupstatus"></div>'; }
 document.getElementById('popupcover').style.display = 'block';
 return false;
}

////////////////////////
// DHTML POPUP CLOSE //
///////////////////////
function closePopup()
{
 document.getElementById('popupcover').style.display = 'none';
 return false;
}

///////////////////////////////
// DHTML POPUP STATUS CLOSE //
//////////////////////////////
function popupStatusClose()
{
 document.getElementById('popupstatus').style.display = 'none';
 return false;
}

////////////////////
// WINDOW ONLOAD //
///////////////////
function init()
{
 imgPreloader();
}
window.onload = init;

-->
