var OnKeyRequestBuffer = 
{
    bufferText: false,
     
    modified : function(elementId, callButtonId, searchOnKeyUp, bufferTime, e)
    {
                    // look for window.event in case event isn't passed in
        if (window.event) { e = window.event; }
        if (e.keyCode == 13)
        {
            if (typeof myTimer === "undefined"){}else{
                clearTimeout(myTimer);    
            } //check if var was declared if not set to nothing
            
            document.getElementById(callButtonId).click();
        }else if(searchOnKeyUp)
        {
            myTimer = setTimeout('OnKeyRequestBuffer.compareBuffer("'+elementId+'","'+xajax.$(elementId).value+'","'+callButtonId+'");', bufferTime);
        }
    },
    
    compareBuffer : function(elementId,strText,callButtonId)
    {       
        if (strText == xajax.$(elementId).value && strText != this.bufferText)
        {
            this.bufferText = strText;
            OnKeyRequestBuffer.makeRequest(elementId,callButtonId);
        }
    },
    
    makeRequest : function(elementId, callButtonId)
    {
        document.getElementById(callButtonId).click();
    }
}

//Submit On Enter
function submitEnter(buttonId,e)
{
    // look for window.event in case event isn't passed in
    if (window.event) { e = window.event; }
    if (e.keyCode == 13)
    {
        document.getElementById(buttonId).click();
    }
}

// function parameters are: field - the string field, count - the field for remaining
//characters  number and max - the maximum number of characters  
function countLeft(field, count, max)
{
    // if the length of the string in the input field is greater than the max value, trim it 
    if (field.value.length > max)
        field.value = field.value.substring(0, max);
    else
        // calculate the remaining characters  
        count.value = max - field.value.length;
}

function checkUncheckAll(theElement) {
    var theForm = theElement.form, z = 0;
    for(z=0; z<theForm.length;z++){
        if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
            theForm[z].checked = theElement.checked;
        }
    }
}

function checkUncheckSome(controller,theElements) {
	//Programmed by Shawn Olson
	//Copyright (c) 2006-2007
	//Updated on August 12, 2007
	//Permission to use this function provided that it always includes this credit text
	//  http://www.shawnolson.net
	//Find more JavaScripts at http://www.shawnolson.net/topics/Javascript/

	//theElements is an array of objects designated as a comma separated list of their IDs
	//If an element in theElements is not a checkbox, then it is assumed
	//that the function is recursive for that object and will check/uncheck
	//all checkboxes contained in that element

     var formElements = theElements.split(',');
	 var theController = document.getElementById(controller);
	 for(var z=0; z<formElements.length;z++){
	  theItem = document.getElementById(formElements[z]);
	  if(theItem.type){
	    if (theItem.type=='checkbox') {
	    	theItem.checked=theController.checked;
	    }
	  } else {
	  	  theInputs = theItem.getElementsByTagName('input');
	  for(var y=0; y<theInputs.length; y++){
	  if(theInputs[y].type == 'checkbox' && theInputs[y].id != theController.id){
	     theInputs[y].checked = theController.checked;
	    }
	  }
	  }
    }
}

//starter for the smooth gallery
function startGallery() {
	document.myGallerySet = new gallerySet($('myGallerySet'), {
		timed: false,
        embedLinks: false
	});
}

