/* Functions that swaps images. */

var temp1,temp2;
var jumped = false;



/* Function to swap a font tag's font class */
function NC_swapClass(textID,myClass) {
	obj=MM_findObj(textID);
	if (obj) obj.className=myClass;
}

/* Function to find a document object */
function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

/* Functions that swap layers - used only in product nav menu */
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/* Function that handle preload. */
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v3.0
  var ok=false; document.MM_returnValue = false;
  with (navigator) if (appName.indexOf('Microsoft')==-1) ok=(plugins && plugins[plgIn]);
  else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
    if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
    else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
    else ok=autoGo; }
  if (!ok) theURL=altURL; if (theURL) window.location=theURL;
}

function popNew(loc,name,width,height) {
	pop = window.open(loc,name,'scrollbars,status,resizable,width=' + width + ',height=' + height);
	pop.focus();
}

function popFull(loc,name,width,height) {
	pop = window.open(loc,name,'resizable,width=' + width + ',height=' + height +',top=0,left=0');
	pop.focus();
}

function popRestricted(loc,name,width,height) {
	pop = window.open(loc,name,'status,width=' + width + ',height=' + height);
	pop.focus();
}

function popRestrictedScroll(loc,name,width,height) {
	pop = window.open(loc,name,'scrollbars,status,width=' + width + ',height=' + height);
	pop.focus();
}

function popNewNoChrome(loc,name,width,height) {
	pop = window.open(loc,name,'width=' + width + ',height=' + height);
	pop.focus();
}

function popReal(loc,name,width,height) {
	pop = window.open(loc,name,'scrollbars,status,toolbar,menubar,directories,location,resizable,width=' + width + ',height=' + height);
	pop.focus();
}
function openWindow (f_name, s_title, s_attrib) {
	w_global = window.open(f_name, s_title, s_attrib);
}

/* checks if text in a form field is a possible email address */
/*   x@x.xx  minimum  */
/*   usage: if (isemail('txt_username','Email not valid!')) submitForm('frm_login');  */
function isemail(field,message) {
	var obj=MM_findObj(field);
	var val=obj.value;
	var atloc=val.indexOf('@');
	var dotloc=val.indexOf('.');
	if ((atloc > 1) && (dotloc > atloc+1) && (val.length > dotloc+2)) {
		var bob=true;
	} else {
		alert(message);
		var bob=false;
	}
	return bob;
}

function ispasseq(field1,field2,message) {
	var obj1=MM_findObj(field1);
	var val1=obj1.value;
	var obj2=MM_findObj(field2);
	var val2=obj2.value;
    if (val1==val2){
		var bob=true;
	} else {
		alert(message);
		var bob=false;
	}
	return bob;
}


/* used to submit forms easily within divs, or from within other forms */
function submitForm(frm) { //v3.0
	var obj = MM_findObj(frm);
	obj.submit();
}
function submitformcheck(form) {
	var obj=MM_findObj(form);
	var frmname='_CF_check' + form + '(obj)';
	if (eval(frmname)) {
		obj.submit();
	}
}

/* used to ensure a combo's value is not "" */
function verifyCombo(form,cbo,message) {
	obj=MM_findObj(form);
	obj=eval('obj.'+cbo);
	var index=obj.selectedIndex;
	var val=obj.options[index].value;
	if (val == "") {
		if (message != "")
			alert(message);
		return false;
	} else {
		return true;
	}
}

