//..Open external links in a new window
//..Extenal links should be marked with rel tag
//..Ex:
//..<a href="http://www.someting.com" rel="external">external link</a>
//..
function externalLinks() {
		if (!document.getElementsByTagName) return; 
		
		var anchors = document.getElementsByTagName("a"); 
		for (var i=0; i<anchors.length; i++) { 
			var anchor = anchors[i];
			
			//..alert(anchor);
			 
			if (anchor.getAttribute("href") && 
				anchor.getAttribute("rel") == "external") 
				anchor.target = "_blank"; 
		} 
 
		//..Open the feedBurner form in a new window
		//.. 
		var feedBurnerForm = document.getElementById("feedBurnerForm"); 
		if(feedBurnerForm != null){
			//..Debug
			//..alert("FeedBurnerForm set to open new window");
			feedBurnerForm.target="_blank";
		}
		
		//..Show the foto of author
		var photoDiv = document.getElementById("photoDiv");
		var d = new Date();
		var i = d.getMinutes()%5;
		photoDiv.innerHTML = "<img class='photo' src='http://www.makelogic.com/blogs/wp-content/themes/default/images/Ujjwal_" + i + ".jpg' alt='Madanu' title='Madanu Ujjwal Kumar'/>";
		
		
		//..Get all <a> tags that lead to other web sites
		if (!document.getElementsByTagName) return; 
		
		var allAnchors = document.getElementsByTagName("a"); 
		for (var i=0; i<allAnchors.length; i++) { 
			var thisAnchor = allAnchors[i];
			var href = thisAnchor.getAttribute("href");
			href = href.toLowerCase();
			
			
			if (  (href.substring(0,7) == "http://")  
			      && 
				  (href.indexOf("www.makelogic.com") == -1)
				  &&
				  (href.indexOf("www.makelogicmldb.com") == -1)
			   )
			{
				 
				//..Set target to open in new window
				thisAnchor.target = "_blank";
				
				//if(!thisAnchor.title){
				//	thisAnchor.title = "Opens in new window";
				//}
				//alert("External Link : " + thisAnchor );
			}			
		} 
} 

window.onload = externalLinks;

