// To get a referrer page function getReferrer(){ var referrerPage = document.referrer; //document.frm.eGrabberReferrerURL.value = referrerPage; // To insert a promo value in a lead_source hidden field insertPromo(); // For google search keyword read(); // To get a time zone and store it in a timezone hidden field calculate_time_zone(); } // To set a google keywords in a searchkeyword field function read(){ var keyword = readCookie("keyword"); var referrerurl = readCookie("referrerurl"); var jrox = readCookie("jrox"); if(keyword=="") document.frm.searchkeyword.value = "No keyword found"; else document.frm.searchkeyword.value = keyword; if(referrerurl=="") document.frm.eGrabberReferrerURL.value = "No keyword found"; else document.frm.eGrabberReferrerURL.value = referrerurl; if(jrox!="") document.frm.jrox.value = jrox; } // To read a cookie function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while(c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } // To erase a cookie function eraseCookie(name) { createCookie(name,"",-1); } // To get a client system time function getTime(){ var currentTime = new Date(); var hours = currentTime.getHours(); var minutes = currentTime.getMinutes(); var time = hours + ":" + minutes; return(time); } // To calculate a client time zone function calculate_time_zone() { var timezoneOffsetArray = new Array("-12:00","-11:00","-10:00","-09:30","-09:00", "-08:00","-07:00","-06:00","-05:00", "-04:00","-03:30","-03:00","-02:00", "-01:00","00:00","+01:00","+02:00", "+03:00","+03:30","+04:00","+04:30", "+05:00","+05:30","+05:45","+06:00", "+06:30","+07:00","+08:00","+09:00", "+09:30","+10:00","+10:30","+11:00","+11:30","+12:00"); var timezoneArray = new Array("IDLW","SST","HST","MART","AKST", "PST","MST","CST","EST", "AST","NST","BST","FDT", "AT","GMT","CET","EET", "MSK","IT","GST","AFT", "PKT","IST","NPT","BDT", "MMT","ICT","HKT","KST", "ACST","AEST","LHST","SBT","NFT","NZT"); var rightNow = new Date(); var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); // jan 1st var june1 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0); // june 1st var temp = jan1.toGMTString(); var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); temp = june1.toGMTString(); var june2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1)); var std_time_offset = (jan1 - jan2) / (1000 * 60 * 60); var daylight_time_offset = (june1 - june2) / (1000 * 60 * 60); var dst; if (std_time_offset == daylight_time_offset) { dst = "0"; // daylight savings time is NOT observed } else { // positive is southern, negative is northern hemisphere var hemisphere = std_time_offset - daylight_time_offset; if (hemisphere >= 0) std_time_offset = daylight_time_offset; dst = "1"; // daylight savings time is observed } var time = getTime(); for (i=0; i 0) ? "+0"+hours : "+"+hours; // positive display_hours = (hours == 0) ? "0"+hours : display_hours; // handle GMT case (00:00) display_hours = (hours < 0 && hours > -10) ? "-0"+Math.abs(hours) : display_hours; // neg mins = (mins < 10) ? "0"+mins : mins; return display_hours+":"+mins; } // Change made in the function to split the jrox cookie properly function insertPromo(){ var pattern = /-\d-\d-\d-+/; var ATScookie = readCookie("jrox"); if(ATScookie!=='' && ATScookie!==null){ var patternSplit = ATScookie.split(pattern); if(patternSplit.length==2){ document.frm.lead_source.value = patternSplit[1]; } } } /* // To get a promo for CRM function insertPromo(){ var campaign = ""; var ATScookie = readCookie("jrox"); if(ATScookie!=='' && ATScookie!==null){ var campaignArray = ATScookie.split("-"); var campaign = campaignArray[5]; if(campaign!=='' && campaign!==undefined){ document.frm.lead_source.value = campaign; } } } */