function validateForm(){
	var e = $('email').value;
	var p = $('password').value;
	if($("agree").checked){
		if(e.indexOf("@") >2 && e.indexOf(".") >2){
			if(p != ''){
				return true;
			} else{
				alert("pasword cannot be blank");
				return false;
			}
			return true;
		} else {
			alert("Please enter a valid email address");
			return false;
		} 
		
		
	} else {
		alert("Please Check the box agreeing to terms and condition to begin application");
		return false;
	}
	
	return false; 
	
}


function gup( name )
			{
			  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
			  var regexS = "[\\?&]"+name+"=([^&#]*)";
			  var regex = new RegExp( regexS );
			  var results = regex.exec( window.location.href );
			  if( results == null )
			    return "";
			  else
			    return results[1];
			}

function mooBox(url, caption, dimensions){
	MOOdalBox.open(url, caption, dimensions);
}
function launch(URL){
		var Width = (screen.width-(screen.width/50)); 
		var Height = (screen.height-(screen.height/10));
	    var params = ('toolbar=no,scrollbars=Yes,left=0,top=0,resizable=yes,width=' + Width + ',height=' + Height);
		pop = window.open(URL, 'newWindow', params);
		pop.focus();
	
}

function confirmAction(path, message) {
    if (confirm(message)) {
		window.location = path;
    } else {
       return false;
    }
}

function imageResize(x, y, maxx, maxy) {
	
	var propx = x / maxx;
	var propy = y / maxy;
	
	var newx = x;
	var newy = y;
	
	if (propx > 1 && propx > propy) {
		newx = maxx;
		newy = y / propx;
	} else if (propy > 1) {
		newy = maxy;
		newx = x / propy;
	}
	
	
	return {'width': newx, 'height': newy};
	
}


// JavaScript Document

function launchImage(theURL,Width,Height){
	  var Scrollbars = "no";
	  if(screen.height<Height){
	  var Height = (screen.height-200);
	  var Scrollbars = "yes";
	  }
	  
	  if(screen.width<Width){
	  var Width = (screen.width-200);
	  var Scrollbars = "yes";
	  }
	  else{
	  var Width = Width;
	  }
	  var Left = (screen.width-Width)/2;
	  var Top = (screen.height-Height)/2;
	  var params = ('toolbar=no,scrollbars=' + Scrollbars + ',resizable=no,left=' + Left +',top=' + Top +',width=' + Width + ',height=' + Height);
	  
	Pop = window.open(theURL, "LaunchImage", params);
	
	Pop.focus();
}
function launch(URL) {
        
		var Width = (screen.width-(screen.width/50)); 
		var Height = (screen.height-(screen.height/10));
	    var params = ('toolbar=no,scrollbars=Yes,left=0,top=0,resizable=yes,width=' + Width + ',height=' + Height);
		pop = window.open(URL, 'newWindow', params);
		pop.focus();
	}


function change_video(channel){
	//var re =  /(.ram|.rm|.ra)$/i;
	//var re2 =  /(.wmv|.wvx|.wma|.asf|.asx)$/i;
	//if(re.test(channel)){
		MediaPlayer.SetSource(channel);
		if(MediaPlayer.CanPlay()){ 
			MediaPlayer.DoPlay(); 
		}
	//}
	//if(re2.test(channel)){
	//	MediaPlayer.URL = channel;
	//	MediaPlayer.controls.play();
	//}
}
  var ie=document.all;
  var ns=document.layers;
  var button = new Array(); //all buttons
  /*
  button[1] = new Image(); button[1].src = "http://www.un.org/webcast/test/video_09.gif";
  button[2] = new Image(); button[2].src = "http://www.un.org/webcast/test/video_over_09.gif";
  var label = new Array(); //all labels
  for(var i=13; i<=17; i++) {
    label[i] = new Array();
	label[i][0] = new Image();
	label[i][1] = new Image();
	label[i][0].src = "http://www.un.org/webcast/test/video_"+i+".gif"; //mouse out
	label[i][1].src = "http://www.un.org/webcast/test/video_over_"+i+".gif"; //mouse out
  }
  */
  function swapbutton(xname) {
    var timg = eval("document."+xname);
	var j = parseInt((xname.toString()).slice(1)) + 12;
	var tlab = eval("document.l"+j);
	//alert(tlab);
    if((timg.src).toString()==(button[1].src).toString()) {
	  timg.src = button[2].src;
	  tlab.src = label[j][1].src;
	}
	else {
	  timg.src = button[1].src;
	  tlab.src = label[j][0].src;
	}
  }
