/*
    Utility function for attaching an event handler to a target element.  Note that this function is intended
    to be used by skeleton and skin developers, NOT by content developers.
*/
function wlp_bighorn_attachEventHandler(target, type, handler)
{
    var result = false;
    if (target.addEventListener)
    {
        target.addEventListener(type, handler, false);
        result = true;
    }
    else if (target.attachEvent)
    {
        result = target.attachEvent("on" + type, handler);
    }
    else
    {
        var name = "on" + type;
        var old = (target[name]) ? target[name] : function() {};
        target[name] = function(e) { old(e); handler(e) };
        return true;
    }
    return result;
}

/*
    Utility function to add a class name to a target element.  This function is intended for use by skin
    developers to help facilitate adding behaviors to elements.
*/
function wlp_bighorn_addClassName(target, name)
{
    target.className += (target.className ? ' ' : '') + name;
}

/*
    Utility function to remove a class name to a target element.  This function is intended for use by skin
    developers to help facilitate adding behaviors to elements.
*/
function wlp_bighorn_removeClassName(target, name)
{
    var regex = new RegExp(" ?" + name + "$");
	target.className = target.className.replace(regex, '');
}

function buscar()
{
	var url = "";
	var selectBusqueda=document.getElementById('selectBuqueda');
	var txtBusqueda = document.getElementById('txtBusqueda');
	if(txtBusqueda.value=='')
	{
		
	}
	
	else
	{	
		if(selectBusqueda.selectedIndex==0)
		{	
			url = "/?_nfpb=true&_pageLabel=resultadosBusqueda&cx=017746900046189346808:x45mihjeqeu&cof=FORID%3A10&ie=UTF-8&q=";
			url = url + txtBusqueda.value;
			location.href=url;
		}
		else
		{
			url="http://www.google.cl/#hl=es&source=hp&q="
			url = url + txtBusqueda.value;
			window.open(url);
		}
	}
}

function esTeclaEnter(e){
	var esIE=(document.all);
	var esNS=(document.layers);
	tecla=(esIE) ? event.keyCode : e.which;
	if(tecla==13){
		buscar();
  }
}

function quitaCaracter( cadena,caracter ) {
	var oAux = new String('');
	var oRut = new String(cadena);
	var ch, j, k
	var oStr = oRut ; //oRut.substring(0, i );
	j = oStr.length ;

	for(k=0;k<=j;k=k+1){
		ch = oStr.charAt(k);
		if (ch!=caracter) {
			oAux = oAux + ch ;
		}
	}
	//ruty = oAux;
	return oAux;
}

function Trim(Cadena){
	Cadena = Cadena.replace( /^\s*/, "" ); //quita los espacios a la iazquierda
	Cadena = Cadena.replace( /\s*$/, "" ); //quita los espacios a la derecha
	return Cadena;
} 

function title(title)
{
	document.title = title;
}

function boton(atributoForm , atributoThis, atributoEvent, atributoWeek){
	
	//alert("semana "+Week +" con Fecha de Inicio = "+fechaInicio+" y Fecha Fin = "+fechaFin + "id " + numeroSemana);
	iceSubmitPartial2(atributoForm , atributoThis, atributoEvent);
	
	return false;
}


function iceSubmitPartial2(C,B,A,D){
		
		C=(C?C:B.form);
		
		if(!D){
			D=new Ice.Parameter.Query();
		}
		
		D.add("ice.submit.partial",false);
			$event(A,B).serializeOn(D);
		
		if(C&&C.id){
			$element(C).serializeOn(D);
		}
		
		if(B&&B.id){
			var E=$element(B);
				if(E.isSubmit()){
					E.serializeOn(D);
				}
		}
		D.sendOn(currentConnection($element(C),$element(B)));
		resetHiddenFieldsFor(C);
			
		return false;
}




