//******************************************************************************************************************************
//Blingo - markm 10.27.2006

function ValidateBlingo(){
	var nickname=Trim(document.forms[0].nickname.value);
	document.forms[0].nickname.value = nickname;
	var passone=document.forms[0].passone.value;//do not modify password
	var passtwo=document.forms[0].passtwo.value;//do not modify password
	
	if(passone.length+passtwo.length==0){
		funcLightBoxMessage();
		return false;
	}
    else {
    //always return TRUE when everything passes
    return true;
	}
}

var boolSwapped=false;
function funcTestSwap(){
	if(!boolSwapped){
		var nickname=Trim(document.forms[0].nickname.value);
		var passone=document.forms[0].passone.value;//do not modify password
		var passtwo=document.forms[0].passtwo.value;//do not modify password
	
		if(nickname.lenth!=0 && passone.length !=0 && passtwo.length !=0){
			boolSwapped=true;
			document.getElementById("submitButton").style.display="none";//hide "SUBMIT"
			document.getElementById("enterButton").style.display="block";//show "ENTER NOW"
		}
	}
}
//end:blingo
//******************************************************************************************************************************

function writeFlash(movieName, width, height, params){
	markup = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	markup += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
	markup += 'height="' + height +'" width="' + width + '">';
	markup += '<param name="movie" value="' + movieName + '">';
	markup += '<param name="flashvars" value="' + params + '">';
	markup += '<param name="quality" value="best"><param name="play" value="true">';
	markup += '<embed pluginspage="http://www.macromedia.com/go/getflashplayer" ';
	markup += 'src="' + movieName + '" flashvars="' + params + '" type="application/x-shockwave-flash" ';
	markup += 'height="' + height +'" width="' + width + '" quality="best" play="true"></embed></object>';
	document.write(markup);
}

function capitalize(string){
	// capitalizes all words in a string
	tmp = "";
	string = string.split(/\s+/); // split on any white space
	for (i=0; i<string.length; i++){
		tmp += ((i==0)?"":" ") + string[i].charAt(0).toUpperCase() + string[i].substring(1).toLowerCase();
	}
	return tmp;
}

function getURLValue(v){
	q = document.location.search.substring(1);
	if (q=="") return q;
	pairs = q.split("&");
	for (i=0; i<pairs.length; i++){
		if (pairs[i].split("=")[0].toLowerCase() == v.toLowerCase()) return unescape(pairs[i].split("=")[1]);
	}
	return "";
}

function nextPage(page){
	//alert(page + document.location.search)
	document.location.href = page + document.location.search;
}


/* Compiled by Amy Jen */
/* Updated by hens, June'04 */
var noclick=0;
var counter = 0;
var counter2=0;
var tempID=0;


function string_GetURLValue(string_name)    {
	var string_queryString = new String(document.location.search);
	if(string_queryString.charAt(0)=="?")   {
		string_queryString = string_queryString.substring(1)
	}
	if(string_queryString.length==0)return "";
	array_nameValuePairs = string_queryString.split("&");
	for(int_counter=0; int_counter < array_nameValuePairs.length; int_counter++)    {
		if(array_nameValuePairs[int_counter].split("=")[0].toUpperCase() == string_name.toUpperCase())  {
			return unescape(array_nameValuePairs[int_counter].split("=")[1]);
		}
	}
	return "";
}

/*****************************************************************************/
/* Prepop Info 											     */
/*****************************************************************************/
	var urlString = window.location.toString();
	urlStringarray = urlString.split("?");

	if (urlStringarray[1]){
		var pairs=urlStringarray[1].split("&");
	
		var key= new Array();
		for (i=0; i<pairs.length; i++) {
			key[i]=pairs[i].split("=");		
		}
	}else{
		urlStringarray[1]="No Query";
	}
	
/*******************************/
//GIFT
function giftLink(Gurl){
	Gurl=Gurl+"?ID_Type=515&Source=XX311&Segment_SourceKey=TY036"
	if (pairs){
		for (i=3; i<pairs.length;i++){
			Gurl=Gurl+"&"+pairs[i];
		}
	}
	newwindow=window.open(Gurl,"giftwin","scrollbars=yes,toolbar=yes,directories=yes,menubar=yes,resizable=yes,status=yes,width=800,height=600");
	newwindow.window.focus();
}
/*******************************/

function writeMe(whatKey){
		for (i=0; i<pairs.length; i++) {
			if (key[i][0]==whatKey){
					return key[i][1];		
			}
		}
}