function StopClick() {
  if(document.MediaPlayer.CanStop()) document.MediaPlayer.DoStop();
}
function PlayClick() {
  if(document.MediaPlayer.CanPlay()) document.MediaPlayer.DoPlay();
}
function PauseClick() {
  if(document.MediaPlayer.CanPause()) document.MediaPlayer.DoPause();
  else if(document.MediaPlayer.CanPlay()) document.MediaPlayer.DoPlay();
}
function VolumeDown(){ 
  if(document.MediaPlayer.GetVolume() >= 10){ 
	document.MediaPlayer.SetVolume(document.MediaPlayer.GetVolume() - 10) 
  }
}
function VolumeUp(){ 
  if(document.MediaPlayer.GetVolume() <= 90){ 
	document.MediaPlayer.SetVolume(document.MediaPlayer.GetVolume() + 10) 
  }
}
function MuteAudioClick() {
  if(!document.MediaPlayer.GetMute()) document.MediaPlayer.SetMute(true);
  else document.MediaPlayer.SetMute(false);
}
	function time2ms(str) {
	  str = new String(str);
	  var foo = str.split(":");
	  var tsec = parseInt(foo[foo.length-1]);
	  tsec += parseInt(foo[foo.length-2])*60;
	  tsec += parseInt(foo[foo.length-3])*60*60;
	  tsec = tsec*1000;
	  return tsec
	}
	function seek(tstr) {
	  	var _vid = self.document.MediaPlayer;
	    if(_vid && _vid.GetCanSeek()) _vid.SetPosition(time2ms(tstr));
	}

function getControlIcon(action,style){
	var imgTag = '<img src="../_media/graphics/icons/'+style+action+'.gif" border=\"0\" />';
	//alert(imgTag);
	return imgTag;
	
}

function getControls(style){

	var embedThis = '<a href="Javascript:PlayClick();">'+getControlIcon('Play',style)+'</a>';
	embedThis += '<a href="Javascript:StopClick();">'+getControlIcon('Stop',style)+'</a>';	
	embedThis += '<a href="Javascript:PauseClick();">'+getControlIcon('Pause',style)+'</a>';
	embedThis += '<a href="Javascript:MuteAudioClick();">'+getControlIcon('Mute',style)+'</a>';
	return embedThis;
}	
	
function renderReal(file,width,height,style){
	if (pluginlist.indexOf("RealPlayer")!=-1){
	
	} else {
		var p=window.confirm("RealPlayer is required to view this video Click okay to Launch Real Player Download Page")
		if (p){
		window.open('http://www.real.com/realcom/R?href=http%3A%2F%2Fforms.real.com%2Freal%2Fplayer%2Fdownload.html');
		} else {
		alert("Real Player is required to view this Video, Please visit real.com when you are ready to download the plug-in")
		}
		
	}
	var embedThis = '<embed controls="ImageWindow" type="audio/x-pn-realaudio-plugin"src=\''+file+'\' width="'+width+'" height='+height+' autostart="TRUE" name="MediaPlayer" console="theclip"></embed>';
	embedThis += getControls(style);
//	alert(embedThis);
	document.getElementById("player").innerHTML = embedThis;
}
function renderMov(file,width,height){
	var embedThis = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="465" height="340" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" align="middle" >';
	embedThis += '<param name="src" value="'+file+'" />';
	embedThis += '<param name="autoplay" value="true" />';
	embedThis += '<embed controls="all" name="MediaPlayer" src="'+file+'" width="'+width+'" height='+height+' pluginspage=http://www.apple.com/quicktime/download/ align="middle" autoplay="true" bgcolor="black" ></embed></object>';
	
	document.getElementById("player").innerHTML = embedThis;
}
function renderMP4(file,width,height){
	renderMov(file,width,height);
}
function renderWMV(file,width,height){
	var embedThis = '<object id="MediaPlayer" width=465 height=340 classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components?" type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">';
	embedThis += '<param name="filename" value="'+file+'">';
	embedThis += '<param name="Showcontrols" value="True">';
	embedThis += '<param name="autoStart" value="True">';
	//embedThis += '<PARAM name="controls" value="all">';
	embedThis += '<embed type="application/x-mplayer2" src="'+file+'" name="MediaPlayer" width="'+width+'" height='+height+'></embed>';
	
	document.getElementById("player").innerHTML = embedThis;
}

