
// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// For the drop menus
// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
function init() {
	//==========================================================================================
	// if supported, initialize TransMenus
	//==========================================================================================
	// Check isSupported() so that menus aren't accidentally sent to non-supporting browsers.
	// This is better than server-side checking because it will also catch browsers which would
	// normally support the menus but have javascript disabled.
	//
	// If supported, call initialize() and then hook whatever image rollover code you need to do
	// to the .onactivate and .ondeactivate events for each menu.
	//==========================================================================================
	if (TransMenu.isSupported()) {
		TransMenu.initialize();

		// hook all the highlight swapping of the main toolbar to menu activation/deactivation
		// instead of simple rollover to get the effect where the button stays hightlit until
		// the menu is closed.
		//menu1.onactivate = function() { document.getElementById("nav_home").className = "hover"; };
		//menu1.ondeactivate = function() { document.getElementById("nav_home").className = ""; };

		menu2.onactivate = function() { document.getElementById("nav_primaryservices").className = "hover"; };
		menu2.ondeactivate = function() { document.getElementById("nav_primaryservices").className = ""; };

		menu3.onactivate = function() { document.getElementById("nav_secondaryservices").className = "hover"; };
		menu3.ondeactivate = function() { document.getElementById("nav_secondaryservices").className = ""; };

		menu4.onactivate = function() { document.getElementById("nav_contact").className = "hover"; };
		menu4.ondeactivate = function() { document.getElementById("nav_contact").className = ""; };
		
		menu5.onactivate = function() { document.getElementById("nav_aboutbcc").className = "hover"; };
		menu5.ondeactivate = function() { document.getElementById("nav_aboutbcc").className = ""; };
	}
}


//Highlight form element- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com

var highlightcolor="lightyellow"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}

//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}
	
// Open pop-up window
function openwindow(path,windowname,attributes) { 
  window.open(path,windowname,attributes);
}

// Read form value and place into hidden form field
function ReadPath() {
	 var filepath = document.form1.filepath.value;
	 document.form1.hiddenpath.value = filepath;
}

// Dropdown navigation without submit
function FastLink() {
window.location= document.getElementById('idcontact').value;
}

// Macromedia functions used by many Dreamweaver behaviors
function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// Basic Toggle
function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

// Clear the input field
function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
	thisfield.value = "";
	}
}

// Toggle checkboxes
function flevToggleCheckboxes() { // v1.1
	// Copyright 2002, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
	var sF = arguments[0], bT = arguments[1], bC = arguments[2], oF = MM_findObj(sF);
    for (var i=0; i<oF.length; i++) {
		if (oF[i].type == "checkbox") {if (bT) {oF[i].checked = !oF[i].checked;} else {oF[i].checked = bC;}}} 
}

// Form validation for the contact page - checks for either a phone or Email addy
//copyright (c)2005 
  function CM_checkform(f){
	 if((f.PrimaryPhone == null || f.PrimaryPhone.value.length < 1) && (f.Email == null || f.Email.value.length < 1)){
		alert('Please provide a Primary Phone # or Email Address.');					
	 }else if( (f.Password == null || f.Password.value.length < 1)){
		alert('Please provide a Password.');			
	 }else if( (f.Username == null || f.Username.value.length < 1)){
		alert('Please provide an Username.');								
	 }else if( (f.R_ContactType == null || f.R_ContactType.value.length < 1)){
		alert('Please Select a Contact Type.');					
	 }else{
		 f.submit();
	 }
  }

  function CM_checkform2(f){
	 if((f.PrimaryPhone == null || f.PrimaryPhone.value.length < 1) && (f.Email == null || f.Email.value.length < 1)){
		alert('Please provide a Primary Phone # or Email Address.');			
	 }else if( (f.R_ContactType == null || f.R_ContactType.value.length < 1)){
		alert('Please Select a Contact Type.');					
	 }else{
		 f.submit();
	 }
  }

// Form validation
function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)}
  document.MM_returnValue = (s=='');
}

//Start textbox suggestion tool - Global variables and functions - additional js on each page that utilizes the tool
var NS4 = (document.layers) ? true : false;
var IE4 = (document.all) ? true : false;
var NS4MAC = NS4 &&
            (navigator.appVersion.indexOf("Macintosh") > -1);

var size = 1;
var textwidth = 1;
var active = false;

// select index style:
//   1. Standard
//      Selects an option if a substring match is found.
//      If no match is found, selects the closest match
//      from the bottom. For example, if the string is
//      "cz", it will match "cy...", "cx...", etc.
//   2. Explorer
//      Simulates the new index in Internet Explorer's
//      help. If the string is empty, selects the first
//      option. Otherwise, if no substring match is found
//      the selection doesn't change.
var style = 1;

function site(name, url) {
  this.name = name;
  this.url = url;
}

