var feedAmount=16;var rotation=true;var currentLocation=0;google.load("feeds","1");function initialize(){var feed=new google.feeds.Feed(worldLocations[currentLocation]);feed.setNumEntries(feedAmount);feed.load(function(result){if(!result.error){var container=document.getElementById("weatherForcast");if(container.hasChildNodes()){while(container.childNodes.length>=1){container.removeChild(container.firstChild)}}for(var i=0;i<result.feed.entries.length;i++){var entry=result.feed.entries[i];var entryTitle=entry.title;if(entryTitle.indexOf("forecast")!=-1){var div=document.createElement("div");var a=document.createElement("a");var href=document.createAttribute("href");var target=document.createAttribute("target");href.nodeValue=entry.link;target.nodeValue="_blank";a.setAttributeNode(target);a.setAttributeNode(href);a.appendChild(document.createTextNode(entry.title));var des=document.createElement("div");des.innerHTML=entry.content;var br0=document.createElement("br");var br1=document.createElement("br");var br2=document.createElement("br");container.appendChild(a);container.appendChild(br0);container.appendChild(br1);container.appendChild(des)}}}})}function countryPicker(){var IPCountry;var IPCountry=getCookie("co");if(IPCountry=="NEW ZEALAND"){IPCountry="NEW_ZEALAND"}if(IPCountry=="NEW+ZEALAND"){IPCountry="NEW_ZEALAND"}if(IPCountry=="UNITED KINGDOM"){IPCountry="UNITED_KINGDOM"}if(IPCountry=="UNITED+KINGDOM"){IPCountry="UNITED_KINGDOM"}if(IPCountry=="UNITED+STATES"){IPCountry="UNITED_STATES"}if(IPCountry=="UNITED STATES"){IPCountry="UNITED_STATES"}if(IPCountry=="SOUTH+AFRICA"){IPCountry="SOUTH_AFRICA"}if(IPCountry=="SOUTH AFRICA"){IPCountry="SOUTH_AFRICA"}if(IPCountry=="RUSSIAN FEDERATION"){IPCountry="RUSSIAN_FEDERATION"}if(IPCountry=="RUSSIAN+FEDERATION"){IPCountry="RUSSIAN_FEDERATION"}if(IPCountry=="CZECH REPUBLIC"){IPCountry="CZECH_REPUBLIC"}if(IPCountry=="CZECH+REPUBLIC"){IPCountry="CZECH_REPUBLIC"}var acceptedCountries=Array("AUSTRALIA","NEW_ZEALAND","UNITED_KINGDOM","UNITED_STATES","CANADA","FRANCE","ITALY","GERMANY","SOUTH_AFRICA","AUSTRIA","HUNGARY","SWEDEN","NETHERLANDS","GREECE","LUXEMBOURG","MALTA","ROMANIA","PORTUGAL","RUSSIAN_FEDERATION","CZECH_REPUBLIC","POLAND","CHINA","NORWAY","BRAZIL");var acceptedCountriesFound=false;for(ipc=0;ipc<acceptedCountries.length;ipc++){if(IPCountry==acceptedCountries[ipc]){acceptedCountriesFound=true}}if(acceptedCountriesFound==false){IPCountry="GLOBAL"}var countryFileName="js/countries/"+IPCountry+".js";$.ajax({url:countryFileName,dataType:"script",success:countryPreparation})}function countryPreparation(){currentLocation=Math.floor(Math.random()*(worldLocations.length-1));var setLocation=getCookie("ci");if(setLocation!=null&&setLocation!=""&&setLocation<=worldLocations.length){clearTimeout(timeoutRotator);rotation=false;currentLocation=setLocation}dropdownConstructor();locationChanger()}var timeoutRotator;function locationChanger(){initialize();currentLocation+=1;if(currentLocation>worldLocations.length-1){currentLocation=0}if(rotation==true){timeoutRotator=setTimeout(locationChanger,10000)}}function getCookie(c_name){var i,x,y,ARRcookies=document.cookie.split(";");for(i=0;i<ARRcookies.length;i++){x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);x=x.replace(/^\s+|\s+$/g,"");if(x==c_name){return unescape(y)}}}function setCookie(c_name,value,exdays){var exdate=new Date();exdate.setDate(exdate.getDate()+exdays);var c_value=escape(value)+((exdays==null)?"":"; expires="+exdate.toUTCString());document.cookie=c_name+"="+c_value}function dropdownConstructor(){var constructedDropdown="<select name='select' id='weatherController' style='width:110px;' class='inputClass' onchange='dropdownSelector(this.value)'>";constructedDropdown+="<option value='null'>Select Location</option>";for(i=0;i<worldLocationsDrop.length;i++){if(currentLocation==i){optionSelected="selected='selected'"}else{optionSelected=""}constructedDropdown+="<option value='"+i+"' "+optionSelected+">"+worldLocationsDrop[i]+"</option>"}constructedDropdown+="</select>";document.getElementById("weatherForcastController").innerHTML=constructedDropdown}function dropdownSelector(selectedValue){if(selectedValue!="null"){clearTimeout(timeoutRotator);rotation=false;currentLocation=selectedValue;locationChanger();setCookie("ci",selectedValue,1825)}}google.setOnLoadCallback(countryPicker);
