/********************** Initial page load methods ********************/

	window.onload = function() { 
		 Common.onPageLoad();
	};
	
	Common = {}
	
	Common.onPageLoad = function() {
		Common.setTabs();
	}
	
	//find set selected tab
	Common.setTabs = function() {
		
		var tabValue = Common.getTabParam();
		
		if(document.tab_form != null){ //only run on navigation page
			if(tabValue){ 
				var selectedTab = document.getElementById(tabValue);
				selectedTab.className = "down";
			} else {                    
				var defaultTab = document.tab_form.getElementsByTagName("div");
				defaultTab[0].className = "down";
			}
		}
	}
		
	//find value of tab parameter in url string
	Common.getTabParam = function(){
		var url = location.href;
		var hasTab = 0;
		var tabValue;
		split = url.split("/_/");
		
		if(split[1] != null){
			
			params = (split[1].split("/"));
			
			for (var i = 0; i < params.length; i++){
				keyValues = params[i].split("-");
				
				if (keyValues[0] == "Tab"){
					hasTab = 1;
					tabValue = keyValues[1];
					
					if(tabValue.indexOf("?") != -1){
						tabValueTemp=tabValue.split("?");
						tabValue = tabValueTemp[0];
					}
				}
			}
		}
		return tabValue;
	}
	
	Common.removeColumn = function(columnNumber)
	{
		// pick a row, and count the visible cells
		// apart from the features column; this is
		// the number of visible columns (items)
		//
		var visibleItems = 0;
		var t = document.getElementById ( "mainTable" );
	    for ( var i = 1 ; i < t.rows[0].cells.length ; i++ )
	    	if ((t.rows[0].cells[i]) && t.rows[0].cells[i] .style .display != "none" )
	    		visibleItems++;
	    		
		// "compare" doesn't really make sense
		// unless there are at least two items...
		//
		if ( visibleItems > 2 )
		{
			t = document.getElementById ( "mainTable" );
			
			// turn off the corresponding cell in each row
		    for ( var i = 0 ; i < t.rows.length ; i++ )
		    {
		    	// columnNumber+1 because column 1
		    	// is the features list, not a product
		    	//
		    	if (t.rows[i].cells[columnNumber+1])
		    		t.rows[i].cells[columnNumber+1] .style .display = "none";
				
		        // and check if the rest of the row is empty;
		        // if it is we will hide it
		        //
		        var rowEmpty = false;
				checkRowEmpty:
				{
					// for all the cells in the row but the 0-th (the feature description)
					//
		        	for ( var h = 1 ; h < t.rows[i].cells.length ; h++)
						with ( t.rows[i].cells[h] ) if ( style.display != "none" && innerHTML != "&nbsp;" )
							break checkRowEmpty;

					rowEmpty = true;
				} //checkRowEmpty:
		        
		        if ( rowEmpty )
		        	t.rows[i] .style .display = "none";
		        
		    } //for ( i = 0 ; i < t.rows.length ; i++ )
		    
			// and if there are now no more than two items,
		    // turn off remove on them
			//
			if ( --visibleItems <= 2 )
			{
				for ( var i = 0 ; i < 5 ; i++ )
				{
					var removeLink = document.getElementById ( "removeLink" + i );
					if ( removeLink != null )
						removeLink.style.display = "none";
				}	
			}
		} //if ( visibleItems > 2 )
	}//Common.removeColumn = function(columnNumber)
	
	//Hide Column on compare page
/*  Common.removeColumn = function(columnNumber){
		
		var column = document.getElementsByTagName("col");
		var visibleNum = 0;
		
		for(var i = 0; i < column.length; i++){
			if(column[i].id == ("column" + columnNumber))
				column[i].style.display = "none";
			if(column[i].id.substr(0,6) == "column")
				if(column[i].style.display != "none") 
					visibleNum=visibleNum+1;
		}
		if (visibleNum<3) {
			for(i = 0; i < 5; i++){
				var removeLink = document.getElementById("removeLink"+i);
				if (removeLink!=null)
					removeLink.style.display = "none";
			}	
		}
	}*/
