var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) );
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_gecko = (agt.indexOf('gecko') != -1);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
var is_aol   = (agt.indexOf("aol") != -1);
var is_aol3  = (is_aol && is_ie3);
var is_aol4  = (is_aol && is_ie4);
var is_opera = (agt.indexOf("opera") != -1);
var is_webtv = (agt.indexOf("webtv") != -1);
var dateNow = new Date();
var dateOffset = dateNow.getTimezoneOffset() / 60;
document.cookie = 'gezageza_t=' + dateOffset;

function getMessage(cmd) {
  if (cmd == 'Bookmark') return '\nItem(s) will be placed under the catagory {$view["desc_v"]}.\nAccess Bookmarks on side bar.';
  else if (cmd == 'Delete') return '\nItem(s) will be deleted from {$view["desc_v"]}.\nPlease be careful.';
  else if (cmd == 'Modify') return '\nYou will be able to modify {$view["desc_v"]} item(s) depending on your account type.';
  else if (cmd == 'Print') return '\nThis will append item(s) to a new Print window.\nEnter CTRL P to start Printing.';
  else if (cmd == 'Quick-send') return '\nYou will be promped for email addresses.\nItem(s) will be emailed immediately.';
  else if (cmd == 'Map') return '\nThis will open a map of the address with mapquest.';
  else if (cmd == 'Basket') return '\nA temporary basket will hold these item(s).';
  else if (cmd == 'Remove-ref') return '\nIf a reference to other item(s) exists, the referenced item(s) will be deleted.';
  else if (cmd == 'Make-live') return '\nIf the item(s) are not live, the item(s) will be made live.';
  else if (cmd == 'Email') return '\nEmail the last person that created this item.';
  return '';
}

function showMenu() {
  arg=showMenu.arguments
  if(is_ie4up) DivId=eval(arg[0])
  else if(is_nav6up || is_opera) DivId=eval(arg[2])
  if (arg[3]) DivId.style.visibility = 'visible';
  else DivId.style.visibility = 'hidden';
}

function checkOk() {
  var docu = parent.location.pathname.substr(parent.location.pathname.lastIndexOf('/') + 1)
  if ((docu != 'demo.htm' && docu != 'live.htm' && docu != '') ||
    (parent.location.host != 'www.gezageza.com'  && parent.location.host != 'localhost')) 
      parent.location.href='http://www.gezageza.com';
}

function flip(img_name,img_src) {
  document[img_name].src=img_src;
}

function fixMeNum(theInput) {
  if (event.keyCode < 32) return true;
  argv = fixMeNum.arguments;
  if (argv[3]) val = argv[3];
  else val=theInput.value;
  format = argv[1];
  if (!argv[2] || argv[2] == 'num' ) theValueNumbers = val.replace(/[^0-9]/g,"");
  else if (argv[2] == 'login' ) { 
    theValueNumbers = val.replace(/[^0-9A-Za-z]/g,"");
    digits = "1234567890";
    if (digits.indexOf(val.charAt(0)) != -1 ) {
      theInput.value="";
      return false;
    }
  }
  else if (argv[2] == 'string' ) theValueNumbers = val.replace(/[^0-9A-Za-z]~`!@#$%^&*()_-+=|\<>,.?\"\'=/g,"");
  theValueStrings = val.toUpperCase().replace(/[^A-Z]/g,"");
  if (val.substr(val.length - 1, 1) == format.substr(val.length -1, 1)) return false;
  if((theValueNumbers+theValueStrings)=="") return;
  tmp="";
  for (j=0, k=0, l=0, i=0;i == j + k + l && i<format.length;i++) {
    if(format.substr(i,1)=="#") tmp+=theValueNumbers.substr(j++,1);
    else if ( format.substr(i,1)=="@" ) tmp+=theValueStrings.substr(k++,1);
    else {
      l++;
      tmp+=format.substr(i,1);
    }
    if(j>theValueNumbers.length || k>theValueStrings.length || j+k == theValueNumbers.length + theValueStrings.length) break;
  }
  if (tmp != theInput.value) theInput.value=tmp;
  return true;
}

function validateMe(theForm, theValues) {
  tot = '';
  for (i = 0; i < theValues.length; i++) {
    if (theForm.name != theValues[i][6]) continue;
    theKey = 'arg[' +theValues[i][0]+ ']';
    theKey = theForm.elements[theKey];
      
    if (theValues[i][5] == 'R' && theValues[i][4] == 'N') {
      for (j = 0 ; j < theKey.length ; j++) if (theKey[j].checked) break;
      if (j == theKey.length) {
        tot = 'The radio is not selected.';
        theKey = theKey[0];
      }
    }
    else if (theKey.value == '') 
	if (theValues[i][4] == 'N') tot = 'This value must not be left empty.';
        else continue;
    else if (theValues[i][5] == 'T' && theValues[i][2] > 0 && theKey.value.length < theValues[i][2] ) tot = 'This value must not be less than ' +theValues[i][2]+ ' characters long.';
    else if (theValues[i][5] == 'T' && theValues[i][3] > 0 && theKey.value.length > theValues[i][3] ) tot = 'This value must not be larger than ' +theValues[i][3]+ ' characters long.';
    else if (theValues[i][7] == 'zip' && theKey.value.length % 5 ) tot = 'This zip code must be either 5 or 10 characters long.';
    if (tot != '') {
      theKey.select();
      tot = 'FORM INCOMPLETE!\n==== ========\n\nFIELD NUMBER \t: ' +theValues[i][0]+ '\n\nFIELD HEADING \t: ' +theValues[i][1]+ '\n\nERROR FOUND \t: ' +tot;
      if (theKey.title.length) tot += '\n\nREQUIREMENTS \t: ' +theKey.title.replace(/\. /g, '.\n\t\t  ');
      alert(tot);
      return false;
    }
  }
  return true;
}

function fixView(theObj, type, max) {
  if (type == "int" ) val = theObj.value.replace(/[^0-9]/g,"");
  else val = theObj.value.replace(/[^0-9.-]/g,"");
  if ( val > max ) val = max;
  if (val != theObj.value) theObj.value=val;
  return true;
}

var qs = location.search.substring(1);
var nv = qs.split('&');
var url = new Object();
for(i = 0; i < nv.length; i++) {
  eq = nv[i].indexOf('=');
  url[nv[i].substring(0,eq).toLowerCase()] = unescape(nv[i].substring(eq + 1));
}

var allImag = new Array('../red3d/lightgray.gif', '../red3d/head.gif', '../red3d/logo.gif', '../red3d/but_bar_l.gif', '../red3d/main_off.gif', '../red3d/main2_off.gif', '../red3d/main3_off.gif', '../red3d/but_bar_r.gif', '../red3d/final.gif', '../red3d/qbr.gif', '../red3d/qbl.gif', '../red3d/qtl.gif', '../red3d/qtr.gif', '../red3d/bg.gif', '../red3d/newtop.gif', '../red3d/b1.gif', '../red3d/b2.gif', '../red3d/b3.gif', '../red3d/pix.gif');

