
 ////  COMBINED FILE -- onDOMReady.js  ////// 

/* -----------------------------------*/
/* --->>> onDOMReady Extension <<<----*/
/* -----------------------------------*/
// http://smoothoperatah.com/files/onDOMReady.js


Object.extend(Event, {
  _domReady : function() {
    if (arguments.callee.done) return;
    arguments.callee.done = true;

    if (this._timer)  clearInterval(this._timer);
    
    this._readyCallbacks.each(function(f) { f() });
    this._readyCallbacks = null;
},
  onDOMReady : function(f) {
    if (!this._readyCallbacks) {
      var domReady = this._domReady.bind(this);
      
      if (document.addEventListener)
        document.addEventListener("DOMContentLoaded", domReady, false);
        
        /*@cc_on @*/
        /*@if (@_win32)
            document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
            document.getElementById("__ie_onload").onreadystatechange = function() {
                if (this.readyState == "complete") domReady(); 
            };
        /*@end @*/
        
        if (/WebKit/i.test(navigator.userAgent)) { 
          this._timer = setInterval(function() {
            if (/loaded|complete/.test(document.readyState)) domReady(); 
          }, 10);
        }
        
        Event.observe(window, 'load', domReady);
        Event._readyCallbacks =  [];
    }
    Event._readyCallbacks.push(f);
  }
});


 ////  COMBINED FILE -- forEach.js  ////// 
/*
	forEach, version 1.0
	Copyright 2006, Dean Edwards
	License: http://www.opensource.org/licenses/mit-license.php
*/

// array-like enumeration
if (!Array.forEach) { // mozilla already supports this
	Array.forEach = function(array, block, context) {
		for (var i = 0; i < array.length; i++) {
			block.call(context, array[i], i, array);
		}
	};
}

// generic enumeration
Function.prototype.forEach = function(object, block, context) {
	for (var key in object) {
		if (typeof this.prototype[key] == "undefined") {
			block.call(context, object[key], key, object);
		}
	}
};

// character enumeration
String.forEach = function(string, block, context) {
	Array.forEach(string.split(""), function(chr, index) {
		block.call(context, chr, index, string);
	});
};

// globally resolve forEach enumeration
var forEach = function(object, block, context) {
	if (object) {
		var resolve = Object; // default
		if (object instanceof Function) {
			// functions have a "length" property
			resolve = Function;
		} else if (object.forEach instanceof Function) {
			// the object implements a custom forEach method so use that
			object.forEach(block, context);
			return;
		} else if (typeof object == "string") {
			// the object is a string
			resolve = String;
		} else if (typeof object.length == "number") {
			// the object is array-like
			resolve = Array;
		}
		resolve.forEach(object, block, context);
	}
};



 ////  COMBINED FILE -- func.inc.js  ////// 
// JavaScript Document  

/* Equalizes height of div columns */
function equalize_columns(col1_id,col2_id) {
	
	if(!document.getElementById(col1_id) || !document.getElementById(col2_id)  ) {
		return false;	
	}
	var c1 = document.getElementById(col1_id);				
	var c2 = document.getElementById(col2_id);
	
    // c2.clientHeight = "150px";
	//window.alert(c2.clientHeight);
	if(c1.offsetHeight > c2.offsetHeight) {
	
		c2.style.height = c1.offsetHeight + 'px';
		//c2.morph('height:'+c1.offsetHeight + 'px;',{ queue: 'end'});
	}
	else {
		
		c1.style.height = c2.offsetHeight + 'px';
		//c1.morph('height:'+c2.offsetHeight + 'px;',{ queue: 'end'});
	}
	//window.alert(c2.offsetHeight);

}

