/**
 * JS for broadbandpage.
 */
 
 
 function broadBand() {
	
	this.active = null;
	this.activeReadMore = null;
	
	this.activeModemPageID = null;
	this.activeModem = null;
	this.activeReadMoreModem = null;
	
	
	
	
	this.modemHeight = null;
	
	this.init = function() {
		
		
	}
	
	
	this.Open = function(pageid, obj) {
	
		if(obj.src.indexOf('/images/shop/bredband/read_more_button_new_size.gif') > 0)
		{		
			obj.src = '/images/shop/bredband/back_button_new_size.gif';
			
			if(this.active != null)
			{
				this.active.style.display = 'none';						
				this.activeReadMore.src = '/images/shop/bredband/read_more_button_new_size.gif';									
			}			
			
			this.active = $('moreInfo' + pageid);	
			this.activeReadMore = $('readMoreBtn' + pageid);
			this.activeReadMore.src = '/images/shop/bredband/back_button_new_size.gif';
			
			this.active.style.display = 'block';					
		}
		
		else
		{
			obj.src = '/images/shop/bredband/read_more_button_new_size.gif';	
			
			if(this.active != null)
			{
				this.active.style.display = 'block';			
			}					
			
			$('moreInfo' + pageid).style.display = 'none';			
		}			
	}
	
	
	
	
	
	this.OpenModem = function(pageid, obj){		
		
		
		
		if(obj.src.indexOf('/images/shop/bredband/read_more_button_new_size.gif') > 0)
		{
		
			obj.src = '/images/shop/bredband/back_button_new_size.gif';
			
			if(this.activeModem != null)
			{
				this.activeModem.style.display = 'none';						
				this.activeReadMoreModem.src = '/images/shop/bredband/read_more_button_new_size.gif';
				
				$('modembodytd' + this.activeModemPageID).style.height = this.modemHeight;
		
				$('modembottom' + this.activeModemPageID).className = "modembottom";	
											
			}			
			
			this.activeModemPageID = pageid;
			
			this.activeModem = $('moreInfo' + pageid);				
			this.activeReadMoreModem = $('openImg' + pageid);
			this.activeReadMoreModem.src = '/images/shop/bredband/back_button_new_size.gif';
			
			this.activeModem.style.display = 'block';					
			
			
			
			modemHeight = $('modembodytd' + pageid).offsetHeight;		
		
			$('modembottom' + pageid).className = "modembottomexpanded";
		
		
		
			$('modembodytd' + pageid).style.height = ($('body' + pageid).offsetHeight + 1) + 'px';
			
		}		
		else
		{
			obj.src = '/images/shop/bredband/read_more_button_new_size.gif';	
			$('modembodytd' + pageid).style.height = this.modemHeight;
		
			$('modembottom' + pageid).className = "modembottom";	
		
			$('moreInfo' + pageid).style.display = 'none';			
		}		
		
	}	
}


function customForm() {

	this.chosenModem = null;
	
	

	this.activeList = null;
	this.allowBodyClick = true;
	this.openSelect = function(obj) {
		this.allowBodyClick = false;
		this.list = obj.parentNode.getElementsByTagName('div')[1];
		
		if(this.activeList != this.list && this.activeList != null)
			this.closeSelect(this.activeList);	
		
		var IsEqual = true;
		if(this.activeList == this.list)
			IsEqual = true;
		
		if(IsEqual && this.list.style.display == 'block')
			this.closeSelect(this.list);
		else
			this.list.style.display = 'block';
			
		this.activeList = this.list;
		setTimeout("CustomForm.freeBodyClick()",5);
	}

	this.closeSelect = function(obj) {
		obj.style.display = 'none';
	}
	
	this.freeBodyClick = function() {
		this.allowBodyClick = true;
	}
	
	this.setBoundValue = 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) {
			$('priceNo' + hardWareId).innerHTML = priceMonthly;
			$('priceText' + hardWareId).innerHTML = "kr per m&aring;nad";
		}
		else {
			$('priceNo' + hardWareId).innerHTML = priceUpfront;
			$('priceText' + hardWareId).innerHTML = "kr vid leverans";		
		}
		
		this.bound_time = obj.parentNode.parentNode.parentNode.getElementsByTagName('span')[0];
		
		/*
		this.price_per_month = obj.parentNode.parentNode.parentNode.getElementsByTagName('div')[0];
		this.start_fee = obj.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('b')[0];
		*/
		
		
		this.bound_time.innerHTML = bound_time_pres;	
		
		
		
		/*
		if(this.chosenModem == modem)		
		{			
			this.hiddenBound.value = bound_time;		
			document.forms[0].submit();				
		}
		*/
			
			
		
		
		
		
		/*this.price_per_month.innerHTML = price_per_month;*/
		
		/*
		if(this.start_fee != null)
		{
		if(start_fee != 0) {
			this.start_fee.innerHTML = start_fee;
			this.start_fee.parentNode.style.display = 'block';
		} else {
			this.start_fee.parentNode.style.display = 'none';	
		}
		}
		*/
		
	}
	
	this.bodyClick = function() {
		var body = document.getElementsByTagName('body')[0];
		
		
		body.onclick = function() {
			if(CustomForm.activeList != null && CustomForm.allowBodyClick)
				 CustomForm.activeList.style.display = 'none';
		}
	}	
}


var BroadBand =  new broadBand();
addEvent(window, "load", function(){BroadBand.init();})



var CustomForm =  new customForm();
addEvent(window, "load", function(){CustomForm.bodyClick();})

