/* Depends on jQuery */ jQuery.fn.log = function (msg) { try{ if(console!=null){ console.log("%s: %o", msg, this); } }catch(ex){} $("#logging").append(msg+"
"); return this; }; $(window).ready(function(){ //Create logging console $("body").prepend(""); //document.onkeypress = function(tEvt){ $(window).keypress(function(tEvt){ //If Ctrl + ] show debug panel //alert(tEvt.which); if(tEvt !=null && tEvt.which == 93 && tEvt.ctrlKey){ $("#logging").toggle(); }else if(window.event!=null && window.event.keyCode == 29 && window.event.ctrlKey==true){ $("#logging").toggle(); }else{ } } ); }); function Dim(){ this.width = 0; this.height = 0; } function getDocumentDimension(){ var d = new Dim(); // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight if (typeof window.innerWidth != 'undefined'){ d.width = window.innerWidth; d.height = window.innerHeight; } // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document) else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) { d.width = document.documentElement.clientWidth; d.height = document.documentElement.clientHeight; } // older versions of IE else { d.width = document.getElementsByTagName('body')[0].clientWidth; d.height = document.getElementsByTagName('body')[0].clientHeight; } return d; } function getStyleProp(style, prop){ var d = $("
"); $(document.body).append(d); d.addClass(style); var val = d.css(prop); d.remove(); return val; } /* Get the contents of a url */ function stripUrl(str){ var i = str.toLowerCase().indexOf("url("); var iEnd = str.indexOf(")",i); if(i>=0 && iEnd>i){ var v = str.substring(i+4,iEnd); //we also cut out the " OR ' if(v.indexOf('"') >= 0 || v.indexOf('"')){ v = v.substring(1,v.length-1); } return v; }else{ return str; } } function initialiseLogging(){ jQuery.fn.log = function (msg) { try{ if(console!=null){ console.log("%s: %o", msg, this); } }catch(ex){} $("#logging").append(msg+"
"); return this; }; //Create logging console $("body").prepend(""); //document.onkeypress = function(tEvt){ $(window).keypress(function(tEvt){ //If Ctrl + ] show debug panel //alert(tEvt.which); if(tEvt !=null && tEvt.which == 93 && tEvt.ctrlKey){ $("#logging").toggle(); }else if(window.event!=null && window.event.keyCode == 29 && window.event.ctrlKey==true){ $("#logging").toggle(); }else{ } } ); } function log(str){ try{ $("").log(str); }catch(ex){ } $("#logging").append(str+"
"); } function removeCSS(css_href){ } function loadCSS(css_href){ var head = document.getElementsByTagName('head')[0]; $(document.createElement('link')).attr({type: 'text/css', href: css_href, rel: 'stylesheet', media: 'screen'}).appendTo(head); //$("head").append(""); //$("head").children(":last").attr({"rel": "stylesheet","type": "text/css","hrea": css_href}); } function isIPhone(){ if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { return true; } } function isIE(){ return navigator.appName == "Microsoft Internet Explorer"; } //TODO we need to set a cookie if the users wishes to use a specific sites version //if (document.cookie.indexOf("iphone_redirect=false") == -1) window.location = "/?iphone&i=COMR"; function loadjscssfile(filename, filetype){ if (filetype == "js"){ //if filename is a external JavaScript file var fileref = document.createElement("script"); fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src", filename); }else if (filetype == "css"){ //if filename is an external CSS file var fileref = document.createElement("link"); fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", filename); } if (typeof fileref != "undefined"){ document.getElementsByTagName("head")[0].appendChild(fileref); } } function hsv2rgb(hue, sat, val) { var red, grn, blu, i, f, p, q, t; hue%=360; if(val==0) {return({r:0, g:0, v:0});} sat/=100; val/=100; hue/=60; i = Math.floor(hue); f = hue-i; p = val*(1-sat); q = val*(1-(sat*f)); t = val*(1-(sat*(1-f))); if (i==0) {red=val; grn=t; blu=p;} else if (i==1) {red=q; grn=val; blu=p;} else if (i==2) {red=p; grn=val; blu=t;} else if (i==3) {red=p; grn=q; blu=val;} else if (i==4) {red=t; grn=p; blu=val;} else if (i==5) {red=val; grn=p; blu=q;} red = Math.floor(red*255); grn = Math.floor(grn*255); blu = Math.floor(blu*255); return ({r:red, g:grn, b:blu}); } // function rgb2hsv(red, grn, blu) { var x, val, f, i, hue, sat, val; red/=255; grn/=255; blu/=255; x = Math.min(Math.min(red, grn), blu); val = Math.max(Math.max(red, grn), blu); if (x==val){ return({h:undefined, s:0, v:val*100}); } f = (red == x) ? grn-blu : ((grn == x) ? blu-red : red-grn); i = (red == x) ? 3 : ((grn == x) ? 5 : 1); hue = Math.floor((i-f/(val-x))*60)%360; sat = Math.floor(((val-x)/val)*100); val = Math.floor(val*100); return({h:hue, s:sat, v:val}); } function RGBtoHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)} function toHex(N) { if (N==null) return "00"; N=parseInt(N); if (N==0 || isNaN(N)) return "00"; N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N); return "0123456789ABCDEF".charAt((N-N%16)/16) + "0123456789ABCDEF".charAt(N%16); } function getUsernameOnly(str){ return str.substr(0,str.indexOf("@")); } /* $(document).ready(function() { initialiseLogging(); }); */