﻿function carga_url (URL,capa) {
        $(document.getElementById(capa)).html('');
          $(document.getElementById(capa)).load(URL,function(){
                $(document.getElementById(capa)).fadeIn("slow");
                //datos=preloaderOff();
          });
}

function msgChange (capa,htmltext) {
        $(document.getElementById(capa)).html(htmltext);
}

function capasDisplay (capa,status,mode) {      
        if (mode==undefined || mode=='') {
                mode="display"; 
        }
		if (document.getElementById(capa)!=undefined || mode!='') {
			if (status!=undefined && status!='') {
				 document.getElementById(capa).style[mode]=status;
			} else {
					if (document.getElementById(capa).style[mode]=="block") {
							document.getElementById(capa).style[mode]="none";
					} else {
							document.getElementById(capa).style[mode]="block";
					}
			}
		}
}

function display_capas (capa,status) {  
        if (status!=undefined && status!='') {
                document.getElementById(capa).style.display=status;
        } else {
                if (document.getElementById(capa).style.display=="block") {
                        document.getElementById(capa).style.display="none";
                } else {
                        document.getElementById(capa).style.display="block";
                }
        }
}

function visible_capas (capa,status) {  
        if (status!=undefined && status!='') {
                document.getElementById(capa).style.visibility=status;
        } else {
                if (document.getElementById(capa).style.visibility=="visible") {
                        document.getElementById(capa).style.visibility="hidden";
                } else {
                        document.getElementById(capa).style.visibility="visible";
                }
        }
}



function giveCSS (capa,clase,htmlelement) {
        $(htmlelement,document.getElementById(capa)).addClass(clase);
}

function giveCSSId (capa,clase) {
    $(document.getElementById(capa)).addClass(clase);
}

function removeCSS (capa,clase,htmlelement) {
        $(htmlelement,document.getElementById(capa)).removeClass(clase);
}
function removeCSSId (capa,clase) {
    $(document.getElementById(capa)).removeClass(clase);
}

scrollSteps = 10
timer=""

function scrollWin(id){
        clearTimeout(timer)
        frame=window.parent;
        doc=frame.document.body
        obj=frame.document.getElementById(id)

        if(doc.scrollTop <= obj.offsetTop-scrollSteps){
                frame.scrollBy(0,scrollSteps)
                timer=setTimeout("scrollWin('"+id+"')",10)

                if(doc.scrollTop>(doc.scrollHeight-doc.clientHeight)-scrollSteps){ // if bottom of page reached before anchor point
                        clearTimeout(timer)
                        doc.scrollTop=doc.scrollHeight-doc.clientHeight
                }

        } else{
                if(doc.scrollTop >= obj.offsetTop+scrollSteps){
                        frame.scrollBy(0,-scrollSteps)
                        timer=setTimeout("scrollWin('"+id+"')",10)
                } else{
                        clearTimeout(timer)
                        doc.scrollTop=obj.offsetTop
                }
        }
}