/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
*    The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
*/
function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;
	
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";
	
	if(typeof(arr) == 'object') { //Array/Hashes/Objects 
		for(var item in arr) {
			var value = arr[item];
			
			if(typeof(value) == 'object') { //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value,level+1);
			} else {
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
		}
	} else { //Stings/Chars/Numbers etc.
		dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}


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 fnSelect(objId) {
	fnDeSelect();
	if (document.selection) {
	var range = document.body.createTextRange();
		range.moveToElementText(document.getElementById(objId));
	range.select();
	}
	else if (window.getSelection) {
	var range = document.createRange();
	range.selectNode(document.getElementById(objId));
	window.getSelection().addRange(range);
	}
}
	
function fnDeSelect() {
	if (document.selection) document.selection.empty(); 
	else if (window.getSelection)
			window.getSelection().removeAllRanges();
}


function showhide(switch_elem,target_elems,show_text,hide_text,limit) {
	
	if(!target_elems) {
		alert('no targets');
		return false;	
	}
	
	if (!target_elems.length) {
		
		var arr = new Array();
		
		arr[0] = target_elems;
		
		target_elems = arr;
			
	} 
	
		
	for(i=0; i<target_elems.length; i++) {
		
		if(limit) {
			if(limit < i) {
				break;
			}
		}
		target_elem = target_elems[i];
		
		if(target_elem.style) {
			
			if(target_elem.style.display == 'none') {
				target_elem.show();
				switch_elem.innerHTML = hide_text;
			} else {
				target_elem.hide();
				switch_elem.innerHTML = show_text;
			}
		}
	}
}

// Disables all other submit buttons (so they are not passed through POST via Ajax
// Page must be reloaded for the other buttons to reset themselves

function disableAllOtherSubmits(except) { 
// arg = EXCEPT for this submit button (presumably the clicked one)
	
	//alert('in dAS');
	
	inputs = $$('input');
	
	//alert(inputs);
	
	for(i=0; i<inputs.length; i++) {
		
		if( inputs[i] && inputs[i].type == 'submit') {
			//alert('found-a-submitbutton: '+inputs[i].value);
			
			if(inputs[i].value != except.value) {
				
				inputs[i].disabled = true;
				
			}
		}
	}

}

//selectAll
function selectAll(id_piece,toggle_me) {
	
	//substr_count( string haystack , string needle [, int offset [, int length]] )
	
	inputs = $$('input.checkbox');
	if(!inputs) {
		return false;
	}
	
	for(i=0; i< inputs.length; i++) {
		
		if (substr_count(inputs[i].getAttribute('id'),id_piece)) {
			
			inputs[i].checked = true;
			
			if(toggle_me) {
				
				var toggle_exists = true;
				var changeToggleText = 'Deselect All';
				
				if(toggle_me.innerHTML == 'Deselect All') {
					inputs[i].checked = false;
					changeToggleText = 'Select All';
				}
						
			
			}
		}
	}
	if(changeToggleText) {
		toggle_me.innerHTML = changeToggleText;	
	}
	
}


//selectBox for create pages
function showAllIfSelected(show_these,selectbox,select_text) {
	
	for(i=0; i<show_these.length; i++) {
		
		show_me = show_these[i];
		showIfSelected(show_me,selectbox,select_text);
	}
}
function showIfSelected(show_me,selectbox,select_text) {
	if(selectbox.options[selectbox.selectedIndex].text == select_text) { 
		show_me.style.display = 'block'; 
		//alert('should show');
	} 
	else { 
		show_me.style.display = 'none';
	    //alert('should hide');
	}
}

function hideAllIfEmpty(cssRule) {
	
	var elements = $$(cssRule);
	
	//alert(elements.length);
	
	for(i=0; i<elements.length; i++) {
		
		if (elements[i].innerHTML.blank()) {
			
			hide(elements[i]);	
		}
	}
	
}
function hide(element) {
	element.style.display = 'none';
}
function show(element) {
	element.style.display = 'block';	
}

// Function to allow one JavaScript file to be included by another.
function IncludeJavaScript(jsFile)
{
	newJS = document.createElement('script');
	newJS.type='text/javascript';
	newJS.src=jsFile;
	// Add the element to the end of the head, body, or any other tag HERE:
	document.getElementsByTagName('body')[0].appendChild(newJS);
}

function setMaxLength() {
	var x = document.getElementsByTagName('textarea');
	var counter = document.createElement('div');
	counter.className = 'counter';
	for (var i=0;i<x.length;i++) {
		if ( x[i].getAttribute('maxlength') ) {
			var counterClone = counter.cloneNode(true);
			counterClone.relatedElement = x[i];
			counterClone.innerHTML =
			'<span class="chars_typed">0</span> / <span class="chars_max">'+x[i].getAttribute('maxlength')+' chars max</span>';
			
			x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
			x[i].relatedElement = counterClone.getElementsByTagName('span')[0];

			x[i].onkeydown = x[i].onchange = checkMaxLength;
			x[i].onkeydown();
		}
	}
}

function checkMaxLength() {
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength)
		this.relatedElement.className = 'error'; //edit this class in your CSS file
	else
		this.relatedElement.className = '';
	this.relatedElement.firstChild.nodeValue = currentLength;
	// not innerHTML
}

