var submitted = false;
var showDialogue = true;


/***********************************************
* Ultimate Fade-In Slideshow (v1.51): © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
 
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=["images/home_picture1.jpg", "", ""] //plain image syntax
fadeimages[1]=["images/home_picture2.jpg", "", ""] //plain image syntax
fadeimages[2]=["images/home_picture3.jpg", "", ""] //plain image syntax
fadeimages[3]=["images/home_picture7.jpg", "", ""] //plain image syntax
fadeimages[4]=["images/home_picture5.jpg", "", ""] //plain image syntax


var fadeimages2=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages2[0]=["images/home_picture6.jpg", "", ""] //plain image syntax
fadeimages2[1]=["images/home_picture7.jpg", "", ""] //plain image syntax
fadeimages2[2]=["images/home_picture8.jpg", "", ""] //plain image syntax
fadeimages2[3]=["images/home_picture9.jpg", "", ""] //plain image syntax


var fadebgcolor="white"

////NO need to edit beyond here/////////////
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
 
var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div></div>')
else
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
else if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
obj.tempobj.style.opacity=obj.degree/101
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(){
if (this.pausecheck==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseovercheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=this.degree/100
else if (crossobj.style.opacity&&!crossobj.filters)
crossobj.style.opacity=this.degree/101
}
 
 
fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
}
this.rotateimage()
}


function setmeasurepicture() {

	if (window.document.getElementById('frmWebShopArea')) {
		
	var webshoparea = window.document.getElementById('frmWebShopArea').value;	
	if (parseInt(webshoparea)>0) {
		window.document.getElementById('measurepicture').src = 'images/ex_bathroom.jpg';
	}
	
	}
	
	
}


//Check fields (from conact-form)
//
function chkfields_contactus() {
	
	var fldName = window.document.frmContact.frmName;
	var fldPhone = window.document.frmContact.frmPhone;
	var fldMail = window.document.frmContact.frmMail;
	
	
	typedin = 1;
	
	if (!fldName.value) {
	
		fldName.focus();
		window.alert('Du måste ange namn!');
		typedin = 0 ;
	
	}
	else if (!fldPhone.value && !fldMail.value) {
		
		//Neither phone or email is typed in
		//
		fldPhone.focus();
		window.alert('Du måste ange telefon eller epost så att vi kan ta kontakt med dig!');
		typedin = 0;
	}
	
	
	//Nothings missing
	//
	if (typedin == 1) {
	
		return true;
	
	}
	else {
		//Something is missing, don't submit form
		//
		return false;
	}
	
}


//Create a link to webshop with parameters when in "webshop-mode"
//else do a "normal link" with filename only
//
function webshoplink(nameoffile) {
	
			window.document.location = nameoffile;
	
	/*
	var roomsrc = 'empty.jpg';
	var roomvalue = '';
	var typeoffloorsrc = 'empty.jpg';
	var typeoffloorvalue = '';
	var floorsrc = 'empty.jpg';
	var floorvalue = '';
	var webshopwidth = 0;
	var webshoplength = 0;
	var webshoparea = 0;
	



	if (window.document.getElementById('frmWebShopArea')) {
	
		webshopwidth = window.document.getElementById('frmWebShopWidth').value;
		webshoplength = window.document.getElementById('frmWebShopLength').value;
		webshoparea = window.document.getElementById('frmWebShopArea').value;	

	} 


	


	
	if (window.document.getElementById('roomchoicepicture')) {
		

		roomsrc = window.document.getElementById('roomchoicepicture').src;
		roomvalue =window.document.getElementById('frmRoomChoice').value;

	}
	

	if (window.document.getElementById('typeoffloorchoicepicture')) {
	

		//typeoffloorsrc = window.document.getElementById('typeoffloorchoicepicture').src;
		//typeoffloorvalue = window.document.getElementById('frmTypeOfFloorChoice').value;

		
	}
	

	if (window.document.getElementById('floorchoicepicture')) {
	
		floorsrc = window.document.getElementById('floorchoicepicture').src;
		floorvalue = window.document.getElementById('frmFloorChoice').value;

	}
	
	

	var linkset = nameoffile + '?roomsrc=' + roomsrc + '&roomvalue=' + roomvalue + '&typeoffloorsrc=' + typeoffloorsrc + '&typeoffloorvalue=' + typeoffloorvalue + '&webshopwidth=' + webshopwidth + '&webshoplength=' + webshoplength + '&webshoparea=' + webshoparea + '&floorsrc=' + floorsrc + '&floorvalue=' + floorvalue;

	
	//If ALL parameters are empty, do a "normal" link
	//
	if (roomsrc == 'empty.jpg' && (roomvalue == '' || roomvalue == '[]') && typeoffloorsrc == 'empty.jpg' && (typeoffloorvalue == '' || typeoffloorvalue == '[]') && webshopwidth == '' && webshoplength == '' && webshoparea == '' && floorsrc == 'empty.jpg' && (floorvalue == '' || floorvalue == '[]')) {
		window.document.location = nameoffile;

		
	}
	else {
		
		//send link with parameters
		//
		window.document.location = linkset;
	
	}
	*/

}