function testDisp(blah){
	var temp = window.location.toString();
	var fisnot = temp.indexOf("&fn=");
	if (fisnot==-1){
		//don't do anything
	}else{
		if (blah=="1"){
			document.write(writeMe('fn')+" "+writeMe('ln'));	
		}
		if (blah=="4"){
			document.write("This communication has been officially prepared for <script language='javascript'> testDisp('1') </script>");
			document.write(". If you are not <script language='javascript'> testDisp('1') </script>");
			document.write(" please <a href='#' onclick='wrongPerson();'><span class='smalltext2'>click here</span></a>.");
		}	
	}
}

function wrongPerson(){
	var winURL = window.location.toString();
	var stopat = winURL.indexOf("&fn");
	var getNew = winURL.substring(winURL, stopat);

	window.location = getNew;
}
/*****************************************************************************/

function getImageOnly(imgPath)	{
	var img = parseInt(imgPath.lastIndexOf("/"))+1;
	return imgPath.substr(img);
}

function openit(sURL,w,h){
	if (urlStringarray[1]){
		sURL=sURL+"?"+urlStringarray[1];
	}else{
		urlStringarray[1]="No Query";
	}	
	newwindow=window.open(sURL,"newwin","scrollbars=no,toolbar=no,directories=no,menubar=no,resizable=yes,status=no,width="+w+",height="+h+"");
	newwindow.window.focus();
}

function openit2(sURL,w,h){
	newwindow=window.open(sURL,"nextwin","scrollbars=yes,toolbar=no,directories=no,menubar=no,resizable=yes,status=no,width="+w+",height="+h+"");
	newwindow.window.focus();
}

function ChangeIT(imgName,imgSrc){
	//alert(noclick);
	document.forms[0][imgName].src=imgSrc;
}	

function go(){
	ChangeIT("load","assets/bireport.gif");
}	
	
/*
	Chris Donnan
	2003 09 24

	BillMe and Gifting support
	This file is a template for local.js includes for billme pages

	Requires library:
		email.js
*/

/*
	newCheck()
	called when a page is submitted
*/
function newCheck()//void
{
	// validates bill me order
	//if(!ValidateOrderInfo())
	//{
	//	return
	//}

	if(!ValidateBlingo()){
		return
	}

	document.forms[0].submit();
}

/*
	string editing function that trims any leading and trailing whitespace
*/
function Trim(str)//string	
{
	return RTrim(LTrim(str));
}

/*
	string editing function that trims any leading whitespace
*/
function LTrim(str)//string	
{
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(0)) != -1) {
	var j=0, i = s.length;
	while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
		j++;
	s = s.substring(j, i);
	}
	return s;
}

/*
	string editing function that trims any trailing whitespace
*/
function RTrim(str)//string	
{
	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
	var i = s.length - 1;       // Get length of string
	while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
		i--;
	s = s.substring(0, i+1);
	}
	return s;
}


//********************************************************************************//

function wrongPerson(){
	var winURL = window.location.toString();
	var stopat = winURL.indexOf("&fn");
	var getNew = winURL.substring(winURL, stopat);

	window.location = getNew;
}
//Put this part in the .js file//
//*************************************************************************************************************************************************

var WM_startTagFix = '</';
var msie_windows = 0;
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)){
  msie_windows = 1;
  document.writeln('<script language="VBscript">');
  document.writeln('\'This will scan for plugins for all versions of Internet Explorer that have a VBscript engine version 2 or greater.');
  document.writeln('\'This includes all versions of IE4 and beyond and some versions of IE 3.');
  document.writeln('Dim WM_detect_through_vb');
  document.writeln('WM_detect_through_vb = 0');
  document.writeln('If ScriptEngineMajorVersion >= 2 then');
  document.writeln('  WM_detect_through_vb = 1');
  document.writeln('End If');
  document.writeln('Function WM_activeXDetect(activeXname)');
  document.writeln('  on error resume next');
  document.writeln('  If ScriptEngineMajorVersion >= 2 then');
  document.writeln('     WM_activeXDetect = False');
  document.writeln('     WM_activeXDetect = IsObject(CreateObject(activeXname))');
  document.writeln('     If (err) then');
  document.writeln('        WM_activeXDetect = False');
  document.writeln('     End If');
  document.writeln('   Else');
  document.writeln('     WM_activeXDetect = False');
  document.writeln('   End If');
  document.writeln('End Function');
  document.writeln(WM_startTagFix+'script>');
}

