

var months = [ "January" , "Febuary" , "March" , "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December" ];

function parseBlogData( xhr , wich ) {
	if( xhr.readyState == 4  && xhr.status == 200  ) {
		document.getElementById( "ew-blogs" ).style.display = "block";
		xhrRoot = xhr.responseXML;
		var bItem = xhrRoot.getElementsByTagName( "item" )[ 0 ];
		var bTitle = bItem.getElementsByTagName( "title" )[ 0 ].firstChild.nodeValue;
		var bDesc = ( bItem.getElementsByTagName( "description" )[ 0 ].childNodes.length == 0 ) ? bItem.getElementsByTagName( "title" )[ 0 ].firstChild.nodeValue : bItem.getElementsByTagName( "description" )[ 0 ].firstChild.nodeValue;
		var bLink = bItem.getElementsByTagName( "link" )[ 0 ].firstChild.nodeValue;
		var bDate = ( bItem.childNodes[ bItem.childNodes.length - 1 ].nodeType == 1 ) ? bItem.childNodes[ bItem.childNodes.length - 1 ].firstChild.nodeValue : bItem.childNodes[ bItem.childNodes.length - 1 ].previousSibling.firstChild.nodeValue;
		// var bDate = xhrRoot.getElementsByTagNameNS( "http://purl.org/rss/1.0/" , "date" )[ 0 ].firstChild.nodeValue;
		var re = /(^\d+)-(\d+)-(\d+)T(.*)/;
		var str = bDate;
		var match = re.exec( str );
		var year = match[ 1 ];
		var mon = match[ 2 ];
		var day = match[ 3 ];
		var time = match[ 4 ];
		/* 20080805 parse leading zero */
		mon = mon.replace(/^0/, "");
		
		
		document.getElementById( wich + "-time" ).innerHTML = months[ parseInt( mon ) - 1 ] + " " + day + ", " + year ;
		// document.getElementById( wich + "-header" ).innerHTML = bTitle;
		// document.getElementById( wich + "-desc" ).innerHTML = bDesc + "<a id=\"" + wich + "-link\" href=\"#\">More</a>";
		document.getElementById( wich + "-desc" ).innerHTML = bTitle + "&nbsp;<a id=\"" + wich + "-link\" href=\"#\">More</a>";
		document.getElementById( wich + "-link" ).setAttribute( "href" , bLink );
	} else {
		// document.getElementById( "ew-blogs" ).style.display = "none";
	}
}



function getBlogs( path , wich ) {
	var xhrRoot;
	var xhr = window.ActiveXObject ? new ActiveXObject( "Microsoft.XMLHTTP" ) : new XMLHttpRequest();
	xhr.onreadystatechange = function( e ) {
		parseBlogData( xhr , wich );
	}
	
	try {
		xhr.open( "get" , path , true );
		xhr.send( null );
	} catch( e ) {
		window.status = e;
	}
}
/*
	
*/
			function ew_changeSubmit() {
				document.getElementById("inp_email").value = "Enter email address"
			
				function ew_empty() {
					if(document.getElementById("inp_email").value == "Enter email address") {
						document.getElementById("inp_email").value = "";
					}
				}
				
				function ew_full() {
					if(document.getElementById("inp_email").value == "") {
						document.getElementById("inp_email").value = "Enter email address"
					}
				}
			
				tii_addEventHandler(document.getElementById("inp_email"), "focus", ew_empty, false);
				tii_addEventHandler(document.getElementById("inp_email"), "blur", ew_full, false);
			}
			
			tii_callFunctionOnWindowLoad(ew_changeSubmit);
/*
	
*/ 