/* used to verify a user's request before connecting a link */
function verifyLink(message,myurl) {
	if (confirm(message)) {
		document.location.href=myurl;
	}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// djh 11/21/00
// This popup window will upload images to the server
// the set the parent text boxes to the correct value
//
function popUpload(p_ccaption, p_ctextname, p_noid, p_cpath) {
	popNew("uploadpop.cfm?caption=" + p_ccaption + "&textname=" + p_ctextname + "&oid=" + p_noid + "&path=" + p_cpath,"uploadwindow","270","190");
}

// These set of JavaScript functions are used for validation of a date entered into a text
// form field. The conversion is attempted when the field is blurred using the onBlur()
// JavaScript function. If the text can't be converted into a recognizable date, a message is
// generated via an alert box and focus is returned to the text field.

// The following functions were written by Tom Wittbrodt
// Copyright (c) 1998, 1999 Tom Wittbrodt
// License is granted if and only if this entire 
// copyright notice is included. 
function validate_date(date_field, desc) {
		if (!date_field.value)  
                return true;
        var in_date = stripCharString(date_field.value," ");
        in_date = in_date.toUpperCase();
        var date_is_bad = 0;  
        if (!allowInString(in_date,"/0123456789T+-"))
                date_is_bad = 1; // invalid characters in date
        if (!date_is_bad) { 
                var has_rdi = 0;
                if (in_date.indexOf("T") >= 0){ 
                        has_rdi = 1;
                }
                if (!date_is_bad && has_rdi && (in_date.indexOf("T") != 0)) { 
                        date_is_bad = 2; // relative date index character is not in first position
                }
                if (!date_is_bad && has_rdi && (in_date.length == 1)) { 
                        var d = new Date();
                                                var return_month = parseInt(d.getMonth() + 1).toString();
                                                return_month = (return_month.length==1 ? "0" : "") + return_month; 
                                                var return_date =  parseInt(d.getDate()).toString();
                                                return_date = (return_date.length==1 ? "0" : "") + return_date; 
                                        in_date = return_month + "/" + return_date + "/" + get_full_year(d);            
                        has_rdi = 0; // date doesn't have rdi char anymore (will also cause failure of add'l rdi checks, which is a good thing)
                }
                if (!date_is_bad && has_rdi && (in_date.length > 1) && !(in_date.charAt(1) == "+" || in_date.charAt(1) == "-")) {
                        date_is_bad = 3; // length of rdi string is greater than 1 but second char is not "+" or "-"
                }
                if (!date_is_bad && has_rdi && isNaN(parseInt(in_date.substring(2,in_date.length),10))) {
                        date_is_bad = 4; // rdi value is not a number
                }
                if (!date_is_bad && has_rdi && (parseInt(in_date.substring(2,in_date.length),10) < 0)) {
                        date_is_bad = 5; // rdi value is not a positive integer
                }
                if (!date_is_bad && has_rdi) {
                        var d = new Date();
                        ms = d.getTime();
                        offset = parseInt(in_date.substring(2,in_date.length),10);
                        if(in_date.charAt(1) == "+") {
                                ms += (86400000 * offset);
                        } else {
                                ms -= (86400000 * offset);
                        }
                        d.setTime(ms);
                                                var return_month = parseInt(d.getMonth() + 1).toString();
                                                return_month = (return_month.length==1 ? "0" : "") + return_month; 
                                                var return_date =  parseInt(d.getDate()).toString();
                                                return_date = (return_date.length==1 ? "0" : "") + return_date; 
                                        in_date = return_month + "/" + return_date + "/" + get_full_year(d);    
                        has_rdi = 0;
                }
        } 
        if (!date_is_bad) {
                var date_pieces = new Array();
                date_pieces = in_date.split("/");
                if (date_pieces.length == 2) {
                        var d = new Date();
                        in_date = in_date + "/" + get_full_year(d);
                        date_pieces = in_date.split("/");
                }
                if (date_pieces.length != 3 || parseInt(date_pieces[0],10) < 1 || parseInt(date_pieces[0],10) > 12 
                                || parseInt(date_pieces[1],10) < 1 || parseInt(date_pieces[1],10) > 31 
                                || (date_pieces[2].length != 2 && date_pieces[2].length != 4)) {
                        date_is_bad = 6;  // date is not in format of m[m]/d[d]/yy[yy]
                }
        }
        if (date_is_bad) {
                alert(desc + " must be in the format of mm/dd/yy, mm/dd/yyyy, t, t+n or t-n.");
                date_field.focus();
                return (false);
        }
        
        var ms = Date.parse(in_date);
        var d = new Date();
        d.setTime(ms);
                var return_date = d.toLocaleString();
                var return_month = parseInt(d.getMonth() + 1).toString();
                return_month = (return_month.length==1 ? "0" : "") + return_month; 
                var return_date =  parseInt(d.getDate()).toString();
                return_date = (return_date.length==1 ? "0" : "") + return_date; 
        return_date = return_month + "/" + return_date + "/" + get_full_year(d);
        date_field.value = return_date;
        return true;
}       // normalize the year to yyyy
function get_full_year(d) {
                var y = ""
                if (d.getFullYear() != null)
                {
                        y = d.getFullYear();
                        if (y < 1970) y+= 100;          
                } else
                {       
                y = d.getYear();
                if (y > 69  && y < 100) y += 1900;
                if (y < 1000) y += 2000;
                }
        return y;
}
// The following functions were written by Gordon McComb
// More information can be found here: http://www.javaworld.com/javaworld/jw-02-1997/jw-02-javascript.html
function stripCharString (InString, CharString)  {
        var OutString="";
   for (var Count=0; Count < InString.length; Count++)  {
        var TempChar=InString.substring (Count, Count+1);
      var Strip = false;
      for (var Countx = 0; Countx < CharString.length; Countx++) {
        var StripThis = CharString.substring(Countx, Countx+1)
         if (TempChar == StripThis) {
                Strip = true;
            break;
         }
      }
      if (!Strip)
        OutString=OutString+TempChar;
   }
        return (OutString);
}
function allowInString (InString, RefString)  {
        if(InString.length==0) return (false);
        for (var Count=0; Count < InString.length; Count++)  {
        var TempChar= InString.substring (Count, Count+1);
      if (RefString.indexOf (TempChar, 0)==-1)  
        return (false);
   }
   return (true);
}

//  Function to open a new window and place focus there.
// If the window is already opened focus will be placed.
var newWindow
function openWebTopWindow(URL, winName, chrome) {
	if (!newWindow || newWindow.closed) {
		newWindow = window.open(URL,winName,chrome)
		if (!newWindow.opener) {
			newWindow.opener = window
		}
	} else {
		// window's already open; bring to front
		newWindow.location = URL;
		newWindow.focus();
	}
}


function isRadioChecked(r)
{
var radio_choice = false;
for (counter = 0; counter < r.length; counter++){
	if (r[counter].checked)	radio_choice = true; 
}
if (!radio_choice) {	
	return (false);	
}
	return (true);	
}


// function to load the calendar window.
function ShowCalendar(FormName, FieldName)
{
    window.open("CFDateSelect.cfm?FormName=" + FormName + "&FieldName=" + FieldName, "CalendarWindow", "width=200,height=125");
}
//-->
//-->

