/* */ var flashActive = true; //set this to true when flash launches var flashURL = 'http://www.foe.co.uk/serious_about_co2/index.html'; var interFlashURL = 'http://www.foe.co.uk/campaigns/climate/get_serious/inter_flash.html'; var council_id = null; //this to be set lower down from smarty tag var xmlReqs = new Array(); function makeAJAXReq(id, url, parameters, processingFunction, async, isPost, contentType) { if(isPost == undefined) { isPost = true; } if(async == undefined) { async = true; } if(contentType == undefined) { contentType = "text/xml"; } var xml_http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... xml_http_request = new XMLHttpRequest(); if (xml_http_request.overrideMimeType) { // set type accordingly to anticipated content type xml_http_request.overrideMimeType(contentType); //http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { xml_http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { alert('e1'+e); try { xml_http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert('e2'+e); } } } if (!xml_http_request) { alert('Cannot create XMLHTTP instance'); return false; } //alert('params:'+parameters); xml_http_request.onreadystatechange = processingFunction; try{ if(isPost) { xml_http_request.open('POST', url, async); xml_http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xml_http_request.setRequestHeader("Content-length", parameters.length); //http_request.setRequestHeader("Content-Disposition", 'form-data; name="act_updateActionstaken.xml"'); xml_http_request.setRequestHeader("Connection", "close"); xml_http_request.send(parameters); } else { //alert('get params:'+parameters); xml_http_request.open("GET", url+'?'+parameters, async); xml_http_request.send(null); } } catch (e) { alert(e); } xmlReqs[id] = xml_http_request; } function getGall() { //alert('po'); var http_request = xmlReqs[0]; var el; if (http_request!=undefined && http_request.readyState == 4) { if (http_request.status == 200 || http_request.status == 302) { //alert(http_request.responseXML); //var resultstr = http_request.responseText; var photodiv = document.getElementById('photos'); if(photodiv!=null) { photodiv.innerHTML = http_request.responseText; } //alert('sg_processLoginOutput ok'); } else { //alert('2There was a problem with the request. http_request.status: '+http_request.status); } } else { //alert('3There was a problem with the request.'); } } function getEvents() { var xhr = xmlReqs[7]; var el; if (xhr!=undefined && xhr.readyState == 4) { if (xhr.status == 200 || xhr.status == 302) { var newsdiv = document.getElementById('gsevents'); if(newsdiv!=null) { var title,links,titles,publishs,teasers, publishdate, counter = 0; var rXML = xhr.responseXML.documentElement; var newslist = rXML.getElementsByTagName('Event'); var html = ''; //identify council var council_id = readCookie('council_id'); for(i=0;i'+titles[0].childNodes[0].data+'

' html += '

'+teasers[0].childNodes[0].data+' See full article

'; } } html += ''; if(counter>0) { newsdiv.innerHTML = html; } else { newsdiv.innerHTML = 'No events have been uploaded for this target council yet'; } } //alert('sg_processLoginOutput ok'); } else { //alert('2There was a problem with the request. xhr.status: '+xhr.status); } } else { //alert('3There was a problem with the request.'); } } function getPhotos() { var xhr = xmlReqs[8]; var el; if (xhr!=undefined && xhr.readyState == 4) { if (xhr.status == 200 || xhr.status == 302) { var newsdiv = document.getElementById('gsphotos'); if(newsdiv!=null) { var title,links,titles,publishs,teasers, publishdate, counter = 0; var rXML = xhr.responseXML.documentElement; var newslist = rXML.getElementsByTagName('Photo'); var html = '', altTitle = ''; //identify council var council_id = readCookie('council_id'); for(i=0;i

' html += '

'+altTitle+'

