function downloadDemo() { if (confirmLegal()) { window.location.href = "ftp://largedownloads.ea.com/pub/demos/crysis/crysis_demo.exe"; } } /** * loadPage - Loads a page into a div * @param {string} the url you want to load * @param {string} the id of the div you wanto to populate */ function loadPage(url, divId) { if (window.XMLHttpRequest) { // Non-IE browsers req = new XMLHttpRequest(); req.onreadystatechange = function() { targetDiv(divId) }; try { req.open("GET", url, true); } catch (e) { alert(e); } req.send(null); } else if (window.ActiveXObject) { // IE req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = function() { targetDiv(divId) }; req.open("GET", url, true); req.send(); } } } /** * targetDiv - Waits until the request is complete and makes sure and ok response was sent back * then populates the div with the html from the requested url * @param {divId} the id of the div you wanto to populate */ function targetDiv(divId) { if (req.readyState == 4) { // Complete if (req.status == 200) { // OK response document.getElementById(divId).innerHTML = req.responseText; var scriptTags = document.getElementById(divId).getElementsByTagName('script'); for(i=0; i < scriptTags.length; i++){ eval(scriptTags[i].innerHTML); } return false; } else { alert("Error: " + req.statusText); } } } /** * setCurSideNav - Checks to see if an object has a class current, if it does then * it removes it. Sets curAnchor to have a class of type current * @param {curAnchor} an anchor object */ function setCurNavItem(parentId, curAnchor){ var anchors = document.getElementById(parentId).getElementsByTagName('a'); for(i=0; i < anchors.length; i++){ if(hasClass(anchors[i], 'current')){ setClass(anchors[i], 'current', false); } } setClass(curAnchor, 'current', true); } /** * hasClass - Returns true if the element has the class, false otherwise * @param {el} a html element * @param {name} a class name */ function hasClass(el, name) { return el && el.className && new RegExp('(?:^|\\s)' + name + '(?:\\s|$)').test(el.className); } /** * addClass - Adds a class to an object * @param {el} a html element * @param {name} a class name */ function addClass(el, name) { if (!hasClass(el, name)) el.className += (el.className ? ' ' : '') + name; } /** * KillClass - Removes a class from an object * @param {el} a html element * @param {name} a class name */ function delClass(el, name) { if (hasClass(el, name)) el.className = el.className.replace(new RegExp('^(?:' + name + '(?:\\s+|$))+|\\s+' + name + '\\s*(?=\\s|$)', 'g'), ''); } /** * setClass - if true is passed in then it will add a class, else it will delete a class * @param {el} a html element * @param {name} a class name * @param {add} a boolean value of true or false */ function setClass(el, name, add) { return add ? addClass(el, name) : delClass(el, name); } /** * checkDate - checks is all selects have been changed, if they have it checks to see if * a user is 17+, if they are it sets a cookie, else displays error message */ function checkDate(){ var isEmpty = true; var selects = document.getElementById("age-form").getElementsByTagName('select'); for(i=0; i < selects.length; i++){ if(selects[i].value == ""){ isEmpty = false; } } if(isEmpty){ var dateOfBirth = new Date (document.getElementById("birthyear").value, document.getElementById("birthmonth").value - 1, document.getElementById("birthday").value); var todayDate = new Date(); var seventeenYearsAgo = new Date(todayDate.getFullYear()-17, todayDate.getMonth(), todayDate.getDate(),0,0,0); if(dateOfBirth <= seventeenYearsAgo){ setCookie('/crysis/home.jsp', 'crysis_age_verification'); } else { document.getElementById("age_verification").innerHTML = "
SORRY. UNFORTUNATELY, YOU ARE TOO YOUNG TO VIEW THESE MATERIALS
"; } } } /** * setCookie - sets a cookie for a url * @param {path} url to be stored in the cookie * @param {name} name of the cookie */ function setCookie(path, name) { location.href = path; createCookie(name, path, 20); } /** * deleteCookie - deletes a cookie * @param {path} url to be stored in the cookie * @param {name} name of the cookie * @param {domain} domain of the cookie */ function deleteCookie(name, path, domain ) { if (getCookie(name)) document.cookie = name + "=" + (( path ) ? ";path=" + path : "") + (( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; } /** * createCookie - creates a cookie * @param {value} calue to be stored in the cookie * @param {name} name of the cookie * @param {days} number of days before cookie expires */ function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else { var expires = ""; } document.cookie = name+"="+value+expires+"; path=/"; } /** * getCookie - gets a cookie * @param {name} name of the cookie */ function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else { begin += 2; } var end = document.cookie.indexOf(";", begin); if (end == -1) { end = dc.length; } return unescape(dc.substring(begin + prefix.length, end)); } /** * Son of Suckerfih Drop Downs */ sfHover = function() { var sfEls = document.getElementById("nav").getElementsByTagName("LI"); for (var i=0; i