//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


// Additional Codes

function expand(elementTag){
	styleObj=document.getElementById(elementTag).style;
	if(styleObj.display=='none'){styleObj.display='';}
}

function collapse(elementTag){
	styleObj=document.getElementById(elementTag).style;
	if(styleObj.display!='none'){styleObj.display='none';}
}

function toggleCollapse(elementTag){
	styleObj=document.getElementById(elementTag).style;
	if(styleObj.display=='none'){styleObj.display='';}
	else {styleObj.display='none';}
}

function isHidden(elementTag){
	styleObj=document.getElementById(elementTag).style;
	return(styleObj.display=='none');
}

	c=document.getElementById('popup_cover').style;
	c.top = '100%px';
	c.height = '200%px';

function showPopup_wh(id, width, heightx) {
	offset = window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;
	docwidth = document.body.offsetWidth||document.documentElement.offsetWidth;
	height = document.documentElement.clientHeight||document.body.clientHeight;
	w=document.getElementById(id).style;
	w.top = 100 + offset + 'px';
	w.width = width + 'px';
	/*w.height = heightx + 'px'; */
	 w.height = '5px'; 
	w.left = ((docwidth - width) / 2) + 'px';
	expand('popup_cover');
	expand(id);
	
	timer = setTimeout((function(){showpopscroll(id,5,heightx);}), 1);
	
}


function showpopscroll(id,curheight,heightx){
	w=document.getElementById(id).style;
	if ((curheight + 20) > heightx) {
		curheight = heightx;
		w.height = curheight + 'px';
	} else {
		curheight = curheight + 20 + (curheight/10);
		w.height = curheight + 'px';
		timer = setTimeout((function(){showpopscroll(id,curheight,heightx);}), 1);
	}

}

function hidePopup(id) {
	collapse('popup_cover');
	collapse(id);
}

/* Simple AJAX Code-Kit (SACK) v1.6.1 */
/* c2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence,
   see documentation or authors website for more details */

function sack(file) {
	this.xmlhttp = null;

	this.resetData = function() {
		this.method = "POST";
		this.queryStringSeparator = "?";
		this.argumentSeparator = "&";
		this.URLString = "";
		this.encodeURIString = true;
		this.execute = false;
		this.element = null;
		this.elementObj = null;
		this.requestFile = file;
		this.vars = new Object();
		this.responseStatus = new Array(2);
	};

	this.resetFunctions = function() {
		this.onLoading = function() { };
		this.onLoaded = function() { };
		this.onInteractive = function() { };
		this.onCompletion = function() { };
		this.onError = function() { };
		this.onFail = function() { };
	};

	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}

		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
	};

	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};

	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	}

	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	}

	this.createURLString = function(urlstring) {
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}

		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}

		// prevents caching of URLString
		this.setVar("rndval", new Date().getTime());

		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}

			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	}

	this.runResponse = function() {
		eval(this.response);
	}

	this.runAJAX = function(urlstring) {
		if (this.failed) {
			this.onFail();
		} else {
			this.createURLString(urlstring);
			if (this.element) {
				this.elementObj = document.getElementById(this.element);
			}
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
					try {
						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
					} catch (e) { }
				}

				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;
						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;

							if (self.execute) {
								self.runResponse();
							}

							if (self.elementObj) {
								elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input"
								|| elemNodeName == "select"
								|| elemNodeName == "option"
								|| elemNodeName == "textarea") {
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							if (self.responseStatus[0] == "200") {
								self.onCompletion();
							} else {
								self.onError();
							}

							self.URLString = "";
							break;
					}
				};

				this.xmlhttp.send(this.URLString);
			}
		}
	};

	this.reset();
	this.createAJAX();
}

var ajax=new sack();


/* Others */

function whenLoading(){
	var e = document.getElementById('replaceme'); 
	e.innerHTML = "<p>Registering Subscription...</p>";
}

function whenCompleted(){
	var e = document.getElementById('replaceme'); 
	if (ajax.responseStatus){
		var string = ajax.response;
	} else {
		var string = "Error Registering Subscription";
	}
	if ( string == 'OK') {SendEmailOK(); } else {	e.innerHTML = string;	}
}

function SendEmail(formname){
	var form = document.getElementById(formname);
	var mylname = form.lname.value;
	ajax.encVar("lname", mylname); 	
	var myfname = form.fname.value;
	ajax.encVar("fname", myfname); 	
	var myemail = form.email.value;
	ajax.encVar("email", myemail); 	
	var mygender = form.gender.value;
	ajax.encVar("gender", mygender); 		
	var mycompany = form.company.value;
	ajax.encVar("company", mycompany); 	
	var myposition = form.position.value;
	ajax.encVar("position", myposition); 	
  ajax.encVar("submit", "Y");   
	ajax.requestFile = 'subscription.php';
	ajax.method = 'POST';
	ajax.element = 'replaceme';
	ajax.onLoading = whenLoading;
	ajax.onCompletion = whenCompleted;
	ajax.runAJAX();
}

function SendEmailOK(){
hidePopup('Email');
showPopup_wh('subscriptionOK',480,350);
}


function SendContact(formname){
	var form = document.getElementById(formname);
	var myname = form.name.value;
	ajax.encVar("name", myname); 	
	var myemail = form.emailcontact.value;
	ajax.encVar("email", myemail); 	
	var mycomment = form.comment.value;
	ajax.encVar("comment", mycomment); 	

alert( myname + '  ' + myemail);


  ajax.encVar("submit", "Y");   
	ajax.requestFile = 'contact.php';
	ajax.method = 'POST';
	ajax.element = 'forminput';
	ajax.onLoading = whenLoadingContact;
	ajax.onCompletion = whenCompletedContact;
	ajax.runAJAX();
}

