var alertObject = null; function myTrim(str) { var n, ind1, ind2, ss; ind1 = 0; ind2 = str.length - 1; for(n = 0; n <= ind2 && str.substr(n, 1) == " "; n++, ind1++) ; for(n = ind2; n >= ind1 && str.substr(n, 1) == " "; n--, ind2--) ; if(ind2 >= ind1) ss = str.substring(ind1, ind2+1); else ss = ""; return ss; } /* Function to open a window: url -> Url to open in the window. target -> Target window. Example: '_blank'. width -> Width in pixels height -> Height in pixels left -> Left position top -> Top position resizable -> Resizable flag. Values: 'yes', 'no', '1', '0', true, false. scrollbars -> Scrollbars flags. Values: 'yes', 'no', '1', '0', true, false. */ function OpenWindow(url, target, width, height, left, top, resizable, scrollbars) { if(typeof(url) == 'undefined' || url == null) url = ''; if(typeof(target) == 'undefined' || target == null) target = ''; if(typeof(width) == 'undefined' || width == null) width = 275; if(typeof(height) == 'undefined' || height == null) height = 275; if(typeof(window.screen) == 'undefined') { var sw = 800; var sh = 600; } else { var sw = window.screen.width; var sh = window.screen.height; } if(typeof(left) == 'undefined' || left == null) left = Math.round(0.5 * (sw - width)); if(typeof(top) == 'undefined' || top == null) top = Math.round(0.5 * (sh - height)); if(typeof(resizable) == 'undefined' || resizable == 'no' || !resizable) resizable = 0; else resizable = 1; if(typeof(scrollbars) == 'undefined' || scrollbars == 'no' || !scrollbars) scrollbars = 0; else scrollbars = 1; var win = window.open(url, target, 'left=' + left + ',top=' + top + ',width=' + width + ',height=' + height + ',directories=0,location=0,menubar=0,resizable=' + resizable +',scrollbars=' + scrollbars + ',status=0,toolbar=0'); win.focus(); return win; } // Validates a date string in format dd/mm/yyyy function checkDate(sinput) { var validformat = /^\d{1,2}\/\d{1,2}\/\d{4}$/; //Basic check for format validity var returnval = false; if (validformat.test(sinput)) { var arrdate = sinput.split("/"); var monthfield = parseInt(arrdate[1], 10); var dayfield = parseInt(arrdate[0], 10); var yearfield = parseInt(arrdate[2], 10); var dayobj = new Date(yearfield, monthfield-1, dayfield); if ((dayobj.getMonth()+1 != monthfield) || (dayobj.getDate() != dayfield) || (dayobj.getFullYear() != yearfield)) returnval = false; else returnval = true; } return returnval; } // Validates an e-mail string function checkEmail(str) { if(!str) return false; var at = "@"; var dot = "."; var lat = str.indexOf(at); var lstr = str.length; var ldot = str.indexOf(dot); if (str.indexOf(at) == -1){ return false; } if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) { return false; } if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) { return false; } if (str.indexOf(at, (lat+1)) != -1) { return false; } if (str.substring(lat-1, lat) == dot || str.substring(lat+1, lat+2) == dot) { return false; } if (str.indexOf(dot, (lat+2)) == -1) { return false; } if (str.indexOf(" ") != -1){ return false; } return true; } // Return url prefix for absolute access to the site root function GetRootPath() { return "/"; } // Returns the media path name for a media id function GetMediaPath(mediaid) { var spath = "store/media/"; var ss = String(mediaid); while(ss.length < 10) ss = "0"+ ss; spath += ss.substr(0, 4) +"/"+ ss.substr(4, 3) +"/"+ ss.substr(7, 3) +"/"; return spath; } // Gets a image link scaled function GetImageScaled(filename, width, height, constrain) { var img = "images/"+ filename; if(!constrain) constrain = "0"; else constrain = "1"; if(!width || isNaN(width)) width = 0; if(!height || isNaN(height)) height = 0; var ss = "scaleimg.php?img="+ img +"&width="+ width +"&height="+ height +"&constrain="+ constrain +"&rnd="+ parseInt(Math.random() * 10000); return ss; } // Gets a image link function GetImage(filename) { var img = "images/"+ filename; return img; } // Gets a image link scaled from the store function GetStoreScaled(mediaid, filename, width, height, constrain) { var img = GetMediaPath(mediaid) + filename; if(!constrain) constrain = "0"; else constrain = "1"; if(!width || isNaN(width)) width = 0; if(!height || isNaN(height)) height = 0; var ss = "scaleimg.php?img="+ img +"&width="+ width +"&height="+ height +"&constrain="+ constrain +"&rnd="+ parseInt(Math.random() * 10000); return ss; } // Gets a image link from the store function GetStore(mediaid, filename) { var img = GetMediaPath(mediaid) + filename; return img; } // Returns the avatar path name for a user id function GetAvatarPath(userid) { var sfile = "store/avatar/user/"; var ss = String(userid); while(ss.length < 10) ss = "0"+ ss; sfile += ss.substr(0, 4) +"/"+ ss.substr(4, 3) +"/"+ ss.substr(7, 3) +"/"; return sfile; } // Gets an avatar image link scaled function GetAvatarScaled(userid, filename, width, height, constrain) { var img; if(!constrain) constrain = "0"; else constrain = "1"; if(!width || isNaN(width)) width = 0; if(!height || isNaN(height)) height = 0; if(!filename || filename == "" || userid <= 0) { if(!filename || filename == "") img = "store/avatar/avatardef.jpg"; else img = "store/avatar/"+ filename; } else { img = GetAvatarPath(userid) + filename; } var ss = "scaleimg.php?img="+ img +"&width="+ width +"&height="+ height +"&constrain="+ constrain +"&rnd="+ parseInt(Math.random() * 10000); return ss; } // Gets an avatar image function GetAvatar(userid, filename) { var img; if(!filename || filename == "" || userid <= 0) { if(!filename || filename == "") img = "store/avatar/avatardef.jpg"; else img = "store/avatar/"+ filename; } else { img = GetAvatarPath(userid) + $filename; } return img; } // Gets a image link for empty images function GetEmptyImage(width, height) { var img = "images/empty.jpg"; if(!width || isNaN(width)) width = 0; if(!height || isNaN(height)) height = 0; var ss = "scaleimg.php?img="+ img +"&width="+ width +"&height="+ height +"&rnd="+ parseInt(Math.random() * 10000); return ss; } var arVersion = navigator.appVersion.split("MSIE"); var version = parseFloat(arVersion[1]); // Fixes transparent PNG bug in IE function fixPNG(myImage) { if ((version >= 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; } } // Hides form and other elements (that render always at a top z-index) function HideFormElements(doc) { if(doc == undefined) doc = document; var list, n; // Hides objects list = doc.getElementsByTagName("select"); for(n = 0; n < list.length; n++) { list[n].style.visibility = "visible"; } // Shows flash objects list = doc.getElementsByTagName("object"); for(n = 0; n < list.length; n++) { list[n].style.visibility = "visible"; } // Recurses on