var startColumn=1;
var curColumn=1;
var lightColor='#feefcb';
var flagFirstLoad=true;

var teil=location.search.replace(/^\?/,'');
teil=teil.replace(/&$/,'');




var singUp = new Array();

/*
Gold:
Gold Plus:
Platinum:
*/
singUp[0]='http://www.lookatmypc.com/members/signup.php';
singUp[1]='http://www.lookatmypc.com/members/signup.php';
singUp[2]='http://www.lookatmypc.com/members/signup.php';

var buy = new Array();
buy[0]='http://www.lookatmypc.com/members/signup.php?price_group=-31&product_id=24&hide_paysys=paypal_r';
buy[1]='http://www.lookatmypc.com/members/signup.php?price_group=-32&product_id=28&hide_paysys=paypal_r';
buy[2]='http://www.lookatmypc.com/members/signup.php?price_group=-33&product_id=26&hide_paysys=paypal_r';

var arrLinkPlans= new Array();
arrLinkPlans[0]='http://www.lookatmypc.com/family-plans/';
arrLinkPlans[1]='http://www.lookatmypc.com/family-plans/';
arrLinkPlans[2]='http://www.lookatmypc.com/family-plans/';

var paramCell= new Array();
paramCell[0]= new Array(1,3,5);

paramCell[1]= new Array(1,3,5);

paramCell[2]= new Array(1,3,5);

paramCell[3]= new Array(1,3,5);

paramCell[4]= new Array(1,3,5);

paramCell[5]= new Array(1,3,5);
paramCell[6]= new Array(1,3,5);
paramCell[7]= new Array(1,3,5);

paramCell[8]= new Array(1,3,5);


var autoEvents={
	setImgPlan:function(obj){
		obj.style.color='black';
		if(obj.getAttribute('row')==null)
			return;
		if(obj.getAttribute('column')==null)
			return;
		switch(parseInt(obj.getAttribute('row'))){
			case 0:
				oImg=getFirstChild(obj);
				if(!oImg.src.match(/_a\.gif$/))
					oImg.src=oImg.src.replace(/\.gif$/,'_a.gif');;
				oImg.style.height='44px';
				oImg.onclick=
					function(){
						window.location=arrLinkPlans[obj.getAttribute('column')];
					}
			break;
			case 1:
				obj.style.color='red';
			break;
			case 2:case 3:case 4:case 5:
				obj.style.color='#0b4c7b';
			break;
			case 8:
				if(!flagFirstLoad)
				obj.innerHTML='<table border="0" cellpadding="0" cellspacing="0" width="100%">\
									<tbody>\
										<tr>\
											<td colspan="2"><img height="22" src="http://www.lookatmypc.com/comparepics/images/free_buy_top.gif" width="127" /></td>\
										</tr>\
										<tr>\
											<td colspan="2"><img  id="buy" src="http://www.lookatmypc.com/comparepics/images/buy.gif"  /></td>\
										</tr>\
										<!--<tr>\
											<td colspan="2"><img height="14" id="learn" src="http://www.lookatmypc.com/comparepics/images/learn.gif" width="127" /></td>\
										</tr>-->\
									</tbody>\
								</table>';
				
			break;
		}
		highLight.initFreeBuy();
	}
}

var paramEvents=new Array();
for(var i=0; i<paramCell.length; i++){
	paramEvents[i]={
		'onclick':function(){
			if(this.getAttribute('column')==null)
				this.setAttribute('column',startColumn);
			highLight.setCurColumn(this.getAttribute('column'));
		}
	}
}	
	