'; } } html += ''; if(counter>0) { newsdiv.innerHTML = html; } else { newsdiv.innerHTML = 'No photos have been uploaded for this target council yet'; } } //alert('sg_processLoginOutput ok'); } else { //alert('2There was a problem with the request. xhr.status: '+xhr.status); } } else { //alert('3There was a problem with the request.'); } } var theList = null; function setCouncil () { var xhr = xmlReqs[3]; var el; if (xhr!=undefined && xhr.readyState == 4) { if (xhr.status == 200 || xhr.status == 302) { if(theList!=null) { var title,links,titles,publishs,teasers, publishdate; var rXML = xhr.responseXML.documentElement; var councilslist = rXML.getElementsByTagName('council_id'); if(councilslist!=null && councilslist.length>0 && councilslist[0].childNodes[0]!=undefined) { var cid = councilslist[0].childNodes[0].data; var cidmatch = cid+':'; for(j=0;j'; } } html += ''; if(counter>0) { newsdiv.innerHTML = html; } else { newsdiv.innerHTML = 'No councillor info uploaded for this target council yet'; } } //alert('sg_processLoginOutput ok'); } else { //alert('2There was a problem with the request. xhr.status: '+xhr.status); } } else { //alert('3There was a problem with the request.'); } } function getNews() { //alert('po'); var xhr = xmlReqs[1]; var el; if (xhr!=undefined && xhr.readyState == 4) { if (xhr.status == 200 || xhr.status == 302) { //alert(xhr.responseXML); //var resultstr = xhr.responseText; var newsdiv = document.getElementById('gsnews'); if(newsdiv!=null) { var title,links,titles,publishs,teasers, publishdate, counter = 0; var rXML = xhr.responseXML.documentElement; var newslist = rXML.getElementsByTagName('News'); var html = ''; //identify council if(council_id != '') { } else { council_id = readCookie('council_id'); } for(i=0;i'+titles[0].childNodes[0].data+'

' html += '

'+teasers[0].childNodes[0].data+' See full article

