///////////////
//zip code get
//
//Browser Support Code
function getWbugForecast(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
	
		if(ajaxRequest.readyState == 1){
			var ajaxDisplay = document.getElementById('wbugDiv');
			ajaxDisplay.innerHTML = '<table border="0" height="90" width="292" style="border: 1px solid #000;"><tr><td><center><img src="http://www.farmersalmanac.com/wp-content/plugins/weatherbug-widget/images/loading.gif" border=0><br>Loading...</td></tr></table>';
		}
		
	
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('wbugDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
		
	}
	var zipcode = document.getElementById('zipcode').value;
	
	var queryString = "?zipcode=" + zipcode;
	ajaxRequest.open("GET", "http://www.farmersalmanac.com/wp-content/plugins/weatherbug-widget/wbug.display.php" + queryString, true);
	ajaxRequest.send(null);

////////////
//shoot me	
var ajaxRequest2;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest2 = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest2 = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest2 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest2.onreadystatechange = function(){
	
		if(ajaxRequest2.readyState == 1){
			var ajaxDisplay = document.getElementById('wbugZipDiv');
			ajaxDisplay.innerHTML = '<center><a href="#" class="wbug">Gathering Information</a><br /><img src="http://www.farmersalmanac.com/wp-content/plugins/weatherbug-widget/images/powered_by.gif" border="0" width="134" height="18"><center>';
		}
		
	
		if(ajaxRequest2.readyState == 4){
			var ajaxDisplay = document.getElementById('wbugZipDiv');
			ajaxDisplay.innerHTML = ajaxRequest2.responseText;
		}
		
	}
	var zipcode = document.getElementById('zipcode').value;

	ajaxRequest2.open("GET", "http://www.farmersalmanac.com/wp-content/plugins/weatherbug-widget/wbug.linkback.php?zipcode=" + zipcode, true);
	ajaxRequest2.send(null); 
	
}

/////////////
//for forecast tabs
//
var ids=new Array('wb0','wb1','wb2','wb3');

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

//////////////