function renderFlash(file,width,height){

	
	
	
// <![CDATA[
var fo = new SWFObject("|||relRoot|||_media/flash/video-player.swf", "FlowPlayer", width, height, "7", "#ffffff", true);
// need this next line for local testing, it's optional if your swf is on the same domain as your html page
fo.addParam("allowScriptAccess", "always");
fo.addVariable("config", "{ fullScreenScriptURL: 'http://powersimple.com/flowplayer/fullscreen.js?id=12', showPlayListButtons: true, playList: [ {overlayId: 'play' }, { url: '"+file+"' } ], initialScale: 'fit' }");
fo.write("player");// ]]\]

}
function showVideo(file,fileType,width,height,style){
	
	document.getElementById("playerHolder").className = style;
	
	if(fileType == 'flv'){
		
		
			var ready = false;
			var version = parseInt(GetSwfVer());
			var neededVersion = "Flash Player is required";
			//alert("v"+version);
			if (pluginlist.indexOf("Flash")!=-1){
				
				if(version >= 8){
					ready = true;	
				} else {
				var neededVersion = "An updated version of your Flash Player is required";
				}	
			}
			
			if(!ready){
				/*var p=window.confirm(neededVersion + " to view this video Click okay to Adobe Flash Player Download Page")
				if (p){
				//window.open('http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player.exe');
				} else {
				//alert(neededVersion + "to view this Video, Please visit adobe.com when you are ready to download the plug-in");
				}
				*/
			} else {
				
			}
			alert("Sorry, we haven't launched our videos, please check back")
			//renderFlash(file,width,height);
		
	} else if(fileType == 'rm'){
		renderReal(file,width,height,style);
	} else if(fileType == 'mov'){
		renderMov(file,width,height);
	} else if(fileType == 'mp4'){
		renderMP4(file,width,height);
	} else if(fileType == 'wmv'){
		renderWMV(file,width,height);
	} else {}
	if(document.all){
		//alert(document.getElementById("playerHolder").className);
	}

}
/*
function formats(file,fileType,width,height,formatList,path){
	l = formatList.split(",");
	formats = '<ul class="formats">';
	for(f in l){
		formats += '<li class="formatIcon"><a href="Javascript:showVideo('+file+','+fileType+','+width+','+height+');">'+f<img src="'+path+'_media/graphics/icons/'+f[l]+'.gif"></a></i>';
	}
	formats += '</ul>';
	document.getElementById('formatListIcons').innerHTML = formats;
	alert(formats);
	
}

//document.getElementById("player").innerHTML = '';

*/
var agt=navigator.userAgent.toLowerCase();
var ie  = (agt.indexOf("msie") != -1);
var ns  = (navigator.appName.indexOf("Netscape") != -1);
var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
var mac = (agt.indexOf("mac")!=-1);
/*+ detectIE("PDF.PdfCtrl.5","Acrobat Reader")+ detectNS("application/pdf","Acrobat Reader")
*/
if (ie && win) {	pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") ; }

if (ns || !win) {
		nse = ""; for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase();
		pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player");
}

function detectIE(ClassID,name) { result = false; document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); if (result) return name+','; else return ''; }
function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }

pluginlist += navigator.javaEnabled() ? "Java," : "";
if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);


//SAMPLE USAGE- detect "Flash"
//if (pluginlist.indexOf("Flash")!=-1)
//document.write("You have flash installed")
// Flash Player Version Detection - Rev 1.5
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. 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];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			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;
}



