// XSM: // Rev. 2.0002 // 15-02-2010 function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } function addonresizevent() { } var div_wait_name='' var dragapproved=false var minrestore=0 var initialwidth,initialheight var ie5=document.all&&document.getElementById var ns6=document.getElementById&&!document.all var div_es_mou='' function f_scrollTop() { var ScrollTop = document.body.scrollTop; if (ScrollTop == 0) { if (window.pageYOffset) ScrollTop = window.pageYOffset; else ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0; } return ScrollTop; } function tamany_body(){ var myWidth = 0, myHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } return {w : myWidth, h : myHeight};; } function mides(){ if (window.innerHeight && window.scrollMaxY) {// Firefox yWithScroll = window.innerHeight + window.scrollMaxY; xWithScroll = window.innerWidth + window.scrollMaxX; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac yWithScroll = document.body.scrollHeight; xWithScroll = document.body.scrollWidth; } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari yWithScroll = document.body.offsetHeight; xWithScroll = document.body.offsetWidth; } return {w : xWithScroll, h : yWithScroll};; } function ajustar_div_opacogeneral(opaco){ var el_div = document.getElementById('opacogeneral'+opaco); el_div.style.width=mides().w; el_div.style.height=mides().h; } function crear_div_opacogeneral(opaco,opacitat){ var newone = document.createElement("div"); newone.id='opacogeneral'+opaco; newone.style.display='block'; newone.style.position="absolute"; newone.style.backgroundColor="#000000"; newone.style.top=0; newone.style.left=0; if (navigator.userAgent.indexOf("Firefox")!=-1) { newone.style.width=mides().w-18; } else { newone.style.width=mides().w; } newone.style.height=mides().h;//-6; opacitat2=(parseFloat(opacitat)/100) newone.style.opacity=opacitat2 newone.style.filter='alpha(opacity='+opacitat+')' document.body.appendChild(newone); window.onresize = function() { ajustar_div_opacogeneral(opaco); } } function iecompattest(){ return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } function drag_drop(e){ if (ie5&&dragapproved&&event.button==1){ document.getElementById(div_es_mou).style.left=tempx+event.clientX-offsetx+"px" document.getElementById(div_es_mou).style.top=tempy+event.clientY-offsety+"px" } else if (ns6&&dragapproved){ document.getElementById(div_es_mou).style.left=tempx+e.clientX-offsetx+"px" document.getElementById(div_es_mou).style.top=tempy+e.clientY-offsety+"px" } } function initializedrag(e,div_nom){ offsetx=ie5? event.clientX : e.clientX offsety=ie5? event.clientY : e.clientY tempx=parseInt(document.getElementById(div_nom).style.left) tempy=parseInt(document.getElementById(div_nom).style.top) dragapproved=true div_es_mou=div_nom document.getElementById(div_nom).onmousemove=drag_drop; } function ampliar_flotant(div_nom,height){ initialheight=height document.getElementById(div_nom).style.height=height+"px" } function posicionar_window(div_nom,align){ // posibilitats de align // l --> left // t --> top align=align.toLowerCase(); align=align.substring(0,1); if (align='l') { document.getElementById(div_nom).style.left=((document.body.offsetWidth-initialwidth)/2); } if (align='t') { document.getElementById(div_nom).style.top=((document.body.ScrollHeight-initialheight)/2); } } function loadwindowfinish(){ document.getElementById(div_wait_name+'contentframe').style.top=0; document.getElementById(div_wait_name+'contentframe').style.height=document.getElementById(div_wait_name+'content').style.height; document.getElementById(div_wait_name+'contentframe').style.visibility='visible'; document.getElementById(div_wait_name+'waitframe').style.display='none'; } function loadwindow(div_nom,left,top,width,height,mostrar){ if (mostrar=='S') { if (document.getElementById('opacogeneral'+div_nom)==null) { crear_div_opacogeneral(div_nom,'50'); bringToFront('opacogeneral'+div_nom) } // if (document.getElementById("opacogeneral")!=null) { // alert('ja hi es'); // crear_div_opacogeneral('2','75'); // bringToFront('opacogeneral2') // } else { // crear_div_opacogeneral('','50'); // bringToFront('opacogeneral') // } } // Sustituides les variables // initialwidth per .tag // initialheight per .tag2 document.getElementById(div_nom).tag=width initialwidth=width document.getElementById(div_nom).tag2=height initialheight=height document.getElementById(div_nom).style.visibility='visible' document.getElementById(div_nom).style.display='' document.getElementById(div_nom).style.width=width+"px" document.getElementById(div_nom).style.height=height+"px" document.getElementById(div_nom+"content").style.height=height-20; document.getElementById(div_nom+"contentframe").style.height=height-20; div_wait_name=div_nom if (left<0) { if (left==-1) { left=(document.body.offsetWidth-initialwidth)/2 // Genera un event de Onresize per posicionat al centre la finestra //window.onresize = function() //{ //posicionar_window(div_nom,'l'); //} } else { left=((document.body.offsetWidth-initialwidth)/2)+Math.abs(left); } } document.getElementById(div_nom).style.left=left; if (top==-1) { top=f_scrollTop()+10; // Genera un event de Onresize per posicionat al mig la finestra //window.onresize = function() //{ //posicionar_window(div_nom,'t'); //} } document.getElementById(div_nom).style.top=top; bringToFront(div_nom) // guardar_apariencia(div_nom); } function guardar_apariencia(div_nom){ if (document.getElementById('frameacciones')!=null){ var valor valor = div_nom +'|' valor = valor + document.getElementById(div_nom).style.left +'|' valor = valor + document.getElementById(div_nom).style.top +'|' valor = valor + document.getElementById(div_nom).tag +'|' valor = valor + document.getElementById(div_nom).tag2 +'|' // Sustituides les variables // initialwidth per .tag // initialheight per .tag2 // valor = valor + initialwidth +'|' // valor = valor + initialheight +'|' if (document.getElementById(div_nom).style.height!='10px'){ valor = valor + 'N|' } else { valor = valor + 'S|' } if ((document.getElementById(div_nom).style.display!='none') || (document.getElementById(div_nom).style.visibility=='visible')){ valor = valor + 'S|' } else { valor = valor + 'N|' } // document.getElementById('frameacciones').src='/includes/guardar/home.asp?v='+valor } } function plegar(div_nom,el_width){ if (document.getElementById(div_nom).style.height!='10px'){ minrestore=1 document.getElementById(div_nom+"buto").setAttribute("src","/imagenes/v11/finestres/obrir.gif"); document.getElementById(div_nom+"content").style.height=0; document.getElementById(div_nom+"content").style.visibility='hidden'; document.getElementById(div_nom).style.height=10; if (el_width!=null){ document.getElementById(div_nom).style.width=el_width; } else { document.getElementById(div_nom).style.width=250; } } else { minrestore=0 document.getElementById(div_nom+"buto").setAttribute("src","/imagenes/v11/finestres/tancar.gif"); document.getElementById(div_nom).style.width=document.getElementById(div_nom).tag; document.getElementById(div_nom).style.height=document.getElementById(div_nom).tag2; // document.getElementById(div_nom).style.width=initialwidth; // document.getElementById(div_nom).style.height=initialheight; document.getElementById(div_nom+"content").style.visibility='visible'; document.getElementById(div_nom+"content").style.height=initialheight-20; } // guardar_apariencia(div_nom); } function plegar_fix(div_nom){ if (document.getElementById(div_nom+"content").style.visibility!='hidden'){ document.getElementById(div_nom+"buto").setAttribute("src","/imagenes/v11/finestres/obrir.gif"); document.getElementById(div_nom+"content").style.height=0; document.getElementById(div_nom+"content").style.visibility='visible'; // document.getElementById(div_nom).style.height=10; } else { document.getElementById(div_nom+"buto").setAttribute("src","/imagenes/v11/finestres/tancar.gif"); // document.getElementById(div_nom).style.height="auto"; document.getElementById(div_nom+"content").style.visibility='hidden'; document.getElementById(div_nom+"content").style.height="auto"; } // guardar_apariencia(div_nom); // $('#cuerpo_2').jScrollPane({showArrows:true}); if (window.CSBfleXcroll) {CSBfleXcroll('cuerpo_2');} } function plegar_tot(div_nom){ if (document.getElementById(div_nom).style.height!='1px'){ minrestore=1 document.getElementById(div_nom+"buto").setAttribute("src","/imagenes/v11/finestres/obrir.gif"); document.getElementById(div_nom).style.height=1; document.getElementById(div_nom).style.visibility='hidden'; } else { minrestore=0 document.getElementById(div_nom+"buto").setAttribute("src","/imagenes/v11/finestres/tancar.gif"); document.getElementById(div_nom).style.height="auto"; document.getElementById(div_nom).style.visibility='visible'; } // $('#cuerpo_2').jScrollPane({showArrows:true}); if (window.CSBfleXcroll) {CSBfleXcroll('cuerpo_2');} } function tancar(div_nom){ if (document.getElementById(div_nom)!=null) { document.getElementById(div_nom).style.visibility='hidden' document.getElementById(div_nom).style.display='none' } if (document.getElementById(div_nom+"contentframe")!=null) { document.getElementById(div_nom+"contentframe").src=''; } if (document.getElementById('opacogeneral'+div_nom)!=null) { document.body.removeChild(document.getElementById('opacogeneral'+div_nom)); } // if (document.getElementById("opacogeneral2")!=null) { // document.body.removeChild(document.getElementById("opacogeneral2")); // } else { // if (document.getElementById("opacogeneral")!=null) { // document.body.removeChild(document.getElementById("opacogeneral")); // } // } // guardar_apariencia(div_nom); } function stopdrag(div_nom){ dragapproved=false; div_es_mou=''; document.getElementById(div_nom).onmousemove=null; // guardar_apariencia(div_nom); } function getAbsoluteDivs() { var arr = new Array(); var all_divs = document.body.getElementsByTagName("div"); var j = 0; for (i = 0; i < all_divs.length; i++) if (all_divs.item(i).style.position=='absolute') { arr[j] = all_divs.item(i); j++; } return arr; } function bringToFront(id) { if (!document.getElementById || !document.getElementsByTagName) return; var obj = document.getElementById(id); var divs = getAbsoluteDivs(); var max_index = 0; var cur_index; // Compute the maximal z-index of // other absolute-positioned divs for (i = 0; i < divs.length; i++) { var item = divs[i]; if (item == obj || item.style.zIndex == '') continue; cur_index = parseInt(item.style.zIndex); if (max_index < cur_index) { max_index = cur_index; } } obj.style.zIndex = max_index + 1; } function bringToFrontObj(obj) { var divs = getAbsoluteDivs(); var max_index = 0; var cur_index; for (i = 0; i < divs.length; i++) { var item = divs[i]; if (item == obj || item.style.zIndex == '') continue; cur_index = parseInt(item.style.zIndex); if (max_index < cur_index) { max_index = cur_index; } } obj.style.zIndex = max_index + 1 } function sendToBack(id) { if (!document.getElementById || !document.getElementsByTagName) return; var obj = document.getElementById(id); var divs = getAbsoluteDivs(); var min_index = 999999; var cur_index; if (divs.length < 2) return; // Compute the minimal z-index of // other absolute-positioned divs for (i = 0; i < divs.length; i++) { var item = divs[i]; if (item == obj) continue; if (item.style.zIndex == '') { min_index = 0; break; } cur_index = parseInt(item.style.zIndex); if (min_index > cur_index) { min_index = cur_index; } } if (min_index > parseInt(obj.style.zIndex)) { return; } obj.style.zIndex = 1; if (min_index > 1) return; var add = min_index == 0 ? 2 : 1; for (i = 0; i < divs.length; i++) { var item = divs[i]; if (item == obj) continue; item.style.zIndex += add; } }