//This function is used for setting value to different images, textfields etc
//based on parameters set in url
//
function setParametersafterlink(imgname, nameofroom, imgname2, typeoffloor, w, l, a, imgname3, nameoffloor) {
	

	changepictureroomchoice(imgname, nameofroom);
	changepicturetypeoffloorchoice(imgname2, typeoffloor);
	changeareasize(w, l, a);
	setmeasurepicture();
	changepicturefloor(imgname3, nameoffloor);


}


function changepicturefloor(imgname, nameoffloor) {
	
	if (document.getElementById('floorchoicepicture') && document.getElementById('frmFloorChoice') && imgname) {
		
		document.getElementById('floorchoicepicture').src = 'images/' + imgname;
		document.getElementById('frmFloorChoice').value = nameoffloor;
	
	}
	

}



function changepictureroomchoice(imgname, nameofroom) {
	
	if (document.getElementById('roomchoicepicture') && document.getElementById('frmRoomChoice')) {
		
		document.getElementById('roomchoicepicture').src = 'images/' + imgname;
		document.getElementById('frmRoomChoice').value = nameofroom;
	
	}
	
}



function changepicturetypeoffloorchoice(imgname, typeoffloor) {

	
	//Show extras (tillbehör) for chosen type of floor
	//
	if (window.document.getElementById('extras')) {
		
	
		
		div = document.getElementById('extras');
		div.innerHTML = '<b>Tillbehör ' + typeoffloor + '</b><br />';
	
		//Show extras content based on chosen type of floor
		//
		var div = document.getElementById('extras_content');
		var div_picture = document.getElementById('extras_picture');
		
		
		var str_content = 'Värmegolv<br />Primer<br />Universalspackel<br />Finspackel<br />Flytspackel';
		var str_picture = '<img border="0" src="images/ex_accessories.jpg">';
		
		
		//Picture
		//
		if (typeoffloor == 'vinyl/plast') {
		
			//str_picture = '<img src="images/vinyl.jpg">';		
			
		}	
		
		
		//Content
		//
		if (typeoffloor == 'vinyl/plast' || typeoffloor == 'våtrumsgolv') {
			
			str_content += '<br />Knivar & knivblad<br />Cascoflex (lim)<br />Limspridare<br />Golvsvets (kemsvets)';
			
		}
		else if (typeoffloor == 'heltäckningsmatta') {
			
			str_content += '<br />Knivar & knivblad<br />Cascoflex (lim)<br />Limspridare<br />Dubbelhäftande tejp';
			
		}
		else if (typeoffloor == 'trägolv/parkett') {
			
			str_content += '<br />Golvlack<br />Underlagspapp<br />Underlagsfoam<br />Läggningssats<br />Läggningsklossar<br />Åldersbeständig plastfolie';
			
		}
		else if (typeoffloor == 'laminatgolv') {
	
			str_content += '<br />Underlagspapp<br />Underlagsfoam<br />Läggningssats<br />Läggnihngsklossar<br />Åldersbeständig plastfolie';
			
		}
		
		
		if (typeoffloor == 'våtrumsgolv') {
			
			str_content += '<br />Våtspackel (vägg)<br />Vägglim';
			
		}
		
		
		div.innerHTML = str_content;
		div_picture.innerHTML = str_picture;

	}
	

}

