function print_r(theObj){
	if(theObj.constructor == Array || theObj.constructor == Object){
		("<ul>")
		for(var p in theObj){
			if(theObj[p].constructor == Array|| theObj[p].constructor == Object){
				("<li>["+p+"] => "+typeof(theObj)+"</li>");
				("<ul>")
				print_r(theObj[p]);
				("</ul>")
			} else {
				("<li>["+p+"] => "+theObj[p]+"</li>");
			}
		}
		("</ul>")
	}
}

function doAjaxToDiv( updateEl, url, progressImage ){
    if( progressImage != '' )
    {
        updateEl.style.display = 'block';
        updateEl.innerHTML = "<center><img src='" + progressImage + "' /></center>";
    }
    new $ajax( { method: 'GET', update: updateEl }, url );
}

function submitAjaxToDiv2( updateEl, url, progressImage, IDsubject, IDtipus_d_ens, IDaltre_tipus_d_ensName, IDaltre_tipus_d_ensValue, IDsender_name,  IDpersona_de_contacte, IDadreca, IDtelefon, IDemail, IDnom_de_la_produccio, IDnum_capitols, IDdurada, IDgenere, IDsinopsiName, IDsinopsiValue, ContentNodeID, ContentObjectID, ViewMode, ActionCollectInformation ){
	
    if( progressImage != '' )
    {
        updateEl.style.display = 'block';
        updateEl.innerHTML = "<center><img src='" + progressImage + "' /></center>";
    }

	//var elem = document.getElementById('ajaxForm');
	url+="?"+IDsubject.name+"="+IDsubject.value+"&"+IDtipus_d_ens.name+"="+IDtipus_d_ens.value+"&"+IDaltre_tipus_d_ensName+"="+IDaltre_tipus_d_ensValue+"&"+IDsender_name.name+"="+IDsender_name.value+"&"+IDpersona_de_contacte.name+"="+IDpersona_de_contacte.value+"&";
	url+=IDadreca.name+"="+IDadreca.value+"&"+IDtelefon.name+"="+IDtelefon.value+"&"+IDemail.name+"="+IDemail.value+"&"+IDnom_de_la_produccio.name+"="+IDnom_de_la_produccio.value+"&"+IDnum_capitols.name+"="+IDnum_capitols.value+"&";
	url+=IDdurada.name+"="+IDdurada.value+"&"+IDgenere.name+"="+IDgenere.value+"&"+IDsinopsiName+"="+IDsinopsiValue+"&";
	url+=ContentNodeID.name+"="+ContentNodeID.value+"&"+ContentObjectID.name+"="+ContentObjectID.value+"&"+ViewMode.name+"="+ViewMode.value+"&"+ActionCollectInformation.name+"="+ActionCollectInformation.value;	
	url+="&via=ajax";
	url=encodeURI(url);
	//alert(url);
	new $ajax( { method: 'GET', update: updateEl }, url );
}
						 
function submitAjaxToDiv( updateEl, url, progressImage, IDtitol, IDepisodeName, IDepisodeValue, IDemail, IDnumber,  IDwhere, IDfirstname, IDsurname, IDnif_cif, IDaddress, IDzipcode, IDcity, IDphone, IDobservationsName, IDobservationsValue, ContentNodeID, ContentObjectID, ViewMode, ActionCollectInformation ){
	
    if( progressImage != '' )
    {
        updateEl.style.display = 'block';
        updateEl.innerHTML = "<center><img src='" + progressImage + "' /></center>";
    }
	//var elem = document.getElementById('ajaxForm');
	url+="?"+IDtitol.name+"="+IDtitol.value+"&"+IDepisodeName+"="+IDepisodeValue+"&"+IDnumber.name+"="+IDnumber.value+"&"+IDemail.name+"="+IDemail.value+"&"+IDwhere.name+"="+IDwhere.value+"&"+IDfirstname.name+"="+IDfirstname.value+"&"+IDsurname.name+"="+IDsurname.value+"&";
	url+=IDnif_cif.name+"="+IDnif_cif.value+"&"+IDaddress.name+"="+IDaddress.value+"&"+IDzipcode.name+"="+IDzipcode.value+"&"+IDcity.name+"="+IDcity.value+"&"+IDphone.name+"="+IDphone.value+"&"+IDobservationsName+"="+IDobservationsValue+"&";	
	url+=ContentNodeID.name+"="+ContentNodeID.value+"&"+ContentObjectID.name+"="+ContentObjectID.value+"&"+ViewMode.name+"="+ViewMode.value+"&"+ActionCollectInformation.name+"="+ActionCollectInformation.value;	
	url+="&via=ajax";
	url=encodeURI(url);
	//alert(url);
	new $ajax( { method: 'POST', update: updateEl }, url );
}


function toggleDisabled( el )
{
    if(el.disabled)
    {
        el.disabled = false;
    } else {
        el.disabled = true;
    }
}

function enableIfChecked( el, checkbox )
{
    el.disabled = !checkbox.checked;
}

function switchEnabledClass( el, classEnabled, classDisabled )
{
    if( el.disabled ) el.className = classDisabled;
        else el.className = classEnabled;
}

function isScrollBottom( el )
{
    isBottom = false;
    elHeight = parseInt( el.offsetHeight );
    
    if( elHeight + el.scrollTop > el.scrollHeight )
    {
        isBottom = true;
    }
    return isBottom;
}

function enableOnScroll( disabledEl, scrollEl )
{
    if( isScrollBottom( scrollEl ) )
    {
        disabledEl.disabled = false;
    }
}

function addOptionToSelect(origin, target)
{
    option = origin.options[origin.selectedIndex];
    if( target.options[target.options.length] = new Option(option.text, option.value) )
    {
        origin.options[origin.selectedIndex] = null;
    }
}

function prioritizeOption(select)
{
    if(select.options.length > 1 && select.selectedIndex > 0)
    {
        optionIndex = select.selectedIndex;
        option = select.options[optionIndex];
        supOptionIndex = select.selectedIndex - 1;
        supOption = select.options[supOptionIndex];
        select.options[optionIndex] = new Option(supOption.text, supOption.value);
        select.options[supOptionIndex] = option;
    }
}

function dePrioritizeOption(select)
{
    if(select.options.length > 1 && select.selectedIndex < select.options.length - 1)
    {
        optionIndex = select.selectedIndex;
        option = select.options[optionIndex];
        supOptionIndex = select.selectedIndex + 1;
        supOption = select.options[supOptionIndex];
        select.options[optionIndex] = new Option(supOption.text, supOption.value);
        select.options[supOptionIndex] = option;
    }
}

function cambiarBanners(nextIndice){
	for (indiceBanners=0; indiceBanners<countBanners; indiceBanners++){
		document.getElementById("href"+indiceBanners).href = bannerArray[nextIndice][0];
		document.getElementById("href"+indiceBanners).title = bannerArray[nextIndice][1];
		document.getElementById("image"+indiceBanners).src = bannerArray[nextIndice][2];
		document.getElementById("image"+indiceBanners).width = bannerArray[nextIndice][3];
		document.getElementById("image"+indiceBanners).height = bannerArray[nextIndice][4];
		shownIndex = nextIndice;
		nextIndice++;
		if (nextIndice + 1 > totalBanners){
			nextIndice = 0;
		}
	}
	
	setTimeout("cambiarBanners("+shownIndex+")",tiempoDemora);
}

