
prodconf_layer = new productConfiguratorLight();

function productConfiguratorLight() {
	this.submitLink = 1;
	this.productOptions = new Array();
	this.productOptions['fun'] = 2;
	this.productOptions['light'] = 4;
	this.productOptions['complete'] = 2;
	this.productOptions['lighttime'] = 2;
	this.productOptions['lightflat'] = 2;

	this.currentNo = 1;
	this.lightclicked = false;
	this.lighttimeclicked = false;
	this.lightflatclicked = false;
	this.productlightNo = new Array();
	this.productlightNo[1] = 1;
	this.productlightNo[2] = 4;
	this.productlight = new Array();
	this.productlight[1] = new Array();
	this.productlight[2] = new Array();
	this.productlight[3] = new Array();
	this.productlight[4] = new Array();
	this.productlight[4][1] = 4;
	this.productlight[3][1] = 3;
	this.productlight[1][3] = 3;
	this.productlight[1][4] = 4;
	this.productlight[2][3] = 2;
	this.productlight[2][4] = 1;
	this.productlight[4][2] = 1;
	this.productlight[3][2] = 2;
	this.productLinks = new Array();
	this.productLinks['fun'] = new Array();
	this.productLinks['light'] = new Array();
	this.productLinks['complete'] = new Array();
	this.productLinks['lighttime'] = new Array();	
	this.productLinks['lightflat'] = new Array();
	
	this.productLinks['fun'][1] = "/tavp/ooPreAction1.do?ka=pk&prod=fun&dsl_tariff=flat&phone=&dsl_speed=&iptv=no";
	this.productLinks['fun'][2] = "/tavp/ooPreAction1.do?ka=pk&prod=fun&dsl_tariff=time&phone=&dsl_speed=&iptv=no";
	
	this.productLinks['complete'][1] = "/tavp/ooPreAction1.do?ka=pk&prod=complete&dsl_tariff=&phone=&dsl_speed=4000&iptv=no";
	this.productLinks['complete'][2] = "/tavp/ooPreAction1.do?ka=pk&prod=complete&dsl_tariff=&phone=&dsl_speed=16000&iptv=no";
	
	this.productLinks['light'][1] = "/tavp/ooPreAction1.do?ka=pk&prod=light&dsl_tariff=time&phone=no&dsl_speed=&iptv=no";
	this.productLinks['light'][2] = "/tavp/ooPreAction1.do?ka=pk&prod=light&dsl_tariff=time&phone=yes&dsl_speed=&iptv=no";
	this.productLinks['light'][3] = "/tavp/ooPreAction1.do?ka=pk&prod=light&dsl_tariff=flat&phone=yes&dsl_speed=&iptv=no";
	this.productLinks['light'][4] = "/tavp/ooPreAction1.do?ka=pk&prod=light&dsl_tariff=flat&phone=no&dsl_speed=&iptv=no";


	this.productLinks['lighttime'][1] = "/tavp/ooPreAction1.do?ka=pk&prod=light&dsl_tariff=time&phone=yes&dsl_speed=&iptv=no";
	this.productLinks['lighttime'][2] = "/tavp/ooPreAction1.do?ka=pk&prod=light&dsl_tariff=time&phone=no&dsl_speed=&iptv=no";

	this.productLinks['lightflat'][1] = "/tavp/ooPreAction1.do?ka=pk&prod=light&dsl_tariff=flat&phone=yes&dsl_speed=&iptv=no";
	this.productLinks['lightflat'][2] = "/tavp/ooPreAction1.do?ka=pk&prod=light&dsl_tariff=flat&phone=no&dsl_speed=&iptv=no";




	
}

prodconf_layer.show = function(product) {
	element = document.getElementById("layer_prodkonf_"+product);
	if(element) {
		element.style.display = "block";
		element.style.visibility = "visible";
	}
		
}




prodconf_layer.submit = function(product) {
	if (product=="light" && !this.lightclicked){
		this.submitLink = 4;
	}
		
	if (product=="lighttime" && !this.lighttimeclicked){
		this.submitLink = 2;
	}
	
	if (product=="lightflat" && !this.lightflatclicked){
		this.submitLink = 2;
	}
	//alert(this.submitLink);
	window.location.href = this.productLinks[product][this.submitLink];
}






prodconf_layer.setOption = function(product,buttonNo) {
	// Button Img : 
	prodconf_layer.elementSwitch(product,buttonNo);
	prodconf_layer.frontendSwitch(product,buttonNo);
}

prodconf_layer.elementSwitch = function(product,buttonNo) {
	elementName = product+"_prodConf_";
	elementNameA = elementName+buttonNo;
	elementNameB = (buttonNo%2==0) ? elementName+(buttonNo-1):elementName+(buttonNo+1);
	elementA = document.getElementById(elementNameA);
	elementB = document.getElementById(elementNameB);
	
	if (elementA) 
		elementA.src = elementA.src.replace(/_norm/g,"_act");
	if (elementB) 
		elementB.src = elementB.src.replace(/_act/g,"_norm");
	
	
	if (product=="light") {
			if ((this.currentNo>2 && buttonNo<=2) || (this.currentNo<=2 && buttonNo>2)) {
				element2 = document.getElementById(elementName+this.currentNo);
				if (element2)
					element2.style.display = "block";
			}
		}
}

prodconf_layer.frontendSwitch = function(product,buttonNo) {
	elementName="productInfo_"+product+"_prodConf_";
	tmpButtonLight = 1;
	
	if (product=="lighttime") {
		this.lighttimeclicked = true;
	}
	
	if (product=="lightflat") {
		this.lightflatclicked = true;
	}
	
	if (product=="light") {
		this.lightclicked = true;
		if(buttonNo<=2) 
			this.productlightNo[1] = buttonNo;
		else {
			this.productlightNo[2] = buttonNo;
		}
		
		buttonDisplay = this.productlight[this.productlightNo[1]][this.productlightNo[2]];
		element = document.getElementById(elementName+buttonDisplay);
		this.submitLink = buttonDisplay;
	} else {
		element = document.getElementById(elementName+buttonNo);
		this.submitLink = buttonNo;
	}
	
	if (element) {
		for(i=0;i<this.productOptions[product];i++) {
			tmpElement = document.getElementById(elementName+(i+1));
			if (tmpElement)
				tmpElement.style.display = "none";
		}
		element.style.display = "block";
		
	}
	
	//alert("ButtonNo: "+buttonNo+"  this.xxx= "+this.currentNo+"  display:"+buttonDisplay +"  Clicked: "+this.productlightClicked);
	this.currentNo = buttonNo;
}


