function ExternalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") &&
			anchor.getAttribute("rel") == "external")
		anchor.target = "_blank";
	}
}
window.onload = ExternalLinks;

function GiveFocus(elements) {
	for (i = 0; i < elements.length; i++) {
		if (!elements[i].value) {
			elements[i].focus();
			break;
		}
	}
}

// Share on Facebook function
function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}


// Tweet this function
function twit_click() {u=location.href;t=document.title;window.open('http://twitter.com/home?status='+encodeURIComponent(t)+'%20'+encodeURIComponent(u),'status','toolbar=0,status=0,width=800,height=600');return false;}

//Start Homepage Bookmarker*************************

// return Microsoft Internet Explorer (major) version number, or 0 for others
function msieversion()
{
	var ua = window.navigator.userAgent
	var msie = ua.indexOf ( "MSIE " )
	if ( msie > 0 )		// is Microsoft Internet Explorer; return version number
		return parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) )
	else
		return 0	// is other browser
}


// return Firefox version number, or 0 for others
function firefoxversion()
{
	var ua = window.navigator.userAgent;
	var ff = ua.indexOf ( "Firefox" );
	if ( ff > 0 )	{	// is Firefox; return version number
		var version =  parseInt ( ua.substring ( ff+8, ua.indexOf ( ".", ff ) ) );
		return version
	}
	 
	else
		return 0	// is other browser
}

// Set Epons as home page
function setEponsHomePage(n) {

	domain = getDomain();

	if (domain !='' && navigator.appVersion.indexOf("MSIE")!=-1) {

		n.style.behavior='url(#default#homepage)';
		n.setHomePage("http://www" + domain);

		return false;
	} else 
		return true; 
}


// Add Epons to Favorites
function addToFavorites() { 
	
	domain = getDomain();

	if (domain != "" && window.external) { 

		window.external.AddFavorite("http://www" + domain,"Epons") 

	} 
		else { alert("Sorry! Your browser doesn't support this function."); 
	} 
} 

// Get the domain from the window location
function getDomain()
{
	href = window.location.href;
	
	start = href.indexOf(".wsmvepons.")

	if(start !=-1) {
		end = href.indexOf("/", start)
		
		href = href.substring(start, end);
	} else
		href = "";
	
	return href;
}
//End HomePage Bookmarker*******************

// image print ***************
var pwin;
function printImg(printOption) {
    var html = printOption;
        pwin = window.open(html, 'Print', 'width=600 height=450');
    setTimeout("pwin.print()" ,2000);
}
