/*** Auditiv CallByCall sitefuncs.js :: 2008 :: copyright @ callbycall.auditiv.org ***/
var d=document;
 window.defaultStatus="Auditiv CallByCall";
 window.ondblclick=new Function("return false");
 function frameless(){if(top.frames.length > 0){top.location.href=self.location;}}
/* frameless(); */
function newwin(url,width,height,parameter){if(!width)width=700; if(!height)height=500; if(!parameter)parameter="resizable, scrollbars, menubar";
 nF=window.open(url,"nF","width="+width+",height="+height+","+parameter+""); nF.focus();
 }
function salga(e){if(e.style.display=='block'){e.style.display='none';}else{e.style.display='block';}
}
function addEngine(name,ext,cat,type){if ((typeof window.sidebar=="object")&& (typeof window.sidebar.addSearchEngine=="function")){window.sidebar.addSearchEngine(
"http://mycroft.mozdev.org/external.php/" + name + ".src",
"http://mycroft.mozdev.org/external.php/" + name + "."+ ext, name, cat );
 }else{alert("You will need a Mozilla based browser to install a search plugin.");
 }
}
function addFavorit(p){if(ie && ver >= 4 && !mac){window.external.AddFavorite(location.href,document.title);}else if (opera || gecko){p.title=document.title; alert(lz_drag);}else{alert(lz_tastatur);}window.external.AddFavorite(location.href,document.title);return false;}
function changeCSS(srcName,tarName){var obj=getElementsByClassName(srcName); for(i=0;i<obj.length;i++){obj[i].className=tarName;}}
function getElementsByClassName(class_name){var all_obj,ret_obj=new Array(),j=0; if(document.all)all_obj=document.all; else if(document.getElementsByTagName && !document.all)all_obj=document.getElementsByTagName("*");for(i=0;i<all_obj.length;i++){if(all_obj[i].className==class_name){ret_obj[j]=all_obj[i]; j++}}return ret_obj;}
/* AJAX functions */
var RequestIsRunning=false; 
var RequestTimeout=500; 
function RequestTimedout(){RequestIsRunning=false;};
 function init_page(){}
function showLoad (){$("load").style.display="block"; RequestIsRunning=true;}
function hideLoad (){$("load").style.display="none"; RequestIsRunning=false;}
function reset_err_msg(){}
function update_layer(element,data){$(element).innerHTML=data;}
function update_layer_get(element,url,pars){var myAjax=new Ajax.Updater( element,url,{method: 'get', parameters: pars,
onLoading: showLoad,
onComplete: hideLoad,
evalScripts: true});
 return false;
 }
function update_layer_post(element,url,pars){var myAjax=new Ajax.Updater( element,url,{method: 'post', parameters: pars, 
onLoading: showLoad,
onComplete: hideLoad,
evalScripts: true});
 return false;
 }
function bookmark_page(){$('menuinfo').innerHTML='Bookmarked';
 $('menuinfo').style.display="block";
 setTimeout("$('menuinfo').style.display='none'", 2000);
 return false;
 }
function ismaxlength(obj){var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")): ""
if (obj.getAttribute && obj.value.length>mlength)obj.value=obj.value.substring(0,mlength)}
function setPointer(theRow, theRowNum, theAction, theDefaultColor){var thePointerColor="#dddddd";
 var theMarkColor="#cccccc";
 var theCells=null;
 var marked_row=[];
 if (typeof(theRow.style)=='undefined'){alert("row style undefined"); return false;}
if (theAction=="over" || theAction=="click"){theRow.style.cursor='pointer';}else{theRow.style.cursor='default';}
if (typeof(document.getElementsByTagName)!= 'undefined'){theCells=theRow.getElementsByTagName('td');}
else if (typeof(theRow.cells)!= 'undefined'){theCells=theRow.cells;}
else{alert("theCells undefined"); return false;}
var rowCellsCnt=theCells.length;
 var domDetect =null; var currentColor=null; var newColor =null;
 if (typeof(window.opera)=='undefined' && typeof(theCells[0].getAttribute)!= 'undefined'){currentColor=theCells[0].getAttribute('bgcolor');
 domDetect =true;
 }
else{currentColor=theCells[0].style.backgroundColor;
 domDetect =false;
 }
if (currentColor.indexOf("rgb")>= 0){var rgbStr=currentColor.slice(currentColor.indexOf('(')+ 1, currentColor.indexOf(')'));
 var rgbValues=rgbStr.split(",");
 currentColor="#";
 var hexChars="0123456789ABCDEF";
 for (var i=0; i < 3; i++){var v=rgbValues[i].valueOf();
 currentColor += hexChars.charAt(v/16)+ hexChars.charAt(v%16);
 }
}
if (currentColor=='' || currentColor.toLowerCase()==theDefaultColor.toLowerCase()){if (theAction=='over' && thePointerColor != ''){newColor =thePointerColor;
 }
else if (theAction=='click' && theMarkColor != ''){newColor =theMarkColor;
 marked_row[theRowNum]=true;
 }
}
else if (currentColor.toLowerCase()==thePointerColor.toLowerCase()&& (typeof(marked_row[theRowNum])=='undefined' || !marked_row[theRowNum])){if (theAction=='out'){newColor =theDefaultColor;
 }
else if (theAction=='click' && theMarkColor != ''){newColor =theMarkColor;
 marked_row[theRowNum]=true;
 }
}
else if (currentColor.toLowerCase()==theMarkColor.toLowerCase()){if (theAction=='click'){newColor =(thePointerColor != '')? thePointerColor
: theDefaultColor;
 marked_row[theRowNum]=(typeof(marked_row[theRowNum])=='undefined' || !marked_row[theRowNum])? true
: null;
 }
}
if (newColor){var c=null;
 if (domDetect){for (c=0; c < rowCellsCnt; c++){theCells[c].setAttribute('bgcolor', newColor, 0);
 }
}
else{for (c=0; c < rowCellsCnt; c++){theCells[c].style.backgroundColor=newColor;
 }
}
}
return true;
 }
