// JavaScript Document
if (window.location.href.indexOf("_cmxprint") != -1){
	setActiveStyleSheet('print');
	cmxPrint();
}
function cmxPrint(){
	if (QueryString("_cmxprint") != null)
		window.print();
	else{
		var url = _normalizeUrl(location.href);
		url += (url.indexOf('?') >= 0) ? '&' : '?';
		url += "_cmxprint=1";
		window.open(url, "_blank").moveBy(40, 40);
	}
}


function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title){
		  a.disabled = false;
	  }
    }
  }
}


function QueryString(name){
	var re = new RegExp("(?:\\?|&)" + name + "\\=([^&]*)(?:&|$)","i");
	var q = location.search.match(re);
	return q ? unescape(q[1]) : null;
	/*
	var a = unescape(location.search.substring(1)).split('&');
	name += '=';
	var nlen = name.length;
	for (var n = 0; n < a.length; n++)
		if (a[n].substr(0, nlen) == name)
			return a[n].substr(nlen);
	return null;
	*/
}

function _normalizeUrl(url){
  var dot = url.lastIndexOf('.');
  var slash = url.lastIndexOf('/');
  if (dot <= slash){
		if (url.charAt(url.length - 1) != '/')
			url += '/';
			url += "index.html";
  }
  return url;
}


function addBookmark() {
	var url=location.href;
	var title=document.title;
	if (document.all) {
	    window.external.addFavorite(url,title);
	}else if (window.sidebar) {
		window.sidebar.addPanel(title, url, "")
	}else if (window.opera && window.print) {
	    return true;
	}
}

function EmailPage() {
    document.email_form.Link.value=location.href;
    document.email_form.submit();
}