function WM_pluginDetect(plugindescription, pluginxtension, pluginmime, activeXname){

  //This script block will test all user agents that have a real plug-in array
  //(i.e. Netscape) and set the variables, otherwise it directs the routine
  // to WM_activeXDetect to detect the activeX control.

  

  // First define some variables
  var i,plugin_undetectable=0,detected=0, daPlugin=new Object();


  // Then we check to see if it's an MSIE browser that you can actually

  // check for the plugin in question. 

  if (msie_windows && WM_detect_through_vb){
      plugin_undetectable = 0;
  } else {
      plugin_undetectable = 1;
  }



  // If it has a real plugins or mimetypes array, we look there for the plugin first

  if(navigator.plugins) {
      numPlugins = navigator.plugins.length;
      if (numPlugins > 1) {
	  if (navigator.mimeTypes && navigator.mimeTypes[pluginmime] && navigator.mimeTypes[pluginmime].enabledPlugin && (navigator.mimeTypes[pluginmime].suffixes.indexOf(pluginxtension) != -1)) { // seems like we have it, let's just make sure and check the version (if specified)
	      if ((navigator.appName == 'Netscape') && (navigator.appVersion.indexOf('4.0') != -1)) { // stupid, stupid Netscape can't handle the references to navigator.plugins by number, sooo...
		  for(i in navigator.plugins) {
		      if ((navigator.plugins[i].description.indexOf(plugindescription) != -1) || (i.indexOf(plugindescription) != -1)) { // some versions of quicktime have no description. feh!
			  detected=1;
			  break;
		      }
		  }
	      } else {
		  for (i = 0; i < numPlugins; i++) {
		      daPlugin = navigator.plugins[i];
		      if ((daPlugin.description.indexOf(plugindescription) != -1) || (daPlugin.name.indexOf(plugindescription) != -1)) {
			  detected=1;
			  break;
		      }
		  }
	      }

	      // Mac weirdness
      if (navigator.mimeTypes[pluginmime] == null) {
		  detected = 0;
	      }
	  }
	  return detected;
      } else if((msie_windows == 1) && !plugin_undetectable){
	  return WM_activeXDetect(activeXname);
      } else { 		
	  return 0;
      }
  } else {
      return 0;
  }
}


// this next function just makes it easy to detect the common plugins

function WM_easyDetect(whichPlugin) {

    // this function just makes it easy to do basic plug-in detection without
    // knowing all the mimetypes and activeX names and such

    var isItThere = 0;
    if( (whichPlugin == 'flash') || (whichPlugin == 'Flash') ) {
	isItThere = WM_pluginDetect('Flash', 'swf', 'application/x-shockwave-flash', 'ShockwaveFlash.ShockwaveFlash');
    } else if( (whichPlugin == 'director') || (whichPlugin == 'Director') ) {
	isItThere = WM_pluginDetect('Shockwave', 'dcr', 'application/x-director', 'SWCtl.SWCtl.1');
    } else if( (whichPlugin == 'quicktime') || (whichPlugin == 'Quicktime') || (whichPlugin == 'QuickTime') ) {
	isItThere = WM_pluginDetect('QuickTime', 'mov', 'video/quicktime', '');

    } else if( (whichPlugin == 'realaudio') || (whichPlugin == 'Realaudio') || (whichPlugin == 'RealAudio') ) {
	isItThere = (WM_pluginDetect('RealPlayer', 'rpm', 'audio/x-pn-realaudio-plugin', 'RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)')) || (WM_pluginDetect('RealPlayer', 'rpm', 'audio/x-pn-realaudio-plugin','rmocx.RealPlayer G2 Control')) || (WM_pluginDetect('RealPlayer', 'rpm', 'audio/x-pn-realaudio-plugin','RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)')) || (WM_pluginDetect('RealPlayer', 'rpm', 'audio/x-pn-realaudio-plugin','RealVideo.RealVideo(tm) ActiveX Control (32-bit)'))
    } else {

	alert('You need to tell me which plug-in to look for, like so:\n\n' + '          WM_easyDetect(\'flash\')\n\n' + '          WM_easyDetect(\'director\')\n\n' + '          WM_easyDetect(\'quicktime\')\n\n' + '          WM_easyDetect(\'realaudio\')');
    }
    return isItThere;
}