highLight={
	init:function(){
		var objTable=document.getElementById('plan_features');
		objTable.style.cursor='pointer';
		var objTableDefColumn_1=document.getElementById('col_1');
		for(var row=0;row<objTable.rows.length;row++){
			objRow=objTable.rows[row];
			objRowTemp=objRow;
			if(paramCell[row]!=undefined){
				for(key in paramCell[row]){
					if(highLight.columns[key]==undefined)
						highLight.columns[key]=new Array();
					if(highLight.defaultAttribute[key]==undefined)
						highLight.defaultAttribute[key]=new Array();
					if(objRow.cells[paramCell[row][key]]!=undefined){
						old=paramCell[row][key];
						if(key==1){
							objRow=objTableDefColumn_1.rows[row];
							oldColumn=paramCell[row][key];
							paramCell[row][key]=0;
						}
						objCell=objRow.cells[paramCell[row][key]];
						objCell.setAttribute('column',key);
						objCell.setAttribute('row',highLight.columns[key].length);
						if(key==1){
							objTable.rows[row].cells[oldColumn].setAttribute('column',key);
							objTable.rows[row].cells[oldColumn].setAttribute('row',highLight.columns[key].length);
						}
						highLight.defaultAttribute[key].push(objCell.cloneNode(true));
						if(key==1)
							objCell=objTable.rows[row].cells[old];
						highLight.columns[key].push(objCell);
						highLight.setEvents(row,key,highLight.columns[key].length-1);
						if(key==1)
							objRow=objRowTemp;
					}
				}						
			}else{
				if(row<paramCell.length){
					paramCell[row] = new Array();
					for(key in paramCell[row-1]){
						if(highLight.columns[key]=='undefined')
							highLight.columns[key]=new Array();
						if(highLight.defaultAttribute[key]==undefined)
							highLight.defaultAttribute[key]=new Array();
						if(objRow.cells[paramCell[row-1][key]]!=undefined){
							if(key==1){
								objRow=objTableDefColumn_1.rows[row];
								paramCell[row-1][key]=0;
							}
							objCell=objRow.cells[paramCell[row-1][key]];
							objCell.setAttribute('column',key);
							objCell.setAttribute('row',highLight.columns[key].length);
							
							highLight.defaultAttribute[key].push(objCell.cloneNode(true));	
							paramCell[row].push(paramCell[row-1][key]);
							if(key==1)
								objCell=objTable.rows[row].cells[3];
							highLight.columns[key].push(objCell);
							highLight.setEvents(row,key,highLight.columns[key].length-1);
							if(key==1)
								objRow=objRowTemp;
						}
					}
				}
			}
		}
		//highLight.alert();
		paramEvents=undefined;		
		if(!flagFirstLoad){
			highLight.setCurColumn(startColumn);
		}
		highLight.setAutoEvents(curColumn);
		//highLight.initFreeBuy();
		if(is_set('loader'))
			loader();
		flagFirstLoad=false;
	},
	setEvents:function(row,column,index){		
		if(paramEvents!=undefined){
			if(paramEvents[row]!=undefined){
				for(event_ in paramEvents[row]){
					if(highLight.columns[column][index]!=undefined)
						eval('highLight.columns[column][index].'+event_+'='+paramEvents[row][event_]);
				}
			}
			highLight.insetEvents[index]=paramEvents[row];
		}else{
			if(highLight.insetEvents[row]!=undefined){
			for(event_ in highLight.insetEvents[row]){
				if(highLight.columns[column][index]!=undefined)
					eval('highLight.columns[column][index].'+event_+'='+highLight.insetEvents[row][event_]);
			}
		}			
		}
	},
	insetEvents:Array(),
	columns: new Array(),
	defaultAttribute: new Array(),
	alert:function(){
		for(column in highLight.columns)
			for(index in highLight.columns[column])
				highLight.columns[column][index].style.border='solid 1px red';	
	},
	setCurColumn:function(nmbColumn){
		if(curColumn==nmbColumn) return;
		highLight.setDefaultColumn();
		curColumn=nmbColumn;
		highLight.setAutoEvents(nmbColumn);		
	},
	setAutoEvents:function(nmbColumn){
		for(index in highLight.columns[nmbColumn]){
			highLight.columns[nmbColumn][index].style.backgroundColor=lightColor;
			for(event_ in autoEvents)
				eval('autoEvents.'+event_+'(highLight.columns[nmbColumn][index])');			
		}
	},
	setDefaultColumn:function(){
		for(index in highLight.columns[curColumn]){
			var objCell=highLight.columns[curColumn][index];
			objClon=highLight.defaultAttribute[curColumn][index].cloneNode(true);
			highLight.columns[curColumn][index]=objClon;
			objCell.parentNode.insertBefore(objClon,objCell);
			objCell.parentNode.removeChild(objCell);
			highLight.setEvents(index,curColumn,index);
			
		}
	},
	initFreeBuy:function(){
		if($_('free')){
			$_('free').onclick=
				function (){
					window.location=singUp[curColumn]+'&'+teil;
				}
			$_('free').onmouseover=
				function(){
					this.src=this.src.replace(/\.gif$/,'_a.gif');
				}
			$_('free').onmouseout=
				function(){
					this.src=this.src.replace(/_a\.gif$/,'.gif');
				}
		}
		if($_('buy')){
			$_('buy').onclick=
				function (){
					window.location=buy[curColumn]+'&'+teil;;
				}
			$_('buy').onmouseover=
				function(){
					this.src=this.src.replace(/\.gif$/,'_a.gif');
				}
			$_('buy').onmouseout=
				function(){
					this.src=this.src.replace(/_a\.gif$/,'.gif');
				}
		}
		if($_('learn'))
			$_('learn').onclick=
				function (event){
					window.location=arrLinkPlans[curColumn];
				}
	}
}



















if (window.addEventListener)
	window.addEventListener("load", highLight.init, false);
if (window.attachEvent)
	window.attachEvent("onload",highLight.init);
	
function getFirstChild(obj){
	obj=obj.firstChild;
	if(obj.nodeName=='#text')
		obj=obj.nextSibling;
	return obj;
}

function $_(id){
	return document.getElementById(id);
}

function is_set(variable){
		try{
		eval(variable);
		return true
		}
		catch(e){return false}
		
}

function loader(){
	if($_('additionalBottom')&&$_('additionalArrow')){
		$_('additionalArrow').onclick=
			function(){
				if($_('additionalBottom').style.visibility=='hidden'){
					$_('additionalBottom').style.visibility='visible';
					$_('additionalArrow').src=$_('additionalArrow').src.replace(/\.gif/,'_up.gif');
				}else{
					$_('additionalBottom').style.visibility='hidden';
					$_('additionalArrow').src=$_('additionalArrow').src.replace(/_up\.gif/,'.gif');
				}
			}
	}
}