'; } } html += ''; if(counter>0) { newsdiv.innerHTML = html; } else { newsdiv.innerHTML = 'No news has been uploaded for this target council yet'; } } //alert('sg_processLoginOutput ok'); } else { //alert('2There was a problem with the request. xhr.status: '+xhr.status); } } else { //alert('3There was a problem with the request.'); } } //getGrid function getGrid() { //alert('po'); var xhr = xmlReqs[6]; var el,i; if (xhr!=undefined && xhr.readyState == 4) { if (xhr.status == 200 || xhr.status == 302) { var grid = xhr.responseText; if((el = document.getElementById('supportersGridOuter'))!=null) { el.innerHTML = grid; } } else { //alert('2There was a problem with the request. xhr.status: '+xhr.status); } } else { //alert('3There was a problem with the request.'); } } function getCount() { //alert('po'); var xhr = xmlReqs[2]; var el,i; if (xhr!=undefined && xhr.readyState == 4) { if (xhr.status == 200 || xhr.status == 302) { var rXML = xhr.responseXML.documentElement; var counter = rXML.getElementsByTagName('count'); if (counter != null && counter.length > 0) { var sdcount = counter[0].childNodes[0].data; var sddigits = sdcount.split("").reverse(); for(i=0;i Get Serious Central Bedfordshire Council */ //each campaign has an id attribute get serious is gs var j = 0, idatt = null; if(list_of_campaigns!=null) { for(j=0;j0) { for(var ki=0;ki 0 if any missing fields if (invalid_counter !==0){ if (document.getElementById('valid') !==null){ document.getElementById('valid').style.display = "block"; } return false; }else{ return true; } } //onsubmit petition form function onpetitionsubmit() { if(has_valid_text_fields(document.forms.petitionForm)) { return true; } else { return false; } } //pre select council from postcode function setCouncilFromPostcode(councillist,postcodeel) { theList = councillist; //o=councilbypostcode pc if(postcodeel!=undefined && postcodeel.value!='') { makeAJAXReq(3,'/phpscripts/gs_councils.php', 'o=councilbypostcode&pc='+postcodeel.value , setCouncil, true, true); } } function getLocalSupportersList(qs) { makeAJAXReq(4,'/phpscripts/gs_supportergrid.php', qs, setlocalSupportersList, true, true, 'text/html'); } function getCouncilImages() { makeAJAXReq(5,'/phpscripts/getfeed.php', 'feedurl=http://www.foe.co.uk/groups/photos_merge.xml', setCouncilImages, true, true); } 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=/"; } 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; } function eraseCookie(name) { createCookie(name,"",-1); } //flash sniffer /* Copyright (c) Copyright (c) 2007, Carl S. Yestrau All rights reserved. Code licensed under the BSD License: http://www.featureblend.com/license.txt Version: 1.0.4 */ var FlashDetect = new function(){ var self = this; self.installed = false; self.raw = ""; self.major = -1; self.minor = -1; self.revision = -1; self.revisionStr = ""; var activeXDetectRules = [ { "name":"ShockwaveFlash.ShockwaveFlash.7", "version":function(obj){ return getActiveXVersion(obj); } }, { "name":"ShockwaveFlash.ShockwaveFlash.6", "version":function(obj){ var version = "6,0,21"; try{ obj.AllowScriptAccess = "always"; version = getActiveXVersion(obj); }catch(err){} return version; } }, { "name":"ShockwaveFlash.ShockwaveFlash", "version":function(obj){ return getActiveXVersion(obj); } } ]; /** * Extract the ActiveX version of the plugin. * * @param {Object} The flash ActiveX object. * @type String */ var getActiveXVersion = function(activeXObj){ var version = -1; try{ version = activeXObj.GetVariable("$version"); }catch(err){} return version; }; /** * Try and retrieve an ActiveX object having a specified name. * * @param {String} name The ActiveX object name lookup. * @return One of ActiveX object or a simple object having an attribute of activeXError with a value of true. * @type Object */ var getActiveXObject = function(name){ var obj = -1; try{ obj = new ActiveXObject(name); }catch(err){ obj = {activeXError:true}; } return obj; }; /** * Parse an ActiveX $version string into an object. * * @param {String} str The ActiveX Object GetVariable($version) return value. * @return An object having raw, major, minor, revision and revisionStr attributes. * @type Object */ var parseActiveXVersion = function(str){ var versionArray = str.split(",");//replace with regex return { "raw":str, "major":parseInt(versionArray[0].split(" ")[1], 10), "minor":parseInt(versionArray[1], 10), "revision":parseInt(versionArray[2], 10), "revisionStr":versionArray[2] }; }; /** * Parse a standard enabledPlugin.description into an object. * * @param {String} str The enabledPlugin.description value. * @return An object having raw, major, minor, revision and revisionStr attributes. * @type Object */ var parseStandardVersion = function(str){ var descParts = str.split(/ +/); var majorMinor = descParts[2].split(/\./); var revisionStr = descParts[3]; return { "raw":str, "major":parseInt(majorMinor[0], 10), "minor":parseInt(majorMinor[1], 10), "revisionStr":revisionStr, "revision":parseRevisionStrToInt(revisionStr) }; }; /** * Parse the plugin revision string into an integer. * * @param {String} The revision in string format. * @type Number */ var parseRevisionStrToInt = function(str){ return parseInt(str.replace(/[a-zA-Z]/g, ""), 10) || self.revision; }; /** * Is the major version greater than or equal to a specified version. * * @param {Number} version The minimum required major version. * @type Boolean */ self.majorAtLeast = function(version){ return self.major >= version; }; /** * Is the minor version greater than or equal to a specified version. * * @param {Number} version The minimum required minor version. * @type Boolean */ self.minorAtLeast = function(version){ return self.minor >= version; }; /** * Is the revision version greater than or equal to a specified version. * * @param {Number} version The minimum required revision version. * @type Boolean */ self.revisionAtLeast = function(version){ return self.revision >= version; }; /** * Is the version greater than or equal to a specified major, minor and revision. * * @param {Number} major The minimum required major version. * @param {Number} (Optional) minor The minimum required minor version. * @param {Number} (Optional) revision The minimum required revision version. * @type Boolean */ self.versionAtLeast = function(major){ var properties = [self.major, self.minor, self.revision]; var len = Math.min(properties.length, arguments.length); for(i=0; i=arguments[i]){ if(i+10){ var type = 'application/x-shockwave-flash'; var mimeTypes = navigator.mimeTypes; if(mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && mimeTypes[type].enabledPlugin.description){ var version = mimeTypes[type].enabledPlugin.description; var versionObj = parseStandardVersion(version); self.raw = versionObj.raw; self.major = versionObj.major; self.minor = versionObj.minor; self.revisionStr = versionObj.revisionStr; self.revision = versionObj.revision; self.installed = true; } }else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript){ var version = -1; for(var i=0; i= 9) { popup(flashURL); return false; } else { //go to intermediate screen, if intermediate screen has been prepared //go to intermediate screen with el.href in tow popup(interFlashURL); return false; } } } else { //go to intermediate screen, if intermediate screen has been prepared //go to intermediate screen with el.href in tow popup(interFlashURL); return false; } return true; //alert('no flash cookie'); //pop up blocker? //flash blocker? } function readQS(name) { var loc = new String(document.location.href); var nlength = name.length + 1; var start = loc.indexOf(name+'='); if(start != -1) { start += nlength; var end = loc.indexOf('&',start); if(end==-1) { end = loc.length; } return loc.substring(start,end); } return null; } //redirect ?reports to #reports if(window.location.href.indexOf("/campaigns/climate/get_serious/info.html?reports")!=-1) { window.location = '/campaigns/climate/get_serious/info.html#reports'; }