

function showTab(obj, id, src, srcoff)
{		

	
	$(activeTab).src = currentTabOffSrc;
	
	
	
		
	activeTab = "tabImg" + id.substring(3);
	currentTabOffSrc = srcoff;
	
	
	
	$(id).style.display = "block";
	
	if(currentTab != null)
		$(currentTab).style.display = "none";	
	
	obj.getElementsByTagName('img')[0].src = src;	
	
	currentTab = id;
	
	chosentab = id;
}

function mouseTab(obj, id, mode, srcout, srcon)
{	
	if(id != chosentab)
	{		
		if(mode == "over")
			obj.src = srcon;
		else
			obj.src = srcout;			
	}	
}

function selectModem(modem)
{
	$('chosenmodem').value = modem;
}

var currentmodem = 0;
function nextModem()
{
	nextmodem = currentmodem + 1;
	
	if($('modem' + nextmodem))
	{
		$('modem' + currentmodem).style.display = "none";		
		$('SelectBT' + currentmodem).style.display = "none";
		
		currentmodem++;
		$('modem' + currentmodem).style.display = "block";
		$('SelectBT' + currentmodem).style.display = "block";
		
		price = $('modemPrice' + currentmodem).innerHTML;		
		$('chosenModemPrice').innerHTML = price;
		
		priceText = $('priceText' + currentmodem).innerHTML;
		$('chosenModemPriceUnit').innerHTML = priceText;
		
		modemName = $('modemName' + currentmodem).innerHTML;
		$('chosenModemName').innerHTML = modemName;
		
		
//		alert(currentBTSelect);
		
		
		
	}
	
	
	
	//vi förutsätter att det finns mer än en färg, annars döljs pilknapparna/länkarna gissningsvis
	$('pmod').style.color = "black";
		
	//kollar om det finns ett nästa modem, om inte gråar vi ut knappen/länken
	nextmodem = currentmodem + 1;
	
	if(!$('modem' + nextmodem))
		$('nmod').style.color = "grey";
	
	
}


function previousModem()
{
	prevmodem = currentmodem - 1;
	
	
	
	if(prevmodem >= 0)		
	{
		$('modem' + currentmodem).style.display = "none";
		$('SelectBT' + currentmodem).style.display = "none";
		currentmodem--;
		$('modem' + currentmodem).style.display = "block";
		$('SelectBT' + currentmodem).style.display = "block";
		
		price = $('modemPrice' + currentmodem).innerHTML;		
		$('chosenModemPrice').innerHTML = price;
		
		priceText = $('priceText' + currentmodem).innerHTML;
		$('chosenModemPriceUnit').innerHTML = priceText;
		
		priceText = $('priceText' + currentmodem).innerHTML;
		$('chosenModemPriceUnit').innerHTML = priceText;
		
		modemName = $('modemName' + currentmodem).innerHTML;
		$('chosenModemName').innerHTML = modemName;
		
	}
	
	//vi förutsätter att det finns mer än en färg, annars döljs pilknapparna/länkarna gissningsvis	
	$('nmod').style.color = "black";
	
	//om vi tittar på det första modemet gråar vi ut knappen/länken
	if(currentmodem == 0)
		$('pmod').style.color = "grey";		
	
	
	
	
}

function readMoreModem()
{
	
	$('readMoreModem' + currentmodem).style.display = "block";
	$('readMoreModem' + currentmodem).parentNode.style.display = "block";
}

function closeReadMoreModem()
{
	$('readMoreModem' + currentmodem).style.display = "none";
	$('readMoreModem' + currentmodem).parentNode.style.display = "none";

}


function checkOut()
{	
	
	ShopFlow.Classes.BasketProxy.CheckOut($('chosenmodem').value, $('chosensub').value, currentbt, CheckOutCallback);
}

function CheckOutCallback(res)
{	
	
	if(res.value != "error")
		location.href = res.value;
	else	
		alert(res.value);
}


var currentbt;
function customForm2() {

	this.closeSelect = function(obj) {
		obj.style.display = 'none';
	}
	
	this.setBoundValueNewBBShop = function(modem, obj,bound_time,bound_time_pres, priceMonthly, priceUpfront, hardWareId) {
	
		this.hiddenBound = $('DefaultFramework_Content2_hiddenBound');	
	
		
		this.closeSelect(obj.parentNode);
		
		this.contract = obj.parentNode.getElementsByTagName('input')[0];
		this.contract.value = bound_time;
		
		if(priceUpfront == 0)
		{
			$('priceText' + currentmodem).innerHTML = "kr per m&aring;nad";
			$('modemPrice' + currentmodem).innerHTML = priceMonthly;
			
			
			$('chosenModemPrice').innerHTML = priceMonthly;
			$('chosenModemPriceUnit').innerHTML = "kr per m&aring;nad";
		}
		else
		{
			$('priceText' + currentmodem).innerHTML = "kr vid leverans";
			$('modemPrice' + currentmodem).innerHTML = priceUpfront;
			
			$('chosenModemPrice').innerHTML = priceUpfront;
			$('chosenModemPriceUnit').innerHTML = "kr vid leverans";
		}
		
		

		
		this.bound_time = obj.parentNode.parentNode.parentNode.getElementsByTagName('span')[0];	
		
		currentbt = bound_time;
		
		
		this.bound_time.innerHTML = bound_time_pres;	

		
	}
	
	this.bodyClick = function() {
		var body = document.getElementsByTagName('body')[0];
		
		
		body.onclick = function() {
			if(CustomForm.activeList != null && CustomForm.allowBodyClick)
				 CustomForm.activeList.style.display = 'none';
		}
	}	
}

var CustomForm2 =  new customForm2();
addEvent(window, "load", function(){CustomForm.bodyClick();})