function whenLoadingContact(){
	var e = document.getElementById('forminput'); 
	e.innerHTML = "<p>Contacting Tony...</p>";
}

function whenCompletedContact(){
	var e = document.getElementById('forminput'); 
	if (ajax.responseStatus){
		var string = ajax.response;
	} else {
		var string = "Error Contacting Tony";
	}
	e.innerHTML = string;	
}

function SendEmailPay(formname){
	var form = document.getElementById(formname);
	var mylname = form.plname.value;
	ajax.encVar("lname", mylname); 	
	var myfname = form.pfname.value;
	ajax.encVar("fname", myfname); 	
	var myemail = form.pemail.value;
	ajax.encVar("email", myemail); 	
	var mygender = form.pgender.value;
	ajax.encVar("gender", mygender); 		
	var mycompany = form.pcompany.value;
	ajax.encVar("company", mycompany); 	
	var mytel = form.ptel.value;
	ajax.encVar("tel", mytel); 	
	var myposition = form.pposition.value;
	ajax.encVar("position", myposition); 	
	var mytype = form.ttype.value;
	ajax.encVar("ptype", mytype); 		
  ajax.encVar("submit", "Y");   
	ajax.requestFile = 'pay.php';
	ajax.method = 'POST';
	ajax.element = 'replacemep';
	ajax.onLoading = whenLoadingPay;
	ajax.onCompletion = whenCompletedPay;
	ajax.runAJAX();
}

function whenLoadingPay(){
	var e = document.getElementById('replacemep'); 
	e.innerHTML = "<p>Adding Payment Information...</p>";
}

function whenCompletedPay(){
	var e = document.getElementById('replacemep'); 
	if (ajax.responseStatus){
		var string = ajax.response;
		if (string == 'OK') {
			hidePopup('Pay');
			showPopup_wh('Paynow',480,350);
			var string = "<a href=\"javascript:hidePopup('Pay');showPopup_wh('Paynow',480,350);\">REDIR to PAYMENT</a> ";
			}	
	} else {
		var string = "Error Adding Payment Information";
	}
	e.innerHTML = string;	
}

function SendEmailPay_s(formname){
	var form = document.getElementById(formname);
	var mylname = form.plname.value;
	ajax.encVar("lname", mylname); 	
	var myfname = form.pfname.value;
	ajax.encVar("fname", myfname); 	
	var myemail = form.pemail.value;
	ajax.encVar("email", myemail); 	
	var mygender = form.pgender.value;
	ajax.encVar("gender", mygender); 		
	var mytel = form.ptel.value;
	ajax.encVar("tel", mytel); 	
	var myschool = form.pschool.value;
	ajax.encVar("school", myschool); 	
	var myid = form.pid.value;
	ajax.encVar("pid", myid); 	
	var mytype = form.ttype.value;
	ajax.encVar("ptype", mytype); 		
  ajax.encVar("submit", "Y");   
	ajax.requestFile = 'pay.php';
	ajax.method = 'POST';
	ajax.element = 'replacemep_s';
	ajax.onLoading = whenLoadingPay_s;
	ajax.onCompletion = whenCompletedPay_s;
	ajax.runAJAX();
}

function whenLoadingPay_s(){
	var e = document.getElementById('replacemep_s'); 
	e.innerHTML = "<p>Adding Payment Information...</p>";
}

function whenCompletedPay_s(){
	var e = document.getElementById('replacemep_s'); 
	if (ajax.responseStatus){
		var string = ajax.response;
		if (string == 'OK') {
			hidePopup('Pay_s');
			showPopup_wh('Paynow_s',480,350);
			var string = "<a href=\"javascript:hidePopup('Pay_s');showPopup_wh('Paynow_s',480,350);\">REDIR to PAYMENT</a> ";
			}	
	} else {
		var string = "Error Adding Payment Information";
	}
	e.innerHTML = string;	
}


function SendEmailPay_g(formname){
	var form = document.getElementById(formname);
	var mylname = form.plname.value;
	ajax.encVar("lname", mylname); 	
	var myfname = form.pfname.value;
	ajax.encVar("fname", myfname); 	
	var myemail = form.pemail.value;
	ajax.encVar("email", myemail); 	
	var mygender = form.pgender.value;
	ajax.encVar("gender", mygender); 		
	var mycompany = form.pcompany.value;
	ajax.encVar("company", mycompany); 	
	var mytel = form.ptel.value;
	ajax.encVar("tel", mytel); 	
	var myposition = form.pposition.value;
	ajax.encVar("position", myposition); 	
	var mytype = form.ttype.value;
	ajax.encVar("ptype", mytype); 		
  ajax.encVar("submit", "Y");   
	ajax.requestFile = 'pay.php';
	ajax.method = 'POST';
	ajax.element = 'replacemep_g';
	ajax.onLoading = whenLoadingPay_g;
	ajax.onCompletion = whenCompletedPay_g;
	ajax.runAJAX();
}

function whenLoadingPay_g(){
	var e = document.getElementById('replacemep_g'); 
	e.innerHTML = "<p>Adding Payment Information...</p>";
}

function whenCompletedPay_g(){
	var e = document.getElementById('replacemep_g'); 
	if (ajax.responseStatus){
		var string = ajax.response;
		if (string == 'OK') {
			hidePopup('Pay_g');
			showPopup_wh('Paynow_g',480,350);
			var string = "<a href=\"javascript:hidePopup('Pay_g');showPopup_wh('Paynow_g',480,350);\">REDIR to PAYMENT</a> ";
			}	
	} else {
		var string = "Error Adding Payment Information";
	}
	e.innerHTML = string;	
}
