// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function showLoadingImg(id){
var temp_HTML="<div style='margin-left:50px'><img src=/images/loading.gif></div>";
$(id).innerHTML=temp_HTML;
}

function checkMaxLength(textArea, relatedElementId) {
	var maxLength = textArea.getAttribute('maxlength');
	var currentLength = textArea.value.length;
	if (currentLength > maxLength)
		$(relatedElementId).className = 'toomuch';
	else
		$(relatedElementId).className = '';
	$(relatedElementId).firstChild.nodeValue = currentLength;
	// not innerHTML
}

function Lightbox(){var thisObj=this;var hideScrollbars=true;this.createOverlay=function(){if($('overlay')==null)
{var overlay=document.createElement('div');overlay.id='overlay';overlay.innerHTML=' ';document.body.appendChild(overlay);this.sizeOverlay();
//overlay.onclick=function(e){window.location=location.href;}
}
else
{this.sizeOverlay();$('overlay').show();}
if(this.hideScrollbars)
{htm=document.getElementsByTagName('html')[0];htm.style.overflow='hidden';document.body.style.overflow='hidden';}
window.onscroll=this.sizeOverlay;window.onresize=this.sizeOverlay;};this.sizeOverlay=function(){$('overlay').style.height=document.viewport.getHeight();$('overlay').style.top=thisObj.scrollHeight()+'px';};
this.close=function(id){$(id).hide();$('overlay').hide();if(this.hideScrollbars){document.body.style.overflow='auto';document.getElementsByTagName('html')[0].style.overflow='auto';}
this.showSelects();window.onscroll=null;window.onresize=null;$$('.flash').each(function(value, index){value.show();})};this.scrollHeight=function()
{var h=window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;return h?h:0;};
this.open=function(id)
{this.createOverlay();this.center(id);$(id).show();this.hideSelects();};this.center=function(id)
{el_w=$(id).getWidth();view_w=document.viewport.getWidth();left=Math.round((view_w-el_w)/2);$(id).style.left=left+'px';$(id).style.top=(this.scrollHeight()+100)+'px';$(id).style.overflow='hidden';};this.hideSelects=function()
{selects=$$('select');for(i=0;i<selects.length;i++){selects[i].hide();}};this.showSelects=function()
{selects=$$('select');for(i=0;i<selects.length;i++){selects[i].show();}};}
LB=new Lightbox();
