﻿//		shiai.js
//		boston kendo kyokai javascript library
//		david harrison
//

function ajaxRequest(){
 var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
 if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
  for (var i=0; i<activexmodes.length; i++){
   try{
    return new ActiveXObject(activexmodes[i])
   }
   catch(e){    //suppress error
   }
  }
 }
 else if (window.XMLHttpRequest) // if Mozilla, Safari etc
  return new XMLHttpRequest()
 else
  return false
}	

function shiailogin(){
showBox("PlsWait")
var xhttp_request=new ajaxRequest()
xhttp_request.onreadystatechange=function(){
 if (xhttp_request.readyState==4){
  if (xhttp_request.status==200 || window.location.href.indexOf("http")==-1){
   document.getElementById("Login").innerHTML=xhttp_request.responseText
   hideBox("PlsWait")
  }
  else{
   alert("An error has occured making the request")
  }
 }
}

var uservalue=encodeURIComponent(document.getElementById("fUserID").value)
var passvalue=encodeURIComponent(document.getElementById("fPassword").value)
var ctrlvalue=encodeURIComponent(document.getElementById("do").value)
var parameters="do="+ctrlvalue+"&fUserID="+uservalue+"&fPassword="+passvalue

xhttp_request.open("POST", "shiailogin.php", true)
xhttp_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
xhttp_request.setRequestHeader("Content-length", parameters.length)
xhttp_request.setRequestHeader("Connection", "close")
xhttp_request.send(parameters)
}

function shiailogout(){
showBox("PlsWait")
var xhttp_request=new ajaxRequest()
xhttp_request.onreadystatechange=function(){
 if (xhttp_request.readyState==4){
  if (xhttp_request.status==200 || window.location.href.indexOf("http")==-1){
   document.getElementById("Login").innerHTML=xhttp_request.responseText
   hideBox("PlsWait")
  }
  else{
   alert("An error has occured making the request")
  }
 }
}
var ctrlvalue=encodeURIComponent(document.getElementById("do").value)
var parameters="do="+ctrlvalue

xhttp_request.open("POST", "shiailogin.php", true)
xhttp_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded")      
xhttp_request.setRequestHeader("Content-length", parameters.length)
xhttp_request.setRequestHeader("Connection", "close")
xhttp_request.send(parameters)
}

function resetpass(){
var xhttp_request=new ajaxRequest()
xhttp_request.onreadystatechange=function(){
 if (xhttp_request.readyState==4){
  if (xhttp_request.status==200 || window.location.href.indexOf("http")==-1){
   document.getElementById("BoxContent").innerHTML=xhttp_request.responseText
  }
  else{
   alert("An error has occured making the request")
  }
 }
}

var fnm=encodeURIComponent(document.getElementById("FirstName").value)
var lnm=encodeURIComponent(document.getElementById("LastName").value)
var phn=encodeURIComponent(document.getElementById("Phone").value)
var eml=encodeURIComponent(document.getElementById("Email").value)
var rnk=encodeURIComponent(document.getElementById("Rank").value)
var doo=encodeURIComponent(document.getElementById("do").value)
var parameters="do="+doo+"&FirstName="+fnm+"&LastName="+lnm+"&Phone="+phn+"&Email="+eml+"&Rank="+rnk
alert(parameters)

xhttp_request.open("POST", "forgotten.php", true)
xhttp_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded")      
xhttp_request.setRequestHeader("Content-length", parameters.length)
xhttp_request.setRequestHeader("Connection", "close")
xhttp_request.send(parameters)

}

function changepass(){
var xhttp_request=new ajaxRequest()
xhttp_request.onreadystatechange=function(){
 if (xhttp_request.readyState==4){
  if (xhttp_request.status==200 || window.location.href.indexOf("http")==-1){
   document.getElementById("ChangePass").innerHTML=xhttp_request.responseText
  }
  else{
   alert("An error has occured making the request")
  }
 }
}
var fnm=encodeURIComponent(document.getElementById("FirstName").value)
var lnm=encodeURIComponent(document.getElementById("LastName").value)
var phn=encodeURIComponent(document.getElementById("Phone").value)
var eml=encodeURIComponent(document.getElementById("Email").value)
var rnk=encodeURIComponent(document.getElementById("Rank").value)
var doo=encodeURIComponent(document.getElementById("do").value)
var parameters="do="+doo+"&FirstName="+fnm+"&LastName="+lnm+"&Phone="+phn+"&Email="+eml+"&Rank="+rnk

xhttp_request.open("POST", "changepass.php", true)
xhttp_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded")      
xhttp_request.setRequestHeader("Content-length", parameters.length)
xhttp_request.setRequestHeader("Connection", "close")
xhttp_request.send(parameters)

}