function byName(a, b) {
  var anew = a.name.toLowerCase();
  var bnew = b.name.toLowerCase();
  if (anew < bnew) return -1;
  if (anew > bnew) return 1;
  return 0;
}

function display() {
  var list = document.organizer.list;
  if (list.selectedIndex > -1) // if an option is selected
    location.href = list.options[list.selectedIndex].value;
}

function update() {
  if ((!NS4 && !IE4) || NS4MAC) return;
  var form = document.organizer;
  var field = form.prefix;
  var list = form.list;
  field.value = list.options[list.selectedIndex].text;
}

function select(list, i) {
  if (list.selectedIndex != i) list.selectedIndex = i;
}

function checkKey() {
  if (!active) return;
  var form = document.organizer;
  var field = form.prefix;
  var list = form.list;
  var str = field.value.toLowerCase();
  if (str == "") {
    select(list, 0);
    return;
  }
  for (var i = 0; i < list.options.length; ++i) {
    if (list.options[i].text.toLowerCase().indexOf(str) == 0) {
      select(list, i);
      return;
    }
  }
  if (style == 1) {
    for (i = list.options.length - 1; i >= 0; --i) {
      if (str > list.options[i].text.toLowerCase()) {
        select(list, i);
        return;
      }
    }
    select(list, 0);
  }
}

//END textbox suggestion tool


//confirm delete 
function confirmSubmit(msg)
{
var agree=confirm(msg);
if (agree)
	return true ;
else
	return false ;
}

//Automatically Clear default value from text box
function clearDefault(el) {

  if (el.defaultValue==el.value) el.value = ""
}

//POPUP window
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//image swap
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 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_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];}
}

//Calendar Picker
/// <summary>
/// Launches the DatePicker page in a popup window, 
/// passing a JavaScript reference to the field that we want to set.
/// </summary>
/// <param name="strField">String. The JavaScript reference to the field that we want to set, in the format: FormName.FieldName
/// Please note that JavaScript is case-sensitive.</param>
function calendarPicker(strField)
{
	window.open('/functions/DatePicker.aspx?field=' + strField,'calendarPopup','width=230,height=170,resizable=yes');
}

// function to display The MeiVici bike for raffle
function displayBike() {
	var bikepic = document.getElementById("bikepic");
	if(bikepic.style.display == "block") {
		bikepic.style.display = "none";
	} else {
		bikepic.style.display = "block";
	}
}

// Browser interrogation.
function browserObj() {

	this.agent = navigator.userAgent.toLowerCase();
	this.name = navigator.appName.toLowerCase();
	this.version = navigator.appVersion;
	
	this.platform = "";
	this.isW3C   = true;  //assume innocent until proven guilty
	this.isMajor = true;  //assume innocent until proven guilty
	
	this.isMinor   = false;
	this.isNav4    = false;
	this.isNav6    = false;
	this.isIE4     = false;
	this.isIE      = false;
	this.isSafari  = false;
	this.isFirefox = false;
	this.isMoz     = false;
	this.isOpera   = false;

	//Platform
	if (this.agent.indexOf("windows") != -1)
		this.platform = "pc";
	else if (this.agent.indexOf("mac") != -1)
		this.platform = "mac";
	else if (this.agent.indexOf("linux") != -1)
		this.platform = "linux";
	else
		this.platform = "unknown";
		
	//Internet Explorer
	var indexMSIE = this.agent.indexOf("msie")
	if (indexMSIE != -1) {
		this.isIE = true;
		
		var versionIE = parseInt(this.agent.charAt(indexMSIE + 5));
		if(versionIE < 6) { 
			this.isW3C = false; //Must specify DOCTYPE for IE6+ to behave as W3C (although even IE6 gets table COL widths wrong)
			
			if(versionIE < 5) {
				this.isIE4 = true;
				this.isMajor = false;
				this.isMinor = true;
			}
		}
	}
	
	//Safari
	else if (this.agent.indexOf("safari") != -1) {
		this.isSafari = true
	}
	
	//Firefox
	else if (this.agent.indexOf("firefox") != -1) {
		this.isFirefox = true
	}
	
	//Netscape 4
	else if (this.name == "netscape" && parseInt(this.version.charAt(0)) < 5) {
		this.isW3C = false;
		this.isNav4 = true;
		this.isMajor = false;
		this.isMinor = true;
	}
	
	//Newer Netscape
	else if (this.agent.indexOf("netscape") != -1) {
		
		indexNetscape = this.agent.indexOf("netscape");
		indexSlash = this.agent.indexOf("/", indexNetscape);
		versionNav = parseInt(this.agent.charAt(indexSlash + 1));
		if(versionNav < 7) {
			this.isNav6 = true;
		}
	}
	
	//Mozilla (will catch derivitives such as K-Meleon)
	else if (this.agent.indexOf('gecko') > -1) {
		this.isMoz = true;
	}
	
	//Opera
	else if (this.agent.indexOf('opera') > -1) {
		this.isOpera = true;
	}
	
}


