window.onerror=function(a,b,c){
if(encodeURIComponent){
a="msg="+encodeURIComponent(a)+"&url="+encodeURIComponent(b)+"&userAgent="+encodeURIComponent(navigator.userAgent)+"&line="+c+"&scriptName="+scriptName;
//AJAX("post","/errors/Error.Java.asp",a);
return true}
return false};
// JavaScript Document
$(function(){
$('.FRMBtn').button();
})
function pageRS(u,p,d){
var div='divUser';
if(d)
if(d!='') div=d;
$.scrollTo('#mapHotelAnchor',800, {onAfter: function(){ AJAX('get',u,p,div) }});
}
function removeHTMLTags(strInputCode){
var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
return (strTagStrippedText);
}
function slideDiv(div){
if($('#'+div).css('display')=='none')
$('#'+div).slideDown('slow');
else
$('#'+div).slideUp('fast');
}
jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", ($(window).height() - this.height()) / 2+$(window).scrollTop() + "px");
this.css("left", ($(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
return this;
}
var TimeOutError;
function closeError(){
$("#dialog").dialog("destroy");
//$("#dialog").hide()
}
function ShowTimePicking(obj){
$(function() {
$("#dialog").html(AJAX('post','/includes/Time.Selection.asp','Time=' + obj.value + '&objId=' + obj.id))
$("#dialog").dialog({
closeOnEscape: true,
title: 'Seleccionar Hora',
modal: true,
width: 320,
height: 'auto',
close: function(event, ui) { $("#dialog").dialog("destroy")}
});
});
}
var TimeOutError;
function ShowErrorDelay(title,err){
closeError();
if(TimeOutError){clearTimeout(TimeOutError);}
$(function() {
$("#dialog").html(err)
$("#dialog").dialog({
closeOnEscape: true,
title: title,
modal: true,
width: 250,
height: 'auto',
close: function(event, ui) { $("#dialog").dialog("destroy")}
});
});
TimeOutError=setTimeout('closeError()',5000);
}
function setCookie(nombre, valor){
return AJAX('post','/xml/SetCookieFRM.asp', 'nombre='+nombre+'&valor='+valor);
}
function setCookieFRM(obj){
var nombre=obj.name;
var valor=obj.value;
return AJAX('post','/xml/SetCookieFRM.asp', 'nombre='+nombre+'&valor='+valor);
}
function ShowStatus(status){
if(status==true){
resizeShimDiv();
$('#divPanel').css({display: "block"});
$('#divLoading').css({display: "block"});
$('#divLoading').html('
');
$('#divLoading').center();
}
else{
setTimeout("$('#divLoading').css({display: 'none'});",10);
setTimeout("$('#divPanel').css({display: 'none'});",10);
}
}
function ShowError(title,err, w){
var width = 'auto';
var titleMinus=title.toLowerCase();
if(w) { var width = w} else { var width = 'auto';}
if(titleMinus.indexOf('error')>=0){
title='
' + title;
}
if(TimeOutError){clearTimeout(TimeOutError);}
if($.browser.msie){
if(w){width = w}
else{width = 400}
}
$(function() {
$("#dialog").html(err)
$("#dialog").dialog({
closeOnEscape: true,
title: title,
modal: true,
width: width,
height: 'auto',
show: 'slide',
hide: 'slide',
open: function() {$('.FRMBtn').button(); },
close: function(event, ui) { $("#dialog").dialog("destroy")}
}).height("auto");
});
}
$(document).ready(function(){
setTimeout('resizeShimDiv()',300);
});
$(window).resize(function() {
setTimeout('resizeShimDiv()',300);
});
function resizeShimDiv(){
$('#divPanel').css('top', $(window).scrollTop())
$('#divPanel').css('width',$(window).width());
$('#divPanel').css('height',$(window).height());
}
function AJAXDirect(method, url, data, div){
var m='POST';
var inMethod=method.toUpperCase();
if(method){
if(inMethod=='POST')
m='POST';
else if(inMethod=='GET')
m='GET';
}
dataSend='';
//ShowStatus('LoadQuery',true, title);
if(data){
dataSend=data;
}
if(dataSend.indexOf('fromAJAX')<0)
dataSend='fromAJAX=true&'+dataSend;
if(div){var asn=true;$('#'+div).html('');}else{var asn=false;}
var retorno='';
var rpt = $.ajax({
url: url,
type: m,
cache: false,
data: dataSend,
async:asn,
timeout: 20000,
dataType: 'html',
beforeSend: function(objeto){
if(div){ShowStatus(true);}
},
success: function(rx){
$('#' + div).html(rx);
$('.FRMBtn').button();
retorno=rx;
if(div){ShowStatus(false);}
},
error: function(objeto, quepaso, otroobj){
ShowStatus(false);
if(quepaso=='timeout'){
windowTimeOut(method, url, data, div, title);
return false;
}else{
ShowError('Error de comunicación','CODIGO: '+quepaso,350);
}
setTimeout("closeError()",5000);
}
});
if(!(div))
return (rpt.responseText);
}
function AJAXGhost(method, url, data, div){
var m='POST';
var inMethod=method.toUpperCase();
if(method){
if(inMethod=='POST')
m='POST';
else if(inMethod=='GET')
m='GET';
}
dataSend='';
//ShowStatus('LoadQuery',true, title);
if(data){
dataSend=data;
}
if(dataSend.indexOf('fromAJAX')<0)
dataSend='fromAJAX=true&'+dataSend;
var asn=false;
var retorno='';
var rpt = $.ajax({
url: url,
type: m,
cache: false,
data: dataSend,
async:asn,
timeout: 20000,
dataType: 'html',
success: function(rx){
$('#' + div).html(rx);
$('.FRMBtn').button();
retorno=rx;
},
error: function(objeto, quepaso, otroobj){
if(quepaso=='timeout'){
windowTimeOut(method, url, data, div, title);
return false;
}else{
ShowError('Error de comunicación','CODIGO: '+quepaso,350);
}
setTimeout("closeError()",5000);
}
});
if(!(div))
return (rpt.responseText);
}
function AJAX(method, url, data, div, title){
var m='POST';
var inMethod=method.toUpperCase();
if(method){
if(inMethod=='POST')
m='POST';
else if(inMethod=='GET')
m='GET';
}
dataSend='';
//ShowStatus('LoadQuery',true, title);
if(data){
dataSend=data;
}
if(dataSend.indexOf('fromAJAX')<0)
dataSend='fromAJAX=true&'+dataSend;
if(div){var asn=true;$('#'+div).html('');}else{var asn=false;}
var retorno='';
var rpt = $.ajax({
url: url,
type: m,
cache: false,
data: dataSend,
async:asn,
timeout: 20000,
dataType: 'html',
beforeSend: function(objeto){
if(div){ShowStatus(true);}
},
success: function(rx){
if(div){
if(!(isUndefined(document.getElementById(div).type))){
var type = document.getElementById(div).type.toLowerCase();
if(type=='textarea'||type=='text'||type=='select-one')
{document.getElementById(div).value=rx;$('.FRMBtn').button();
}
else{
document.getElementById(div).style.display='block';
document.getElementById(div).style.visibility='visible';
$('#'+div).html(rx); alert(0);
}
}
else{
var urlLower=url.toLowerCase()
if(urlLower.indexOf('v2.0')>0){
document.getElementById(div).style.display='block';
document.getElementById(div).style.visibility='visible';
$('#'+div).html(rx);
$('.FRMBtn').button();
}else{
document.getElementById(div).style.display='none';
$('#'+div).html(rx);
$('#'+div).slideDown('slow');
$('.FRMBtn').button();
}
}
}
else {
//return rx;
}
retorno=rx;
if(div){ShowStatus(false);}
},
error: function(objeto, quepaso, otroobj){
ShowStatus(false);
if(quepaso=='timeout'){
windowTimeOut(method, url, data, div, title);
return false;
}else{
ShowError('Error de comunicación','CODIGO: '+quepaso,350);
}
setTimeout("closeError()",5000);
}
});
if(!(div))
return (rpt.responseText);
}
function windowTimeOut(method, url, data, div, title){
if(confirm('Ha ocurrido un error en la carga de la página, por favor confirme el reintento')){
AJAX(method, url, data, div, title);
}
}
function getTime() {
var curtime = new Date();
var curhour = curtime.getHours();
var curmin = curtime.getMinutes();
var cursec = curtime.getSeconds();
var time = "";
if(curhour == 0) curhour = 12;
time = (curhour > 12 ? curhour - 12 : curhour) + ":" +
(curmin < 10 ? "0" : "") + curmin + ":" +
(cursec < 10 ? "0" : "") + cursec + " " +
(curhour > 12 ? "PM" : "AM");
return time;
}
function SetLog(obj){
if(obj.responseText !== undefined){
if(obj.status=='404'||obj.status=='500'){
$("#dialog").dialog("destroy");
}
if(document.getElementById('divStatusLog')){
document.getElementById('divStatusLog').innerHTML='LOG: Time: ' + getTime() + '; Code: ' + obj.status + '; Msg: ' + obj.statusText;
}
}
}
var AJXTimeOut;
function ajaxTimeout(obj){
obj.abort();
if(document.getElementById('divStatusLog')){
document.getElementById('divStatusLog').innerHTML='LOG: Time: ' + getTime() + '; Code: TIMEOUT';
}
}
function isUndefined(v){var undef;return v===undef;}
function CheckParentLink(url){
if(parent.window.opener.closed==true){
var wnd = window.open(url);
wnd.focus();
}
else{
window.opener.location=url;
window.opener.focus();
}
}
function ClearDIV(dv){
if(document.getElementById(dv))
document.getElementById(dv).innerHTML='';
}
//Prototipos para Fechas
Date.prototype.string = function (fecha){
var dia=fecha.getDate().toString();
if(dia.length==1)
dia='0'+dia;
var mes=fecha.getMonth()+1; mes=mes.toString();
if(mes.length==1)
mes='0'+mes;
var ano=fecha.getYear();
if(ano<2000)
ano=1900+ano
fecha=dia + '-' + mes + '-' + ano;
return fecha
}
Date.prototype.add = function (sInterval, iNum){
var dTemp = this;
if (!sInterval || iNum == 0) return dTemp;
switch (sInterval.toLowerCase()){
case "ms":
dTemp.setMilliseconds(dTemp.getMilliseconds() + iNum);
break;
case "s":
dTemp.setSeconds(dTemp.getSeconds() + iNum);
break;
case "mi":
dTemp.setMinutes(dTemp.getMinutes() + iNum);
break;
case "h":
dTemp.setHours(dTemp.getHours() + iNum);
break;
case "d":
dTemp.setDate(dTemp.getDate() + iNum);
break;
case "mo":
dTemp.setMonth(dTemp.getMonth() + iNum);
break;
case "y":
dTemp.setFullYear(dTemp.getFullYear() + iNum);
break;
}
return dTemp;
}
//Prototipos de String
String.prototype.trim = function() {return this.replace(/^\s+|\s+$/g,"");}
String.prototype.ltrim = function() {return this.replace(/^\s+/,"");}
String.prototype.rtrim = function() {return this.replace(/\s+$/,"");}
String.prototype.left = function(count) {
if (this.length>count)
return this.substring(0, count);
else
return this;
}
String.prototype.right = function(count) {
if (this.length>count)
return this.substring(this.length-count, this.length);
else
return this;
}
String.prototype.RemoveZero = function() {
s=this;
while (s.substr(0,1) == '0' && s.length>1) { s = s.substr(1,9999); }
return s;
}
function urlencode(str) {
var v;
str = str.split(/\r\n|\r|\n/).join("%0D");
try { v = encodeURIComponent(str); } catch (e) { v = escape(str); }
return v.replace(/%20/g,"+");
}
function CreateQS(theForm){
var reqStr = "";
for(i=0; i < theForm.elements.length; i++){
isFormObject = false;
if(theForm.elements[i].name!=''){
switch (theForm.elements[i].tagName){
case "INPUT":
switch (theForm.elements[i].type){
case "text":
case "hidden":
case "password":
reqStr += theForm.elements[i].name + "=" + encodeURIComponent(theForm.elements[i].value);
isFormObject = true;
break;
case "checkbox":
if (theForm.elements[i].checked){
reqStr += theForm.elements[i].name + "=" + theForm.elements[i].value;
isFormObject = true;
}else{
//reqStr += theForm.elements[i].name + "=";
isFormObject = false;
}
break;
case "radio":
if (theForm.elements[i].checked){
reqStr += theForm.elements[i].name + "=" + theForm.elements[i].value;
isFormObject = true;
}
}
break;
case "TEXTAREA":
reqStr += theForm.elements[i].name + "=" + encodeURIComponent(theForm.elements[i].value);
isFormObject = true;
break;
case "SELECT":
var sel = theForm.elements[i];
var tipo=sel.type;
tipo=tipo.toLowerCase();
if(tipo=='select-multiple'){
for(j=0;j= 5.5) && (version < 7) && (document.body.filters))
{
var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
var imgTitle = (myImage.title) ?
"title='" + myImage.title + "' " : "title='" + myImage.alt + "' "
var imgStyle = "display:inline-block;" + myImage.style.cssText
var strNewHTML = ""
myImage.outerHTML = strNewHTML
}
*/
}
function isArray(obj){return(typeof(obj.length)=="undefined")?false:true;}
function isNumberKey(evt, acceptPunto)
{
var eve;
if ( typeof window.event!= "undefined" ) { eve = window.event; }
else { eve = evt; }
var charCode = (eve.charCode)? eve.charCode :((eve.which)? eve.which : eve.keyCode);
var rt = false;
if (charCode == 8) var rt = true;
else if (charCode == 9) var rt = true;
else if (charCode == 35) var rt = true;
else if (charCode == 36) var rt = true;
else if (charCode == 39) var rt = true;
else if (charCode == 37) var rt = true;
else if(acceptPunto){
if (acceptPunto==true){
if (charCode == 46) {
var rt = true;
}
}
}
else if (charCode >= 48 && charCode <= 57) return true;
else var rt = false;
return rt
}
function returnAlpha(val){
var re = new RegExp("[^a-zA-Z0-9]", "g");
return val.replace(re,'');
}
function isAlpha(evt)
{
var eve;
if ( typeof window.event!= "undefined" ) { eve = window.event; }
else { eve = evt; }
var charCode = (eve.charCode)? eve.charCode :((eve.which)? eve.which : eve.keyCode);
var nonLettersRegExp = /[^A-Za-z0-9]/;
if (charCode > 31 && (nonLettersRegExp.test(String.fromCharCode(charCode))))
return false;
return true;
}
function isUserName(evt)
{
var eve;
if ( typeof window.event!= "undefined" ) { eve = window.event; }
else { eve = evt; }
var charCode = (eve.charCode)? eve.charCode :((eve.which)? eve.which : eve.keyCode);
var nonLettersRegExp = /[^A-Za-z0-9\.\_\-]/;
if (charCode > 31 && (nonLettersRegExp.test(String.fromCharCode(charCode))))
return false;
return true;
}
function camelCaps(str, theCase)
{
var strTemp=str.value.toLowerCase();
var tempArray = strTemp.split(' ');
// Make the first character of each word upper- or lowercase
// depending on the value of theCase
for (var i = 0; i < tempArray.length; i++) {
if (!theCase) {
tempArray[i] = tempArray[i].charAt(0).toUpperCase() + tempArray[i].substring(1);
}
else {
tempArray[i] = tempArray[i].charAt(0).toLowerCase() + tempArray[i].substring(1);
}
}
str.value=tempArray.join(' ');
}
function FormatDateTime(datetime, FormatType)
/*
FomatType takes the following values
1 - General Date = Friday, October 30, 1998
2 - Typical Date = 10/30/98
3 - Standard Time = 6:31 PM
4 - Military Time = 18:31
*/
{
var strDate = new String(datetime);
if (strDate.toUpperCase() == "NOW") {
var myDate = new Date();
strDate = String(myDate);
} else {
var myDate = new Date(datetime);
strDate = String(myDate);
}
// Get the date variable parts
var Day = new String(strDate.substring(0,3));
if (Day == "Sun") Day = "Domingo";
if (Day == "Mon") Day = "Lunes";
if (Day == "Tue") Day = "Martes";
if (Day == "Wed") Day = "Miécoles";
if (Day == "Thu") Day = "Jueves";
if (Day == "Fri") Day = "Viernes";
if (Day == "Sat") Day = "Sábado";
var Month = new String(strDate.substring(4,7)), MonthNumber = 0;
if (Month == "Jan") { Month = "Enero"; MonthNumber = 1; }
if (Month == "Feb") { Month = "Febrero"; MonthNumber = 2; }
if (Month == "Mar") { Month = "Marzo"; MonthNumber = 3; }
if (Month == "Apr") { Month = "Abril"; MonthNumber = 4; }
if (Month == "May") { Month = "Mayo"; MonthNumber = 5; }
if (Month == "Jun") { Month = "Junio"; MonthNumber = 6; }
if (Month == "Jul") { Month = "Julio"; MonthNumber = 7; }
if (Month == "Aug") { Month = "Agosto"; MonthNumber = 8; }
if (Month == "Sep") { Month = "Septiembre"; MonthNumber = 9; }
if (Month == "Oct") { Month = "Octubre"; MonthNumber = 10; }
if (Month == "Nov") { Month = "Noviembre"; MonthNumber = 11; }
if (Month == "Dec") { Month = "Diciembre"; MonthNumber = 12; }
var curPos = 11;
var MonthDay = new String(strDate.substring(8,10));
if (MonthDay.charAt(1) == " ") {
MonthDay = "0" + MonthDay.charAt(0);
curPos--;
}
var MilitaryTime = new String(strDate.substring(curPos,curPos + 5));
var Year = new String(strDate.substring(strDate.length - 4, strDate.length));
// Format Type decision time!
if (FormatType == 1)
strDate = Day + ", " + MonthDay + " de " + Month + " de " + Year;
else if (FormatType == 2)
strDate = MonthNumber + "/" + MonthDay + "/" + Year.substring(2,4);
else if (FormatType == 3) {
var AMPM = MilitaryTime.substring(0,2) >= 12 && MilitaryTime.substring(0,2) != "24" ? " PM" : " AM";
if (MilitaryTime.substring(0,2) > 12)
strDate = (MilitaryTime.substring(0,2) - 12) + ":" + MilitaryTime.substring(3,MilitaryTime.length) + AMPM;
else {
if (MilitaryTime.substring(0,2) < 10)
strDate = MilitaryTime.substring(1,MilitaryTime.length) + AMPM;
else
strDate = MilitaryTime + AMPM;
}
}
else if (FormatType == 4)
strDate = MilitaryTime;
return strDate;
}
function isEmail(_email) {
var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i
return emailReg.test(_email);
}
function handleEnter(field, event, num)
{
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
if (keyCode == 13) {
var i;
for (i = 0; i < field.form.elements.length; i++)
if (field == field.form.elements[i])
break;
i = (i + 1) % field.form.elements.length;
field.form.elements[i].focus();
return false;
}
else
{
if(num)
{
if (keyCode > 31 && (keyCode < 48 || keyCode > 57))
return false;
return true;
}
return true;
}
return true;
}
function CheckMovil(obj)
{
if(obj.value.length>8)
obj.value=obj.value.substring(obj.value.length-8,obj.value.length);
if(obj.value.length==8)
obj.value=obj.value;
if(obj.value.length==7)
obj.value='9'+obj.value;
}
function GetRadio(obj)
{
if(obj.length>0)
for(i=0;i0)
{
for(i=0;i0)
qs=qs.substring(0,qs.length-2);
return qs;
}
function checkAll(field, state){
if(isArray(field)){
for (i=0;i=0){
//AJX.SendS('post','/Store.Browser.asp','B='+BrowserDetect.browser+'&V='+BrowserDetect.version+'&O='+BrowserDetect.OS);
}
*/
//Resampleo de Ventana por Navegador
function ResizeWindow(X,Y){
var ng='';
var H=0; var W=0; var OH=0; var OW = 0;
var v=BrowserDetect.version;
if(BrowserDetect.browser=='FireFox'){
ng='FF';H=0;
}
if(BrowserDetect.browser=='Explorer'){
ng='IE';H=-33;
if(v>=7){
H=H+21;
}
}
if(BrowserDetect.browser=='Safari'){
ng='SF';H=H-42; W=W+30;
}
if(BrowserDetect.browser=='Opera'){
ng='OP';H=0;
}
if(BrowserDetect.browser=='Chrome'){
ng='OP';H=H-25; W=W+20;
}
if(BrowserDetect.browser=='Opera'){
ng='OP';H=H-40;
}
var Body=GetBodySize();
var Window=GetWindowSize();
TopHeight=(Window[1]-Y);
//alert(OH);
WindowW=(Window[0]);
BodyW=Body[0];
DeltaW=WindowW-BodyW;
//alert(WindowW);
ResizeToInner(X,Y,100,100)
// window.resizeTo(LeftWidth+X+W,TopHeight+Y+H);
}
function GetInnerSize () {
var x,y;
if (self.innerHeight) // all except Explorer
{
x = self.innerWidth;
y = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
// Explorer 6 Strict Mode
{
x = document.documentElement.clientWidth;
y = document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
x = document.body.clientWidth;
y = document.body.clientHeight;
}
return [x,y];
}
function ResizeToInner (w, h, x, y) {
// make sure we have a final x/y value
// pick one or the other windows value, not both
if (x==undefined) x = window.screenLeft || window.screenX;
if (y==undefined) y = window.screenTop || window.screenY;
// for now, move the window to the top left
// then resize to the maximum viewable dimension possible
window.moveTo(0,0);
window.resizeTo(screen.availWidth,screen.availHeight);
// now that we have set the browser to it's biggest possible size
// get the inner dimensions. the offset is the difference.
var inner = GetInnerSize();
var ox = screen.availWidth-inner[0];
var oy = screen.availHeight-inner[1];
// now that we have an offset value, size the browser
// and position it
window.resizeTo(w+ox, h+oy);
window.moveTo(x,y);
}
function HideSelectBox(state){
if(state==true)
var show='hidden';
else
var show='visible';
var x = document.getElementsByTagName("select");
for (i = 0; i < x.length; i++)
x[i].style.visibility = show;
}
function GetBodySize() {
var myWidth = 0, myHeight = 0; var RT = [];
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;
}
RT[0]=myWidth; RT[1] = myHeight;
return RT;
}
function GetWindowSize(){
w = 640;
h = 480;
var RT = [];
NS4Plus = (document.layers) ? 1 : 0;
IE4Plus = (document.all) ? 1 : 0;
if (NS4Plus) {
w = window.innerWidth;
h = window.innerHeight;
}
if (IE4Plus) {
/* The script must be inside the body tags - there is no body in the head of the document */
w = document.body.clientWidth;
h = document.body.clientHeight;
}
RT[0] = w; RT[1] = h
return RT;
}
function GetRazonSocialSII(RUT){
var RS=AJAX('get','/includes/Get.RUT.asp','RUT='+RUT);
return RS;
}
function CheckCaractCount(obj,lbl,ctn)
{
if(obj.value.length<=ctn)
{
document.getElementById(lbl).innerHTML=ctn-obj.value.length;
}
else
{
obj.value=obj.value.substring(0,ctn);
document.getElementById(lbl).innerHTML=ctn-obj.value.length;
}
}
function addLoadEvent(func){
var oldonload = window.onload;
if(typeof window.onload != 'function'){
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
function addUnloadEvent(func) {
var oldunload = window.onunload;
if (typeof window.onunload != 'function') {
window.onunload = func;
}
else {
window.onunload = function() {
if (oldunload) {
oldunload();
}
func();
}
}
}
/*function addEvent(obj,type,fn){
if(obj.addEventListener) obj.addEventListener(type,fn,false);
else if(obj.attachEvent){
obj["e"+type+fn]=fn;
obj[type+fn]=function(){obj["e"+type+fn](window.event);}
obj.attachEvent("on"+type,obj[type+fn]);
}
}
*/
function addEvent(obj, evType, fn){
if (obj.addEventListener){
obj.addEventListener(evType, fn, false);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
return false;
}
}
function removeEvent(obj,type,fn){
if(obj.removeEventListener) obj.removeEventListener(type,fn,false);
else if(obj.detachEvent){
obj.detachEvent("on"+type,obj[type+fn]);
obj[type+fn]=null;
obj["e"+type+fn]=null;
}
}
function formatRUT(obj){
var rut=obj.value;
rut=rut.toUpperCase();
if(rut!=''){
for(i=0;i<5;i++){
rut=rut.replace('-','');
rut=rut.replace('.','');
rut=rut.replace(',','');
}
rut=rut.substring(0,rut.length-1) + '-' + rut.substring(rut.length-1,rut.length)
obj.value=rut;
}
}
function isRUT(evt)
{
var eve;
if ( typeof window.event!= "undefined" ) { eve = window.event; }
else { eve = evt; }
var charCode = (eve.charCode)? eve.charCode :((eve.which)? eve.which : eve.keyCode);
var nonLettersRegExp = /[^Kk0-9\-]/;
if (charCode > 31 && (nonLettersRegExp.test(String.fromCharCode(charCode))))
return false;
return true;
}
function ValidarRut(intlargo){
var tmpstr = "";
//var intlargo = Objeto.value;
if (intlargo.length> 0) {
crut = intlargo;
largo = crut.length;
if(largo<2) {
return false;
}
for ( i=0; i 2 ){
rut = crut.substring(0, largo - 1);
}else rut = crut.charAt(0);
dv = crut.charAt(largo-1);
if ( rut == null || dv == null ) return 0;
var dvr = '0';
suma = 0;
mul = 2;
for (i= rut.length-1 ; i>= 0; i--) {
suma = suma + rut.charAt(i) * mul;
if (mul == 7) mul = 2;
else mul++;
}
res = suma % 11;
if (res==1) dvr = 'k';
else if (res==0) dvr = '0';
else { dvi = 11-res; dvr = dvi + ""; }
if ( dvr != dv.toLowerCase() ) {
//Objeto.focus();
return false;
}
//Objeto.focus();
return true;
}
}
//Time Picker
var Hour=''; var Minute='';
function CheckTime(obj){
if(Hour!=''&&Minute!=''){
var Time=Hour+':'+Minute;
if(document.getElementById(obj))
document.getElementById(obj).value=Time;
$("#dialog").dialog("destroy");
if(document.getElementById(obj)){
document.getElementById(obj).focus();
document.getElementById(obj).select();
}
}
}
function setIntervalMinute(){
if(document.getElementById('divMinuto5').style.display=='block'){
document.getElementById('divMinuto5').style.display='none';
document.getElementById('divMinuto1').style.display='block';
document.getElementById('btnTimePicking').value='<<<';
}
else{
document.getElementById('divMinuto5').style.display='block';
document.getElementById('divMinuto1').style.display='none';
document.getElementById('btnTimePicking').value='>>>';
}
}
function setCellHour(td){
for(j=0;j<24;j++){
var js=j.toString();
if(js.length<2) js='0'+js;
document.getElementById('tdH'+js).style.backgroundColor='#E0E0E0';
document.getElementById('tdHFont'+js).style.color ='#000000';
document.getElementById('tdHFont'+js).style.fontWeight='normal'
}
document.getElementById('tdH'+td).style.backgroundColor='#000099';
document.getElementById('tdHFont'+td).style.color='#FFFFFF';
document.getElementById('tdHFont'+td).style.fontWeight='bold'
Hour=td;
}
function setCellMinute(td,obj){
for(j=0;j<60;j=j+5){
var js=j.toString();
if(js.length<2) js='0'+js;
document.getElementById('tdM'+js).style.backgroundColor='#FFFFFF';
document.getElementById('tdMFont'+js).style.color ='#000000';
document.getElementById('tdMFont'+js).style.fontWeight='normal'
}
document.getElementById('tdM'+td).style.backgroundColor='#000099';
document.getElementById('tdMFont'+td).style.color='#FFFFFF';
document.getElementById('tdMFont'+td).style.fontWeight='bold';
Minute=td;
CheckTime(obj);
}
function setCellMinute2(td,obj){
for(j=0;j<60;j++){
var js=j.toString();
if(js.length<2) js='0'+js;
document.getElementById('tdM2'+js).style.backgroundColor='#FFFFFF';
document.getElementById('tdM2Font'+js).style.color ='#000000';
document.getElementById('tdM2Font'+js).style.fontWeight='normal'
}
document.getElementById('tdM2'+td).style.backgroundColor='#000099';
document.getElementById('tdM2Font'+td).style.color='#FFFFFF';
document.getElementById('tdM2Font'+td).style.fontWeight='bold';
Minute=td;
CheckTime(obj);
}
function ExtractEmails(Emails, Separador) {
var separateEmailsBy = Separador + ", ";
var email = "";
var emailsArray = Emails.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
if (emailsArray) {
email = "";
for (var i = 0; i < emailsArray.length; i++) {
if (i != 0) email += Separador;
email += emailsArray[i];
}
}
return email;
}
function LatLonDistance(lat1, lon1, lat2, lon2){
var radlat1 = Math.PI * lat1/180
var radlat2 = Math.PI * lat2/180
var radlon1 = Math.PI * lon1/180
var radlon2 = Math.PI * lon2/180
var theta = lon1-lon2
var radtheta = Math.PI * theta/180
var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
dist = Math.acos(dist)
dist = dist * 180/Math.PI
dist = dist * 60 * 1.1515
dist = dist * 1.609344;
return dist
}
function connectFB(msg){
FB.ui({
method: 'stream.publish',
attachment: attachment
},
function(response) {
//DO NOTHING
}
);
}
function postFBMessage(fbObj,attachment){
if(attachment!=0){
fbObj.Connect.streamPublish('', attachment, '', 122425809186, '', null, true);
fbObj.Connect.streamPublish('', attachment, '', null, '', null, true);
}
else if(attachment==0){
var attachment = {
'name':'ha conectado su cuenta de facebook con Reservame.net',
'href':'http://www.reservame.net/ecv2/?urlFrom=facebook',
'caption':'Ir al sitio web de Reservame.net',
'description':'¿Quieres realizar un pedido de delivery o una reserva en restaurants, complejos deportivos, taxis, hostales, Spa?. Visita el link para más información nuestros servicios.',
'media': [{'type': 'image', 'src': 'http://www.reservame.net/img/4.0/logos/images/Main3.png','href':'http://www.reservame.net/ecv2/?urlFrom=facebook'}]
};
fbObj.Connect.streamPublish('', attachment, '', 122425809186, '', null, true);
fbObj.Connect.streamPublish('', attachment, '', null, '', null, true);
}
}
function postFBID(fbObj){
if(fbObj.Facebook.apiClient.get_session()){
(AJAX('post','/xml/setUserFaceBook.asp','FBUserID='+fbObj.Facebook.apiClient.get_session().uid));
}
}
function checkWidth(obj){
var obj='#'+obj;
var w = ($(obj).width());
//alert($.browser.msie);
if($.browser.msie){
$(obj).width(w-18);
}
}
/*
* Easy Retweet Button
* http://ejohn.org/blog/retweet/
* by John Resig (ejohn.org)
*
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*/
(function(){
window.RetweetJS = {
// Your Bit.ly Username
bitly_user: "retweetjs",
// Your Bit.ly API Key
// Found here: //bit.ly/account
bitly_key: "R_6287c92ecaf9efc6f39e4f33bdbf80b1",
// The text to replace the links with
link_text: (/windows/i.test( navigator.userAgent) ? "►" : "♻") +
" Retweet",
// What # to show (Use "clicks" for # of clicks or "none" for nothing)
count_type: "clicks",
// Tweet Prefix text
// "RT @jeresig " would result in: "RT @jeresig Link Title http://bit.ly/asdf"
prefix: "RT @Reservame ",
// Style information
styling: "a.retweet { font: 12px Helvetica,Arial; color: #000; text-decoration: none; border: 0px; }" +
"a.retweet span { color: #FFF; background: #94CC3D; margin-left: 2px; border: 1px solid #43A52A; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; padding: 3px; }" +
"a.vert { display: block; text-align: center; font-size: 16px; float: left; margin: 4px; }" +
"a.retweet strong.vert { display: block; margin-bottom: 4px; background: #F5F5F5; border: 1px solid #EEE; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; padding: 3px; }" +
"a.retweet span.vert { display: block; font-size: 12px; margin-left: 0px; }"
};
//////////////// No Need to Configure Below Here ////////////////
var loadCount = 1;
// Asynchronously load the Bit.ly JavaScript API
// If it hasn't been loaded already
if ( typeof BitlyClient === "undefined" ) {
var head = document.getElementsByTagName("head")[0] ||
document.documentElement;
var script = document.createElement("script");
script.src = "//bit.ly/javascript-api.js?version=latest&login=" +
RetweetJS.bitly_user + "&apiKey=" + RetweetJS.bitly_key;
script.charSet = "utf-8";
head.appendChild( script );
var check = setInterval(function(){
if ( typeof BitlyCB !== "undefined" ) {
clearInterval( check );
head.removeChild( script );
loaded();
}
}, 10);
loadCount = 0;
}
if ( document.addEventListener ) {
document.addEventListener("DOMContentLoaded", loaded, false);
} else if ( window.attachEvent ) {
window.attachEvent("onload", loaded);
}
function loaded(){
// Need to wait for doc ready and js ready
if ( ++loadCount < 2 ) {
return;
}
var elems = [], urlElem = {}, hashURL = {};
BitlyCB.shortenResponse = function(data) {
for ( var url in data.results ) {
var hash = data.results[url].userHash;
hashURL[hash] = url;
var elems = urlElem[ url ];
for ( var i = 0; i < elems.length; i++ ) {
elems[i].href += hash;
}
if ( RetweetJS.count_type === "clicks" ) {
BitlyClient.stats(hash, 'BitlyCB.statsResponse');
}
}
};
BitlyCB.statsResponse = function(data) {
var clicks = data.results.clicks, hash = data.results.userHash;
var url = hashURL[ hash ], elems = urlElem[ url ];
if ( clicks > 0 ) {
for ( var i = 0; i < elems.length; i++ ) {
var strong = document.createElement("strong");
strong.appendChild( document.createTextNode( clicks + " " ) );
elems[i].insertBefore(strong, elems[i].firstChild);
if ( /(^|\s)vert(\s|$)/.test( elems[i].className ) ) {
elems[i].firstChild.className = elems[i].lastChild.className = "vert";
}
}
}
hashURL[ hash ] = urlElem[ url ] = null;
};
if ( document.getElementsByClassName ) {
elems = document.getElementsByClassName("retweet");
} else {
var tmp = document.getElementsByTagName("a");
for ( var i = 0; i < tmp.length; i++ ) {
if ( /(^|\s)retweet(\s|$)/.test( tmp[i].className ) ) {
elems.push( tmp[i] );
}
}
}
if ( elems.length && RetweetJS.styling ) {
var style = document.createElement("style");
style.type = "text/css";
try {
style.appendChild( document.createTextNode( RetweetJS.styling ) );
} catch (e) {
if ( style.styleSheet ) {
style.styleSheet.cssText = RetweetJS.styling;
}
}
document.body.appendChild( style );
}
for ( var i = 0; i < elems.length; i++ ) {
var elem = elems[i];
if ( /(^|\s)self(\s|$)/.test( elem.className ) ) {
elem.href = window.location;
elem.title = document.title;
}
var origText = elem.title || elem.textContent || elem.innerText,
href = elem.href;
elem.innerHTML = "" + RetweetJS.link_text + "";
elem.title = "";
elem.href = "//twitter.com/home?status=" +
encodeURIComponent(RetweetJS.prefix + origText + " http://bit.ly/");
if ( urlElem[ href ] ) {
urlElem[ href ].push( elem );
} else {
urlElem[ href ] = [ elem ];
BitlyClient.shorten(href, 'BitlyCB.shortenResponse');
}
}
}
})();
//Table Update
$('#example a.edit').live('click', function (e) {
e.preventDefault();
var nRow = $(this).parents('tr')[0];
if ( nEditing !== null && nEditing != nRow ) {
restoreRow( oTable, nEditing );
editRow( oTable, nRow );
nEditing = nRow;
}
else if ( nEditing == nRow && this.innerHTML == "Guardar" ) {
saveRow( oTable, nEditing );
nEditing = null;
}
else {
editRow( oTable, nRow );
nEditing = nRow;
}
});
function restoreRow ( oTable, nRow )
{
var aData = oTable.fnGetData(nRow);
var jqTds = $('>td', nRow);
for ( var i=0, iLen=jqTds.length ; iEditar', nRow, editTag, false );
oTable.fnDraw();
}
function editRow ( oTable, nRow )
{
var aData = oTable.fnGetData(nRow);
var jqTds = $('>td', nRow);
for(i=0;i';
}
jqTds[editTag].innerHTML = 'Guardar';
}
$('#example a.delete').live('click', function (e) {
e.preventDefault();
if(confirm('Esta seguro de eliminar el registro?')){
var nRow = $(this).parents('tr')[0];
var aData = oTable.fnGetData(nRow);
var jqTds = $('>td', nRow);
var data=deleteFlag;
data+='&' + editFields[0] + '=' + aData[editCols[0]].replace(/<\/?[^>]+>/gi, '');
AJAX('post',scriptName,data);
oTable.fnDeleteRow( nRow );
}
});