// popup windows 
var newWin = null; 
function popUp(strURL, strType, strHeight, strWidth) { 
 if (newWin != null && !newWin.closed) 
   newWin.close(); 
 var strOptions=""; 
 if (strType=="console") 
   strOptions="resizable,height="+ 
     strHeight+",width="+strWidth; 
 if (strType=="fixed") 
   strOptions="status,height="+ 
     strHeight+",width="+strWidth; 
 if (strType=="fixedscroll") 
   strOptions="status,scrollbars,height="+ 
     strHeight+",width="+strWidth; 
 if (strType=="elastic") 
   strOptions="toolbar,menubar,scrollbars,"+ 
     "resizable,location,height="+ 
     strHeight+",width="+strWidth; 
 newWin = window.open(strURL, 'newWin', strOptions); 
 newWin.focus(); 
}

// bookmark function
function AddBookmarkLink (title, url)
{
	if (window.sidebar) 
	{
		// Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url, '');
	}
	else
		if (window.external)
		{
			// IE Favourite
			window.external.AddFavorite (url, title);
		}
		else 
			if (window.opera && window.print)
			{
				// Opera hotlist
				return true;
			}	
}
 
 // add the rounded graphic to the table with a "financial class"
	if( ! Array.push ){
		Array.prototype.push = function(){
			for( var i = 0 ; i < arguments.length ; i++ ){
				this[this.length] = arguments[i];
			}
			return this.length;
		};
	}
	
	function addEvent(obj,type,fn){
		if(obj.addEventListener){
			obj.addEventListener(type,fn,false);
		}else if(obj.attachEvent){
			obj["e"+type+fn] = fn;
			obj[type+fn] = function(){
				obj["e"+type+fn](window.event);
			}
			obj.attachEvent("on"+type,obj[type+fn]);
		}
	}
	
	function insertAfter(parent,node,referenceNode) {
		parent.insertBefore(node,referenceNode.nextSibling);
	}
	
	function prependChild(parent,node){
		parent.insertBefore(node,parent.firstChild);
	}
	
	function getElementsByClassName(el,tag,c){
		var elements = el.getElementsByTagName(tag);
		var ret = [];
		for( var i = 0 ; i < elements.length ; i++ ){
			if( elements[i].className && elements[i].className.toString().indexOf(c) >= 0 ){
				ret.push( elements[i] );
			}
		}
		return ret;
	}	

	function shadeTableHeaders(){
		var tables = getElementsByClassName(document,"table","financial");
		for( var i = 0 ; i < tables.length ; i++ ){
			var tmp_table = tables[i];
			var tmp_header = tmp_table.getElementsByTagName("thead");
			if( tmp_header.length ){
				tmp_header = tmp_header[0];
				tmp_row = tmp_header.getElementsByTagName("tr");
				if( tmp_row.length ){
					tmp_row = tmp_row[0];
					var tmp_th = tmp_row.getElementsByTagName("th");
					var tmp_td = tmp_row.getElementsByTagName("td");
					var shade_mastiek_count = 0;
					for( var x = 0 ; x < tmp_th.length ; x++ ){
						if( tmp_th[x].getAttribute("colspan") ){
							shade_mastiek_count += parseInt( tmp_th[x].getAttribute("colspan") );
						}else{
							shade_mastiek_count++;
						}
					}
					for( var y = 0 ; y < tmp_td.length ; y++ ){
						if( tmp_td[y].getAttribute("colspan") ){
							shade_mastiek_count += parseInt( tmp_td[y].getAttribute("colspan") );
						}else{
							shade_mastiek_count++;
						}
					}
					var shade_row = document.createElement("tr");
					shade_row.className = "r_img_row";
					var shade_cell = document.createElement("th"); 
					shade_cell.className = "r_img";
					shade_cell.nodeValue = "&nbsp;";
					shade_row.appendChild( shade_cell );
					shade_cell = document.createElement("th");
					shade_cell.nodeValue = "&nbsp;";
					shade_cell.setAttribute("colspan", ( shade_mastiek_count - 1 ));
					shade_row.appendChild( shade_cell );
					prependChild( tmp_header,shade_row);
				}
			}
		}
	}

	addEvent(window,"load",shadeTableHeaders);

// window popups
var w;
function getWindowCenter(_iX,_iY){
	var iWinX=(screen.width - _iX)/2;
	var iWinY=(screen.height - _iY)/2;
	return('top='+iWinY+',left='+iWinX);
}