/*** --- simplefaq --- ***/
var sfaq_open=false;
 function sfaq_show(e){if( $(e).style.display=="block" ){$(e).style.display= "none"; $(e+"q").className="faqtitle";}else{if(sfaq_open){$(sfaq_open).style.display= "none"; $(sfaq_open+"q").className= "faqtitle";}
$(e+"q").className="faqtitle-act";
 $(e).style.display= "block"; sfaq_open=e;}
$(e).blur();
 }
/*** --- linklab --- ***/
/*** --- users --- ***/
function usertooltip(element){x=(document.all)? window.event.x + document.body.scrollLeft : $(element).pageX;
 y=(document.all)? window.event.y + document.body.scrollTop : $(element).pageY;
 if($(element).style.display=="block")$(element).style.display="none";
 else{$(element).style.left=(x-50)+"px";
 $(element).style.top=(y+5)+"px";
 $(element).style.display="block";
 }
}
function uProfile(uid){newwin("http://callbycall.auditiv.org/acceso/userProfile.php?uid=" + uid + "", "400", "550", "resizable,scrollbars");
 }
function uMsg(uid){newwin("http://callbycall.auditiv.org/acceso/userMailU2U.php?toUser=" + uid + "", "600", "450", "resizable,scrollbars");
 }
/*** --- callbycall --- ***/
function avisolegal(){newwin('http://callbycall.auditiv.org/avisolegal.php');
 }
function check_paytype(typ){if(typ=="PP"){$("paytype_PP").style.display ="block";
 $("paytype_BA").style.display ="none";
 $("paytype_CC").style.display ="none";
 }
if(typ=="BC"){$("paytype_PP").style.display="none";
 $("paytype_BA").style.display="block";
 $("paytype_CC").style.display="none";
 }
if(typ=="CC"){$("paytype_PP").style.display="none";
 $("paytype_BA").style.display="none";
 $("paytype_CC").style.display="block";
 }
}
function get_detail_contrato(contrato){if($("d"+contrato).style.display=="block")$("d"+contrato).style.display ="none";
 else{update_layer_get( "d"+contrato , "http://callbycall.auditiv.org/_inc/ajax.updater.inc.php" , "cbc_detail_contrato=" + contrato );
 $("d"+contrato).style.display="block";}
}
/*** --- contabilidad --- ***/
function cambia_fechas(){var df=document.filtros;if(df.mesc.value!="0"){a=2008; m=11;
 if(m<df.mesc.value){a--};
 df.fd.value=a+"-"+df.mesc.value+"-01"; df.fa.value=a+"-"+df.mesc.value+"-31";
 }
}
function cambia_fechas_T(){var df=document.filtros;
 var dt= df.mest.value
if(dt!="0"){a=2008; p=2007;
 if( dt== "T-1"){desde=p+"-01-01"; hasta=p+"-03-31";}
if( dt== "T-2"){desde=p+"-04-01"; hasta=p+"-06-31";}
if( dt== "T-3"){desde=p+"-07-01"; hasta=p+"-10-31";}
if( dt== "T-4"){desde=p+"-10-01"; hasta=p+"-12-31";}
if( dt== "T1"){desde=a+"-01-01"; hasta=a+"-03-31";}
if( dt== "T2"){desde=a+"-04-01"; hasta=a+"-06-31";}
if( dt== "T3"){desde=a+"-07-01"; hasta=a+"-10-31";}
if( dt== "T4"){desde=a+"-10-01"; hasta=a+"-12-31";}
df.fd.value= desde; df.fa.value= hasta;
 }
}
function selfichero (formname){mes=$(formname).mes.value;
 ano=$(formname).ano.value;
 fichero=$(formname).oldfichero.value;
 path=ano + "/" + mes;
 update_layer_get("selfichero", "http://callbycall.auditiv.org/_inc/ajax.updater.inc.php", "fichero=" + fichero + "&selficheropath=" + path);
 }
function openselfichero (formname){fichero=$(formname).fichero.value;
 if(fichero!="0" && fichero!=""){dir="http://callbycall.auditiv.org/uploads/contabilidad/";
 mes=$(formname).mes.value;
 ano=$(formname).ano.value;
 path=dir + ano + "/" + mes + "/" + fichero;
 newwin(path,"800","600","resizable,scrollbars,location,menubar");
 }
}