/////////////////////////////////////////////////////////////////// // // // Javascript functions for tix/SYS On-Line Film Guide // // // // copyright (c) 2000 synercom/edi - All Rights Reserved // // // // written by Arne F. Hermann // // // // // //////////////////////////////////////////////////////////////////// function tixSYS_body_onload() { /** * tixSYS_body_onload(); is a content replacement * item - this function is to keep the call valid * should it not be replaced. - dt - 20051121 */ } function removeNonNumeric( strString ) { // Variables var strValidCharacters = "1234567890"; var strReturn = ""; var strBuffer = ""; var intIndex = 0; // Loop through the string for( intIndex = 0; intIndex < strString.length; intIndex++ ) { // Get this character strBuffer = strString.substr( intIndex, 1 ); // Is this a number if( strValidCharacters.indexOf( strBuffer ) > -1 ) { // Yes strReturn += strBuffer; } } // Return the value return strReturn; } function removeNonDecimal( strString ) { // Variables var strValidCharacters = "1234567890."; var strReturn = ""; var strBuffer = ""; var intIndex = 0; // Loop through the string for( intIndex = 0; intIndex < strString.length; intIndex++ ) { // Get this character strBuffer = strString.substr( intIndex, 1 ); // Is this a number if( strValidCharacters.indexOf( strBuffer ) > -1 ) { // Yes strReturn += strBuffer; } } // Return the value return strReturn; } function number_format(number, decimals, dec_point, thousands_sep) { // Formats a number with grouped thousands // // version: 1001.2911 // discuss at: http://phpjs.org/functions/number_format // + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + bugfix by: Michael White (http://getsprink.com) // + bugfix by: Benjamin Lupton // + bugfix by: Allan Jensen (http://www.winternet.no) // + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) // + bugfix by: Howard Yeend // + revised by: Luke Smith (http://lucassmith.name) // + bugfix by: Diogo Resende // + bugfix by: Rival // + input by: Kheang Hok Chin (http://www.distantia.ca/) // + improved by: davook // + improved by: Brett Zamir (http://brett-zamir.me) // + input by: Jay Klehr // + improved by: Brett Zamir (http://brett-zamir.me) // + input by: Amir Habibi (http://www.residence-mixte.com/) // + bugfix by: Brett Zamir (http://brett-zamir.me) // + improved by: Theriault // * example 1: number_format(1234.56); // * returns 1: '1,235' // * example 2: number_format(1234.56, 2, ',', ' '); // * returns 2: '1 234,56' // * example 3: number_format(1234.5678, 2, '.', ''); // * returns 3: '1234.57' // * example 4: number_format(67, 2, ',', '.'); // * returns 4: '67,00' // * example 5: number_format(1000); // * returns 5: '1,000' // * example 6: number_format(67.311, 2); // * returns 6: '67.31' // * example 7: number_format(1000.55, 1); // * returns 7: '1,000.6' // * example 8: number_format(67000, 5, ',', '.'); // * returns 8: '67.000,00000' // * example 9: number_format(0.9, 0); // * returns 9: '1' // * example 10: number_format('1.20', 2); // * returns 10: '1.20' // * example 11: number_format('1.20', 4); // * returns 11: '1.2000' // * example 12: number_format('1.2000', 3); // * returns 12: '1.200' var n = !isFinite(+number) ? 0 : +number, prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, dec = (typeof dec_point === 'undefined') ? '.' : dec_point, s = '', toFixedFix = function (n, prec) { var k = Math.pow(10, prec); return '' + Math.round(n * k) / k; }; // Fix for IE parseFloat(0.55).toFixed(0) = 0; s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); if (s[0].length > 3) { s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); } if ((s[1] || '').length < prec) { s[1] = s[1] || ''; s[1] += new Array(prec - s[1].length + 1).join('0'); } return s.join(dec); } function getObject( obj ) { // step 1 if ( document.getElementById ) { obj = document.getElementById( obj ); // step 2 } else if ( document.all ) { obj = document.all.item( obj ); //step 3 } else { obj = null; } //step 4 return obj; } function displayObject( obj, show ) { // step 1 obj = getObject( obj ); if (obj==null) return; // step 2 obj.style.display = show ? 'block' : 'none'; obj.style.visibility = show ? 'visible' : 'hidden'; } /** * This use by pkg mode to move parent window to login via * the addtoplanner routine */ function goParent(loc){ var parentwin = window.opener; var grandparentwin = parentwin.opener; if(grandparentwin){ grandparentwin.location.href=loc; window.close(); } if(parentwin){ parentwin.location.href=loc; window.close(); } } function AddToCart(FCode) { var WinName = window.name; document.AddCodeForm.AddCode.value = FCode; hAddWin=window.open("AddToCart.php?FCode=" + FCode,"AddWindow","width=400,height=200,left=200,top=300,scrollbars=no,toolbar=no,status=no,directories=no,location=no,menubar=no,resizable=no"); } function AddToPkg(FCode,PageFrom) { document.AddCodeForm.AddCode.value = FCode; hAddWin=window.open("addtoplannerpkg.php?FCode=" + FCode + "?PageFrom="+PageFrom,"AddWindow","width=400,height=200,left=200,top=300,scrollbars=no,toolbar=no,status=no,directories=no,location=no,menubar=no,resizable=no"); } function getCookieVal (offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } // Function to correct for 2.x Mac date bug. function FixCookieDate (date) { var base = new Date(0); var skew = base.getTime(); // dawn of (Unix) time - should be 0 if (skew > 0) // Except on the Mac - ahead of its time date.setTime (date.getTime() - skew); } // Function to return the value of the cookie specified by "name". function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return "NOTSET"; } // Function to create or update a cookie. function SetCookie (name,value,expires,path,domain,secure) { //var tett = new Date(); //alert(tett.toGMTString(expires)); path="/"; document.cookie = name + "=" + escape (value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); } // Function to delete a cookie. (Sets expiration date to start of epoch) function DeleteCookie (name,path,domain) { path="/"; if (GetCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } function UpdateTotals(FCode,SChgType,SChgAmt,MaxTix) { var Amount = 0; var Quantity = 0; var DAmount = ""; var HChgAmount = 0; var pr=""; var qq = ""; var Elem = ""; var numelems = document.OrderForm.length; for (var ii=0; ii < numelems; ii=ii+1) { Elem = document.OrderForm.elements[ii]; FCode = Elem.name; if (FCode.substr(0,1) == "Q"){ pr = eval("document.OrderForm.Price" + FCode.substr(1) + ".value"); qq = Elem.selectedIndex; Amount += qq * pr; if (FCode.substr(1,1) != "i") { //eval qty for NON-ITEMS (i.e. tickets) only Quantity += parseFloat(qq); } if (Quantity > MaxTix) { alert("You can only select a maximum of " + MaxTix + " tickets on a single ticket order. \nThe Qty for this show will be reset to zero.") Quantity = Quantity - Elem.selectedIndex; Elem.selectedIndex = 0; } } } //Fix the format of Amount... if (Amount > 0) { // Add in will-call handling charge switch (SChgType) { case 'P': //Percentage of Order Total Amount = parseFloat(Amount) + (Amount * parseFloat(SChgAmt)); break; case 'F': //Flat Rate per Order Amount = parseFloat(Amount) + parseFloat(SChgAmt); HChgAmount = parseFloat(SChgAmt); break; case 'T': //Flat Rate per Ticket Amount = parseFloat(Amount) + (parseFloat(SChgAmt) * Quantity); HChgAmount = parseFloat(SChgAmt) * Quantity; break; } if (document.getElementById('MailOrder').checked) { // Hamptons Specific for $1 mail charge //Amount = Amount + 1; //document.OrderForm.MailOrderChg.value = "1.00"; } //Format to [nnn]n.dd Amount = (Math.ceil(Amount * 100))/100; DAmount = "A"+Amount; DAmount = DAmount.substr(1); if (DAmount.indexOf(".") < 1) { DAmount = DAmount + ".00"; } else { DAmount = DAmount + "00"; DAmount = DAmount.substr(0,DAmount.indexOf(".")+3); } HChgAmount = "A"+HChgAmount; HChgAmount = HChgAmount.substr(1); if (HChgAmount.indexOf(".") < 1) { HChgAmount = HChgAmount + ".00"; } else { HChgAmount = HChgAmount + "00"; HChgAmount = HChgAmount.substr(0,HChgAmount.indexOf(".")+3); } } document.OrderForm.OrderAmount.value = DAmount; document.OrderForm.HChgAmount.value = HChgAmount; document.OrderForm.NumberTix.value = Quantity; } //php document related functions function swapImgRestore() { //v3.0 var i,x,a=document.sr; for(i=0;a&&i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i 0){ numEntries++; if(contentLength < 5){ brokenEntries++; } } } if((brokenEntries > 0) || (numEntries == 0)){ alert("There appears to be a problem with your form.\n You must enter at least ONE Film Code\n and Film Codes must all be 5 characters in length."); result = false; } else{ result = true; } return result; } function replaceSubstring(inputString, fromString, toString) { // Goes through the inputString and replaces every occurrence of fromString with toString var temp = inputString; if (fromString == "") { return inputString; } if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation) while (temp.indexOf(fromString) != -1) { var toTheLeft = temp.substring(0, temp.indexOf(fromString)); var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length); temp = toTheLeft + toString + toTheRight; } } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop var midStrings = new Array("~", "`", "_", "^", "#"); var midStringLen = 1; var midString = ""; // Find a string that doesn't exist in the inputString to be used // as an "inbetween" string while (midString == "") { for (var i=0; i < midStrings.length; i++) { var tempMidString = ""; for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; } if (fromString.indexOf(tempMidString) == -1) { midString = tempMidString; i = midStrings.length + 1; } } } // Keep on going until we build an "inbetween" string that doesn't exist // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string while (temp.indexOf(fromString) != -1) { var toTheLeft = temp.substring(0, temp.indexOf(fromString)); var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length); temp = toTheLeft + midString + toTheRight; } // Next, replace the "inbetween" string with the "toString" while (temp.indexOf(midString) != -1) { var toTheLeft = temp.substring(0, temp.indexOf(midString)); var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length); temp = toTheLeft + toString + toTheRight; } } // Ends the check to see if the string being replaced is part of the replacement string or not return temp; // Send the updated string back to the user } // Ends the "replaceSubstring" function /* GRID */ function movegrid(){ // centers grid in window. var gridWidth = document.getElementById('venuebar').style.width; gridWidth = replaceSubstring(gridWidth, "px", "") var winW = 630, winH = 460; if (parseInt(navigator.appVersion)>3) { if (navigator.appName=="Netscape") { winW = window.innerWidth; winH = window.innerHeight; } if (navigator.appName.indexOf("Microsoft")!=-1) { winW = document.body.offsetWidth; winH = document.body.offsetHeight; } } var leftoffset = (winW - gridWidth)/2 - 35; var allDivs = document.all.tags('div'); var leftpx; for(var i = 0; i < allDivs.length; i++){ leftpx = allDivs[i].style.left; if(leftpx.length > 0){ leftpx = leftpx.substring(0,leftpx.indexOf('px')); var newleft = parseInt(leftpx) + leftoffset; allDivs[i].style.left = newleft; } } } var speed, currentpos=curpos1=0, alt=1, curpos2=-1 function initializeScroll(){ if (window.parent.scrollspeed!=0){ speed=window.parent.scrollspeed scrollwindow(); } } function scrollwindow(){ temp=(document.all)? document.body.scrollLeft : window.pageXOffset; alt=(alt==0)? 1 : 0; if(alt==0){ curpos1=temp; } else{ curpos2=temp; } window.scrollBy(speed,0); } /* MM IMAGE SWAPPING */ function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i>> 32, but since JS converts // bitwise-op args to 32 bits, we need to simulate this by arithmetic operators M[N-1][14] = ((msg.length-1)*8) / Math.pow(2, 32); M[N-1][14] = Math.floor(M[N-1][14]) M[N-1][15] = ((msg.length-1)*8) & 0xffffffff; // set initial hash value [§5.3.1] var H0 = 0x67452301; var H1 = 0xefcdab89; var H2 = 0x98badcfe; var H3 = 0x10325476; var H4 = 0xc3d2e1f0; // HASH COMPUTATION [§6.1.2] var W = new Array(80); var a, b, c, d, e; for (var i=0; i>>(32-n)); } // // extend Number class with a tailored hex-string method // (note toString(16) is implementation-dependant, and // in IE returns signed numbers when used on full words) // Number.prototype.toHexStr = function() { var s="", v; for (var i=7; i>=0; i--) { v = (this>>>(i*4)) & 0xf; s += v.toString(16); } return s; }