function createWindowName(_sUrl){
	var _iLastSlash=_sUrl.lastIndexOf('/');
	var _iLastSlashMin=_sUrl.substring(0,(_iLastSlash-1)).lastIndexOf('/');
	return(_sUrl.substr(_iLastSlash,_sUrl.length).indexOf('.')>0)?('file_'+escape(_sUrl.substring(_iLastSlash+1,_sUrl.lastIndexOf('.')))):('file_'+ escape(_sUrl.substring((_iLastSlashMin+1),_iLastSlash)));
}

function createWindow(_sUrl,_sName,_sParams){
	w=window.open(_sUrl,_sName,_sParams);
	w.focus();
}

function popUp(_sUrl,_sType){
	var _sParams,_sName,_sWinPos,_iX,_iY;
	switch(_sType){
                case'swfvideo':
                        _iX=324;
                        _iY=264;
			_sParams='height='+_iY+',width='+_iX+',scrollbars=0,location=0;toolbars=0,resizable=0,status=1';
			_sName='swfvideo';
                        break;
		case'print':
			_iX=645;
			_iY=440;
			_sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=1;toolbars=1,menubar=1,resizable=0,status=1';
			_sName='print';
			break;
		case'note':
			_iX=745;
			_iY=500;
			_sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0;toolbars=0,resizable=1,status=1';
			_sName=createWindowName(_sUrl);
			break;
                case'html':
                        _iX=800;
                        _iY=600;
_sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0;toolbars=0,resizable=1,status=1';
			_sName=createWindowName(_sUrl);
			break;
		case'img':
			_iX=400;
			_iY=300;
			_sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0;toolbars=0,resizable=1,status=1';
			_sName=createWindowName(_sUrl);
			break;
		case'xls':
		case'pdf':
			_iX=600;
			_iY=500;
			_sParams='height='+_iY+',width='+_iX+',scrollbars=1,location=0,toolbars=1,resizable=1,status=1';
			_sName='file';
			break;
	};
	_sWinPos=getWindowCenter(_iX,_iY);
	_sParams+=','+_sWinPos;
 	createWindow(_sUrl,_sName,_sParams);
}

function parentNav(_url){
 if(window.opener != null){
  window.opener.location=_url;
  window.opener.focus();
 }
 else{
  window.location=_url
 }
}

function cboNav(o){
 var _o=document.getElementById(o);
 if(_o.selectedIndex!=0){
 var _oWin=window.open(_o.options[_o.selectedIndex].value,'_blank');
 }
}

// toggle
var oStoredToggle='dOverview';

function getObjByRef(_id){return document.getElementById(_id);}

function toggleDiv(_id){
 var _oDivStyle=getObjByRef(_id).style;
 if(oStoredToggle!=_id){
  getObjByRef(oStoredToggle).style.display='none';
  _oDivStyle.display='block';
 oStoredToggle=_id;
 }
}

function getTargetToggle(){
 var _sDocLoc=document.location.toString();
 var _rv='';
 if(_sDocLoc.indexOf('target=')>0){
  _rv=_sDocLoc.split('target=')[1];
 }
 return(_rv);
}

function spawnFullScreen(u,n) {
			if (screen.width) {
				if ((screen.width/screen.height) > 1.5) {
					// two monitors
					w = screen.width/2;
				} else {
					w = screen.width;
				}
				
				if (navigator.appName.indexOf('etscape')>0) {
					w=w-5;
				} else {
					w=w-8;
				}
				
				h = screen.height-50;
		
				if (w>800) {
					pagesize='lrg';
				} else {
					pagesize='sml';
				}
			} else {
				pagesize='sml';
			}
			
			if (navigator.appName.indexOf('etscape')>0) {
				wh = 300 - 18;
				ww = 770 - 5;
			} else {
				wh = 300 - 20;
				ww = 770 - 10;
			}
			
			wleft=0
			wtop=0
			if (screen.width) {
				if (screen.width > 800) {
				
					if (screen.width/screen.height>1.5) {
						sw = screen.width/4;
					} else {
						sw = screen.width/2;
					}
				
					wleft=(sw) - (ww/2) - 5;
					wtop=(screen.height/2) - (wh/2) - 18
					if (navigator.userAgent.indexOf('acintosh')>0) {
						wleft=wleft+4
						ww=ww-9
					}
				}
			}
			
			if (pagesize=='lrg') {
				w=w;
				h=h;
			} else {
				w=770;
				h=440;
			}
		
			window.open(u,n, 'width=' + w + ',height=' + h + ',left=0,top=250,scrollbars=1,status=1,location=0,resizable=1,toolbar=0')
		
			
		}