function changeareasize(w, l, a) {


		if (window.document.getElementById('frmWebShopArea')) {
		
			window.document.getElementById('frmWebShopWidth').value = w;
			window.document.getElementById('frmWebShopLength').value = l;
			window.document.getElementById('frmWebShopArea').value = a;	
			
		}

}


function togglePictureZoom() {

	
	window.document.getElementById("largePicture1").style.visibility = 'hidden';
	window.document.getElementById("largePicture1").style.width = '0px';
	window.document.getElementById("largePicture1").style.height = '0px';

	
	
	window.document.getElementById("largePicture2").style.visibility = 'hidden';
	window.document.getElementById("largePicture2").style.width = '0px';
	window.document.getElementById("largePicture2").style.height = '0px';
	
}



//Used together so "a real button-effect" appears
//
function setBorderButton(buttonLayer) {
	
	//window.alert(buttonLayer);
	
	//No layer is set, button is default layer
	//
	if (!buttonLayer) {
	
		buttonLayer = 'button';
	
	}
		
	window.document.getElementById(buttonLayer).style.borderRight = '1px solid #FFFFFF';
	window.document.getElementById(buttonLayer).style.borderBottom = '1px solid #FFFFFF';
	window.document.getElementById(buttonLayer).style.borderLeft = '1px solid #716f64';
	window.document.getElementById(buttonLayer).style.borderTop = '1px solid #716f64';
	window.document.getElementById(buttonLayer).style.height = '16px';
	
		
	window.document.getElementById(buttonLayer + "_inner").style.borderRight = '1px solid #ece9d8';
	window.document.getElementById(buttonLayer + "_inner").style.borderBottom = '1px solid #ece9d8';
	window.document.getElementById(buttonLayer + "_inner").style.borderLeft = '1px solid #aca899';
	window.document.getElementById(buttonLayer + "_inner").style.borderTop = '1px solid #aca899';
	window.document.getElementById(buttonLayer).style.backgroundColor = '#8fab7e';
	window.document.getElementById(buttonLayer + "_inner").style.height = '14px';
	//window.document.getElementById(buttonLayer).style.border = '1px solid black';
	//window.document.getElementById(buttonLayer + "_inner").style.border = '1px solid #364f23';

}



function setBorderButtonHover(buttonLayer) {

	//window.alert(buttonLayer);
	
	//No layer is set, button is default layer
	//
	if (!buttonLayer) {
	
		buttonLayer = 'button';
	
	}
	

	window.document.getElementById(buttonLayer).style.backgroundColor = '#e1e7de';
		window.document.getElementById(buttonLayer).style.backgroundColor = '#7ab757';


}


function setBorderButtonNormal(buttonLayer) {

	
//window.alert(buttonLayer);
	//No layer is set, button is default layer
	//
	if (!buttonLayer) {
	
		buttonLayer = 'button';
	
	}

	window.document.getElementById(buttonLayer).style.borderLeft = '1px solid #FFFFFF';
	window.document.getElementById(buttonLayer).style.borderTop = '1px solid #FFFFFF';
	window.document.getElementById(buttonLayer).style.borderRight = '1px solid #716f64';
	window.document.getElementById(buttonLayer).style.borderBottom = '1px solid #716f64';
	window.document.getElementById(buttonLayer).style.backgroundColor = '#d6d6d6';
		
	window.document.getElementById(buttonLayer + "_inner").style.borderLeft = '1px solid #ece9d8';
	window.document.getElementById(buttonLayer + "_inner").style.borderTop = '1px solid #ece9d8';
	window.document.getElementById(buttonLayer + "_inner").style.borderRight = '1px solid #aca899';
	window.document.getElementById(buttonLayer + "_inner").style.borderBottom = '1px solid #aca899';


}