//Pop-up windows
var win = null;
function NewWindow(mypage,myname,w,h,scroll,resize){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize;

win = window.open(mypage,myname,settings)
}

/*
Auto tabbing script- By JavaScriptKit.com
http://www.javascriptkit.com
*/

function autotab(original,destination){
	if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
	destination.focus()
}


function disableField(fieldname,disableIt) {
	
	fieldname.disabled = disableIt;
	
}

function showhideChildElements(Id_or_Element,vis) {
	
	//recursive function that shows or hides ALL descendents of an element
	
	if(vis == 'show') {
		vis_in_f = 'visible';	
	} else { vis_in_f = 'hidden'; }
	
	//check to see if func argument is an Element's Id (string) or an HTML object
	var mother = document.getElementById(Id_or_Element);
	if(!mother) {
		mother = Id_or_Element;	
	}
	
	
	for (var i = 0; i<mother.childNodes.length; i++) {
		var child = mother.childNodes[i];
		if(child.nodeType == 1) {
			child.style.visibility = vis_in_f;
			
		
			showhideChildElements(child,vis);
			
		}
	}
}

function substr_count( haystack, needle, offset, length ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: substr_count('Kevin van Zonneveld', 'e');
    // *     returns 1: 3
    // *     example 2: substr_count('Kevin van Zonneveld', 'K', 1);
    // *     returns 2: 0
    // *     example 3: substr_count('Kevin van Zonneveld', 'Z', 0, 10);
    // *     returns 3: false
 
    var pos = 0, cnt = 0;

    if(isNaN(offset)) offset = 0;
    if(isNaN(length)) length = 0;
    offset--;
 
    while( (offset = haystack.indexOf(needle, offset+1)) != -1 ){
        if(length > 0 && (offset+needle.length) > length){
            return false;
        } else{
            cnt++;
        }
    }
 
    return cnt;
}

function Gettime() {
var now = new Date();
//var currenthour = now.getHours();
//var currenttime = now.getMinutes();
//var currentdate = now.getDate();
//var offset = now.gettimezoneOffset();
document.write(now);
}




 ////  COMBINED FILE -- xfade2.js  ////// 
/*
	Image Cross Fade Redux
	Version 1.0
	Last revision: 02.15.2006
	steve@slayeroffice.com

	Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html
*/

window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init);

var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init()
{
	if(!d.getElementById || !d.createElement)return;

	css = d.createElement('link');
	css.setAttribute('href','slideshow2.css');
	css.setAttribute('rel','stylesheet');
	css.setAttribute('type','text/css');
	d.getElementsByTagName('head')[0].appendChild(css);
	
	if(d.getElementById('rotator')) {
		
		imgs = d.getElementById('rotator').getElementsByTagName('img');
		
		for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
		imgs[0].style.display = 'block';
		imgs[0].xOpacity = .99;
	
		setTimeout(so_xfade,4000);
	}
}

function so_xfade()
{
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;
	nOpacity = imgs[nIndex].xOpacity;

	cOpacity-=.05;
	nOpacity+=.05;

	imgs[nIndex].style.display = 'block';
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;

	setOpacity(imgs[current]);
	setOpacity(imgs[nIndex]);

	if(cOpacity<=0)
	{
		imgs[current].style.display = 'none';
		current = nIndex;
		setTimeout(so_xfade,3000);
	}
	else
	{
		setTimeout(so_xfade,50);
	}

	function setOpacity(obj)
	{
		if(obj.xOpacity>.99)
		{
			obj.xOpacity = .99;
			return;
		}

		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
	}
}