// JavaScript Document

function fillChildSelect(parentSel,childName,toggleParent,emptyText)
{
	var f = parentSel.form;
	if(!emptyText) emptyText = ' ';
	if(typeof getChildValues == 'function') { 
		var values = getChildValues(parentSel.value);
		if(f.elements[childName] != null )
		{
			var cSel = f.elements[childName];
			cSel.options.length = 0;
			if( parentSel.value.length > 0 && typeof(values) == 'object' && values.length > 0 )
			{
				if(toggleParent) cSel.parentNode.className = '';
				else cSel.className = '';
				for(var i=0;i<values.length;i++)
				{
					cSel[i] = new Option(decodeURIComponent(values[i][1]),values[i][0]);
				}			
			}
			else
			{
				if(toggleParent) cSel.parentNode.className = 'hide';
				else cSel.className = 'hide';
				cSel[0] = new Option('- ' + emptyText + ' -','');
			}
		}
	
	} 	
}

function winOpen( url, target, features, event )
{
	var winWidth = 100;
	var winHeight = 100;
	var posX = 5;
	var posY = 5;
	var newFeatures = features;
	var windowX = screen.availWidth;
	var windowY = screen.availHeight - 50;
	if( event != null )
	{
		regExp = features.match( /,?width=(\d+),?/ );
		regExp2 = features.match( /,?height=(\d+),?/ );
		if( regExp )
			winWidth = parseInt( regExp[1] );
		
		if( regExp2 )
			winHeight = parseInt( regExp2[1] );
		
		if( winWidth + parseInt( event.clientX ) + 15 <= windowX )
			posX =  parseInt( event.clientX ) + 15;
		else
			posX = event.clientX - ( winWidth + 20 ) ;
			
		if( winHeight + parseInt( event.clientY ) <= windowY )
			posY = parseInt( event.clientY );
		else
			posY = windowY - winHeight; 	
	
		newFeatures = 'width=' + winWidth + ',height=' + winHeight + ',left=' + posX + ',top=' + posY;
		if( features.indexOf( 'scrollbars' ) > -1 )
			newFeatures += ',scrollbars=1';
		if (features.indexOf('resizable') > -1 )
			newFeatures += ',resizable=1';
		if (features.indexOf('status') > -1 )
			newFeatures += ',status=1';
	}
	var win = window.open( url, target, newFeatures );
	win.focus();
}

function preCarga()
{
  var args = preCarga.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0,l=args-length; i<l; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

function effectHide(elem)
{
	$('#' + elem).hide('fast');
}

function detectEnter(e,btn)
{
	tecla = (document.all) ? e.keyCode : e.which;
 	if (tecla==13){
		if( !btn )	$("a.lupa").click();
		else document.getElementById(btn).click();
	}
	
	return false; 
}