function showLargePicture(layerPicture, w, h) {
	
	//Height and width of div
	//
	if (!w && !h) {
		
		w = 0;
		h = 0;

	}
	
	var scalefactorWidth = 6;
	var scalefactorHeight = 6;

	window.document.getElementById(layerPicture).style.width = (w * scalefactorWidth) + ' px';
	window.document.getElementById(layerPicture).style.height = (h * scalefactorHeight) + ' px';
	
	window.document.getElementById(layerPicture).style.visibility = 'visible';

}


function showSmallPicture(layerPicture) {

	window.document.getElementById(layerPicture).style.visibility = 'hidden';
	window.document.getElementById(layerPicture).style.width = '0px';
	window.document.getElementById(layerPicture).style.height = '0px';
	
}


//Make sure size is chosen
//when adding to cart
//(product_info.php)
//

function checkSize(nameForm) {
	
	if (submitted == false) {
	 

	
	var str = "";
	var fset = 0;
	
	//Go through all form elements
	//
	var cform = nameForm.elements.length;

	
	for (i=0;i<cform-1;i++) {
		
	
			
		if (nameForm.elements[i]) {
	
			str = nameForm.elements[i].value;
			
			//value = 8 when --- Choice --- is selected
			//
			if (str.match(8)) {
				
				if (showDialogue == true) {

					window.alert('You must make a choice!');
			
					showDialogue = false;
					i = cform;

				}
				
				fset = 1;
				
			}
			

					
		}

		
	
	}
	
	if (fset == 0) {
		submitted = true;
		nameForm.submit();
	}




	}

}


//Select whole textbox
//
function selectTextBox(id) {
	
	window.document.frmSearch.frmSearchCriteria.value = '';
	
	
	//Div for products is not shown, redirect to right page
	//
	if (window.document.getElementById('productsview')) {
	}
	else {
		window.document.location = 'webshop';
	}
	
	
	
}



//Formula for calculating before ordering a specific product
//and where sqm (kvm) is given by user from form
//
function calculateSqm(productPrice, sqmPerPackage) {

	var nf = document.frmProductData;
	var sqm = nf.frmSqm.value.replace(',', '.');

	var docalc = 'N';
	var price = 0;
	var nrofpackages = 0;
	
	if (parseInt(sqm)>0) {
	
		docalc = 'Y';
		
	}


	//Do calculation (square metres * productprice )
	//
	if (docalc == 'Y') {
		
		//Calculate nr of packages
		//
		nrofpackages = 0;
		price = 0;
		
		
		
		//sqm = value this is typed from user
		//sqmPerPackage = squaremetre per package
		//
		
		//Round sqm-variable to one decimal
		//		
		var sqm_onedecimals=Math.round(sqm*10)/10; 
		sqm = sqm_onedecimals;
		//window.alert(sqm);
		
		
		//If number is something like 2.14, then round up to 3 (Math.ceil)
		//
		nrofpackages = Math.ceil(sqm / sqmPerPackage);		
		price = parseInt( (sqmPerPackage * nrofpackages) * productPrice); 
		
		//Show price and nr of packages for user
		//

		ajax_do('content_showinfo_calculatedsqm.php?productprice=' + productPrice + '&nrofpackages=' + nrofpackages + '&price=' + price + '&sqmperpackage=' + sqmPerPackage);
		
	}
	

}