function change(){
var xhttp_request=new ajaxRequest()
xhttp_request.onreadystatechange=function(){
 if (xhttp_request.readyState==4){
  if (xhttp_request.status==200 || window.location.href.indexOf("http")==-1){
   document.getElementById("ChangePass").innerHTML=xhttp_request.responseText
  }
  else{
   alert("An error has occured making the request")
  }
 }
}
var fnm=encodeURIComponent(document.getElementById("FirstName").value)
var lnm=encodeURIComponent(document.getElementById("LastName").value)
var phn=encodeURIComponent(document.getElementById("Phone").value)
var eml=encodeURIComponent(document.getElementById("Email").value)
var rnk=encodeURIComponent(document.getElementById("Rank").value)
var doo=encodeURIComponent(document.getElementById("do").value)
var parameters="do="+doo+"&FirstName="+fnm+"&LastName="+lnm+"&Phone="+phn+"&Email="+eml+"&Rank="+rnk

xhttp_request.open("POST", "change.php", true)
xhttp_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded")      
xhttp_request.setRequestHeader("Content-length", parameters.length)
xhttp_request.setRequestHeader("Connection", "close")
xhttp_request.send(parameters)

}

function FP_swapImg() {//v1.0
	 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
	 n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
	 elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_preloadImgs() {//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}

function zg_insert_badge() {
var zg_bg_color = 'ffffff';
var zgi_url = 'http://www.flickr.com/apps/badge/badge_iframe.gne?zg_bg_color='+zg_bg_color+'&zg_person_id=27961109%40N05';
document.write('<iframe style="background-color:#'+zg_bg_color+'; border-color:#'+zg_bg_color+'; border:none;" width="113" height="151" frameborder="0" scrolling="no" src="'+zgi_url+'" title="Flickr Badge"><\/iframe>');
if (document.getElementById) document.write('<div id="zg_whatlink"><a href="http://www.flickr.com/badge.gne"	style="color:#3993ff;" onclick="zg_toggleWhat(); return false;">What is this?<\/a><\/div>');
}
function zg_toggleWhat() {
document.getElementById('zg_whatdiv').style.display = (document.getElementById('zg_whatdiv').style.display != 'none') ? 'none' : 'block';
document.getElementById('zg_whatlink').style.display = (document.getElementById('zg_whatdiv').style.display != 'none') ? 'none' : 'block';
return false;
}

//============================================================
//Script:     Print Current Window From A Link
//Function:   Opens printer dialogue to print current page
//Browsers:   Version 4 and later (others degrade gracefully)
//Author:     etLux
//============================================================

// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this  header

function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}

function dispModalBox (elementID, title, width, height, top, left, border, bgcolor, color)
{
//	document.getElementById('Veil').style.width=screen.availWidth-45;
//	document.getElementById('Veil').style.height=screen.availHeight;
	document.getElementById('Veil').style.visibility="visible";
	
	dispBox (elementID, title, width, height, top, left, border, bgcolor, color);
}

function hideModalBox (elementID)
{
	document.getElementById('Veil').style.visibility="hidden";
	document.getElementById('Box').style.visibility="hidden";
}

function dispBox (elementID, title, width, height, top, left, border, bgcolor, color)
{
	var boxContent = document.getElementById(elementID).innerHTML;
	var boxTop = title;

	document.getElementById('BoxContent').innerHTML=boxContent;
	document.getElementById('BoxTitle').innerHTML=boxTop;
	
	document.getElementById('Box').style.width=width;
	document.getElementById('Box').style.height=height;
	document.getElementById('Box').style.top=top;
	document.getElementById('Box').style.left=left;
	document.getElementById('Box').style.border=border;
	document.getElementById('Box').style.backgroundColor=bgcolor;
	document.getElementById('Box').style.color=color;
	document.getElementById('Box').style.visibility="visible";
}

function showBox (elementID)
{
	document.getElementById('Veil').style.visibility="visible";
	document.getElementById(elementID).style.visibility="visible";
}

function hideBox (elementID)
{
	document.getElementById(elementID).style.visibility="hidden";
	document.getElementById('Veil').style.visibility="hidden";
}