/*

var modalBox = new Class ({

	container: "outer",
	
	launch: function (url) {
	
		
		if ($defined($('modalBox')))
			$('modalBox').destroy();
	
		var height = 630;
		var width = 810;
	
		var windowSize = window.getSize();
	
		if (! $defined($('modalBlanket'))) {
			var blanket = new Element("div", {'id': 'modalBlanket'});
			blanket.setStyle("height", window.getHeight());
			blanket.setStyle("width", window.getWidth());
			blanket.setStyle("position", "absolute");
			blanket.setStyle("top", 1);
			blanket.setStyle("left", 1);
			blanket.setStyle("background", "black");
			blanket.setStyle("opacity", .5);
		
			blanket.inject($(this.container));
			
			blanket.addEvent('click', function () {this.close()}.bind(this));
		}
	
		if (! $defined($('modalBox'))) {
			var box = new Element("div", {'id': 'modalBox'});
			
			box.setStyle("position", "absolute");
			box.setStyle("top", (windowSize.y - height) / 2);
			box.setStyle("left", (windowSize.x - width) / 2);
			box.setStyle("height", height);
			box.setStyle("width", width);
			box.setStyle("border", "1px solid black");
			box.setStyle("padding", "4px");
			box.setStyle("margin", "4px");
			box.setStyle("z-index", "1000");
			box.setStyle("background", "white");
			box.setStyle("overflow", "auto");
			
			box.setProperty("id", "modalBox");
			
			box.inject($(this.container));
//			box.inject($(this.container));
		}
		
		$('modalBox').load(url);
				
		return $('modalBox');
	
	},
	
	close:  function () {
	
		$('modalBlanket').destroy();
		$('modalBox').destroy();
	
	}
});

modalBox = new modalBox();

function form2url(wformid,encode_it){
  
  if (kform = document.getElementById(wformid)){
    var fkeys = new Array();
    var fvals = new Array();
    var str = "";
    var no,i;
    var inputFields = kform.getElementsByTagName("INPUT");
    for(no=0;no<inputFields.length;no++){
      if (inputFields[no].type.toLowerCase() == "checkbox"){
        if(inputFields[no].checked){
          fkeys[fkeys.length] = inputFields[no].name;
          fvals[fvals.length] = "on";
        }
      } else if (inputFields[no].type.toLowerCase() != "button" && inputFields[no].type.toLowerCase() != "submit"){
        fkeys[fkeys.length] = inputFields[no].name;
        fvals[fvals.length] = inputFields[no].value;
      }
    }
    var selectBoxes = kform.getElementsByTagName("SELECT");
    for(no=0;no<selectBoxes.length;no++){
      fkeys[fkeys.length] = selectBoxes[no].name;
      fvals[fvals.length] = selectBoxes[no].value;
    }
    var selectBoxes = kform.getElementsByTagName("TEXTAREA");
    for(no=0;no<selectBoxes.length;no++){
      fkeys[fkeys.length] = selectBoxes[no].name;
      fvals[fvals.length] = selectBoxes[no].value;
    }
 
    for(i=0;i<fkeys.length;i++){
      str += "&"+fkeys[i]+"="+(fvals[i]?escape((encode_it?encode64(fvals[i]):fvals[i])):"");
    }
 
    return str;
  }
}
 
 
// This code was written by Tyler Akins and has been placed in the
// public domain.  It would be nice if you left this header intact.
// Base64 code from Tyler Akins -- http://rumkin.com
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function encode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;
 
   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);
 
      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;
 
      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }
 
      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);
 
   return output;
}
function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;
 
   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));
 
      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;
 
      output = output + String.fromCharCode(chr1);
 
      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);
 
   return output;
}
*/
/////////////////////////////////////////////////////////
//
// FISHEYE MENU CLASS
/*
var fish = new Class({
	minZoom : 50,
	maxZoom : 100,
	zoomQty : 5,
	testVar : 'hi',
	initialize: function(handle) {
		this.handle = $(handle);
		this.items = this.handle.getElements('img');
		this.handle.setStyle('margin-left', '-' + (this.handle.offsetWidth/2) + 'px');
		this.effects = [] //meh
		this.items.each(function(el) {
			el.addEvent('mouseover', function() { this.magnify(el); }.bind(this));
			el.addEvent('mouseout', function() { this.shrink(el); }.bind(this));
			this.effects[el.src] = $(el.parentNode).effects({wait: false, duration: 200});
		}, this);
	},
	magnify: function(el) {
		this.effects[el.src].custom({
			'height': this.maxZoom + 'px',
			'width': this.maxZoom + 'px',
			'margin-top': '-' + (this.maxZoom - el.getStyle('height').toInt()) + 'px',
		})
	},
	shrink: function(el) {
		this.effects[el.src].custom({
			'height': this.minZoom + 'px',
			'width': this.minZoom + 'px',
			'margin-top': '0px',
		})
	}
});
			
*/
function scrollToTop(){
	var scroll = new Fx.Scroll(document, {
	 wait: false,
	 duration: 2500,
	 offset: {'x': 0, 'y': 0},
	 transition: Fx.Transitions.Quad.easeInOut
	});
}

    requiredCheckbox = 0;
    requiredCheckboxMessage = "";
    
    