//Formula for calculating before ordering a specific product
//width is given by system and length (längd) is given by user from form
//
function calculateLengthLpm(productPrice, widthSystem) {


	var nf = document.frmProductData;

	var sqm = 0;
	var lengthUser = nf.frmLengthLpm.value.replace(',', '.');
	var docalc = 'N';
	var price = 0;

	if (parseInt(lengthUser)>0) {
	
		docalc = 'Y';
		
	}


	//Do calculation (square metres * productprice )
	//
	if (docalc == 'Y') {

		//Calculate price (price multiplied with length that user has typed in)
		//
		price = parseInt(lengthUser * productPrice);
	
		//Show price and squaremetres for user
		//	
		
		ajax_do('content_showinfo_calculatedlengthlpm.php?widthsystem=' + widthSystem + '&lengthuser=' + lengthUser + '&productprice=' + productPrice + '&price=' + price);
		
	}
	
}


//Formula for calculating before ordering a specific product
//width is given by system and length (längd) is given by user from form
//
function calculateLength(productPrice, widthSystem) {
	
	
	var sqm = 0;

	var lengthUser = document.frmProductData.frmLength.value.replace(',', '.');

	var docalc = 'N';
	var price = 0;
	
	if (parseInt(lengthUser)>0) {
	
		docalc = 'Y';
		
	}



	//Do calculation (square metres * productprice )
	//
	if (docalc == 'Y') {
		
		//Calculate squaremetres based on width given by system
		//and length given by user
		//
		sqm = lengthUser * widthSystem;
	
		//Calculate price (price multiplied with squaremetres)
		//
		price = parseInt(sqm * productPrice);
	
		//Show price and squaremetres for user
		//	
		ajax_do('content_showinfo_calculatedlength.php?productprice=' + productPrice + '&sqm=' + sqm + '&price=' + price);
		
	}
	
}



//Formula for calculating before ordering a specific product
//Quantity is given by user from form
//
function calculateQuantity(productPrice) {

	var nf = document.frmProductData;
	var quantity = nf.frmQuantity.value.replace(',', '.');
	var docalc = 'N';
	var price = 0;
	
	if (parseInt(quantity)>0) {
	
		docalc = 'Y';
		
	}


	//Do calculation (square metres * productprice )
	//
	if (docalc == 'Y') {
			
		//Calculate price (price multiplied with quantity)
		//
		price = parseInt(quantity * productPrice);
	
		//Show price and squaremetres for user
		//	
		ajax_do('content_showinfo_calculatedlengthlpm.php?price=' + price);
		
	}
	
}





//Formula for calculating before ordering a specific product
//There are more than one width for product, that user must choose from form
//and length (längd) is given by user from form
//
function getCheckedValue(radioObj) {

	
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}



function calculateLengthOptionalWidths(productPrice) {

	var nf = document.frmProductData;
	var sqm = 0;
	var lengthUser = nf.frmLength.value.replace(',', '.');
	var docalc = 'N';
	var price = 0;
	var widthUser = getCheckedValue(nf.frmOption);	//Get value from selected radiobutton

	
	if (parseInt(lengthUser)>0) {
	
		if (parseInt(widthUser) == 0) {
				window.alert('Du måste välj bredd genom att klicka på valbar bredd ovan!');
		}
		else {
			
			//width and length is set and above 0
			//
			docalc = 'Y';
	
		}
		
	}
	
	//Do calculation (square metres * productprice )
	//
	if (docalc == 'Y') {
		
		//Calculate squaremetres based on width given by user
		//and length given by user
		//
		sqm = lengthUser * widthUser;
	
		//Calculate price (price multiplied with squaremetres)
		//
		price = parseInt(sqm * productPrice);
	
		//Show price and nr of packages for user
		//
		
		ajax_do('content_showinfo_calculatedlength.php?productprice=' + productPrice + '&sqm=' + sqm + '&price=' + price);
		
	}
	

}


//form validation from productinfo-page
function checkFilledIn(obj, feedbackText) {

	
	if (obj.value == 0 || obj == null) {
			alert(feedbackText);
			return false;
	}
	else {
		return true;
	}
	
}
