var openpopup = new Array();

function getRealPos(i,which) {
 var iPos = 0
 while (i!=null) {
  iPos += i["offset" + which]
  i = i.offsetParent
 }
 return iPos
}
function showSelect(el, popname, leftOffset, topOffset, onlyone, group) {
 leftOffset = parseInt(leftOffset);
 topOffset = parseInt(topOffset);
 if (popname == '') {
  alert('No popup name supplied');
  return;
 }
 var left = getRealPos(el,"Left");
 var top  = getRealPos(el,"Top")

 if (onlyone && openpopup[group] != null) {
  hideSelect(openpopup[group]);
  openpopup[group] = null;
 }
 var popup = document.getElementById(popname);
 if (popup) {
  popup.style.left  = left + leftOffset + "px";
  popup.style.top   = top + topOffset + "px";
  popup.style.visibility = "visible";
  popup.style.display = "block";
  if (onlyone) {
   openpopup[group] = popname;
  }
 }
 else {
  alert('Could not locate id with name: ' + popname);
  return;
 }
}
function hideSelect(popname) {
 if (popname == '') {
  alert('No popup name supplied');
  return;
 }
 var popup = document.getElementById(popname);
 if (popup) {
  popup.style.visibility = "hidden";
  popup.style.display = "none";
 }
 else {
  alert('Could not locate id with name: ' + popname);
  return;
 }
}  

var winRef;
function globalMakeWindow(url,width,height) {
 if (! width) {width=600;}
 if (! height) {height=400;}
 if (winRef && (! winRef.closed)) { winRef.close() }
 remote = window.open("","popupwindow","scrollbars=yes,resizable=yes,width="+width+",height="+height);
 remote.location.href = url;
 if (remote.opener == null) window.opener = window;
 winRef = remote;
 remote.focus();
}
function globalMakePlainWindow(url,width,height) {
 if (! width) {width=600;}
 if (! height) {height=400;}
 if (winRef && (! winRef.closed)) { winRef.close() }
 remote = window.open("","plainpopupwindow","scrollbars=no,resizable=no,width="+width+",height="+height);
 remote.location.href = url;
 if (remote.opener == null) window.opener = window;
 winRef = remote;
 remote.focus();
}
function globalMakeInstantMessengerWindow(url,width,height) {
 if (! width) {width=600;}
 if (! height) {height=400;}
 if (winRef && (! winRef.closed)) { winRef.close() }
 remote = window.open("","InstantMessengerWindow","scrollbars=yes,resizable=yes,width="+width+",height="+height);
 remote.location.href = url;
 if (remote.opener == null) window.opener = window;
 winRef = remote;
 remote.focus();
}
function globalMakeJavaGamesWindow(url,width,height) {
 if (! width) {width=600;}
 if (! height) {height=400;}
 if (winRef && (! winRef.closed)) { winRef.close() }
 remote = window.open("","JavaGamesWindow","scrollbars=no,resizable=no,width="+width+",height="+height);
 remote.location.href = url;
 if (remote.opener == null) window.opener = window;
 winRef = remote;
 remote.focus();
}
function globalMakeFullWindow(url) {
 if (winRef && (! winRef.closed)) { winRef.close() }
 remote = window.open("","fullwindow");
 remote.location.href = url;
 if (remote.opener == null) window.opener = window;
 winRef = remote;
 remote.focus();
} 

function globalConfirm(txt,windowlocation,url) {
 if(confirm(txt)){
  windowlocation.href = url;   
 }
}
function globalAlert(txt) {
 alert(txt);  
}
function globalDrawCalendar(curl, width, height, UpdateMonthField, UpdateDayField, UpdateYearField, formname ){  
 var month = eval ('document.' + formname + '.' + UpdateMonthField + '.value');
 var day   = eval ('document.' + formname + '.' + UpdateDayField + '.value');
 var year  = eval ('document.' + formname + '.' + UpdateYearField + '.value');
 curl = curl + "?action=drawcalendar&month=" + month + "&day=" + day + "&year=" + year + "&UpdateDayField=" + UpdateDayField + "&UpdateMonthField=" + UpdateMonthField + "&UpdateYearField=" + UpdateYearField + "&formname=" + formname;
 if (! width) {width=250;}
 if (! height) {height=300;}
 if (winRef && (! winRef.closed)) { winRef.close() }
 remote = window.open("","popupwindow","scrollbars=no,resizable=yes,width="+width+",height="+height);
 remote.location.href = curl;
 if (remote.opener == null) window.opener = window;
 winRef = remote;
 remote.focus();
}

/*
Auto center window script- Eric King (http://redrival.com/eak/index.shtml)
Permission granted to Dynamic Drive to feature script in archive
For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable, status'
win = window.open(mypage,myname,settings)
}



/*
Select and Copy form element script- By Dynamicdrive.com
For full source, Terms of service, and 100s DTHML scripts
Visit http://www.dynamicdrive.com
*/

var copytoclip=1

function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
if (document.all&&copytoclip==1){
therange=tempval.createTextRange()
therange.execCommand("Copy")
window.status="Contents highlighted and copied to clipboard!"
setTimeout("window.status=''",1800)
}
}

// Ajax form submission
function submitForm()
{
  var http = null;
  if(window.XMLHttpRequest)
    http = new XMLHttpRequest();
  else if (window.ActiveXObject)
    http = new ActiveXObject("Microsoft.XMLHTTP");

  http.onreadystatechange = function()
  {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();
        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
        }
    }
  }

  http.open('POST', '/signup.php', true);
  http.setRequestHeader('Content-Type',
    'application/x-www-form-urlencoded');
  http.send("email=" + document.getElementById('email').value);
}

// Clear selected form fields
function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}


