
function hiLite(imgDocID,width,height,path) {

	// detect browser 
	browserName = navigator.appName;
	browserVer = parseInt(navigator.appVersion);
	if (browserName == "Netscape" && browserVer >= 3) browserVer = "1";
	else if (browserName == "Microsoft Internet Explorer" && browserVer == 4) browserVer = "1";
	else browserVer = "2";	
	
	if (browserVer == 1) {
		img = new Image(width,height);
		img.src = path;
		
		document.images[imgDocID].src = eval("img.src")
	}
}

function AutoSize()
{
    var ltable, mtable, rtable, lmcell, rmcell, mmcell;
    var imgm, imglb, imgrb;

    if (document.getElementById)
    {
        ltable = document.getElementById('lc');
        mtable = document.getElementById('mc');
        rtable = document.getElementById('rc');
        lmcell = document.getElementById('lm');
        rmcell = document.getElementById('rm');
        mmcell = document.getElementById('mm');
        imgm = document.getElementById('sep_v');
        imglb = document.getElementById('lb');
        imgrb = document.getElementById('rb');
    }
    else if (document.all)
    {
        ltable = document.all['lc'];
        mtable = document.all['mc'];
        rtable = document.all['rc'];
        lmcell = document.all['lm'];
        rmcell = document.all['rm'];
        mmcell = document.all['mm'];
    }
    
    if(ltable.clientHeight >= rtable.clientHeight)
    {
        if(!mtable.style.height)
        {
            imgm.height = lmcell.clientHeight+6;
            imgm.width=1;
            imglb.height = lmcell.clientHeight;
            imglb.width=9;
            imgrb.height = lmcell.clientHeight-55;
            imgrb.width=9;
        }
        if(!mtable.style.innerHeight)
        {
            imgm.height = lmcell.clientHeight+6;
            imgm.width=1;
            imglb.height = lmcell.clientHeight;
            imglb.width=9;
            imgrb.height = lmcell.clientHeight-55;
            imgrb.width=9;
        }              
    }
    else
    {        

        if(!mtable.style.height)
        {
            imgm.height = rmcell.clientHeight+61;
            imgm.width=1;
            imglb.height = rmcell.clientHeight+55;
            imglb.width=9;
            imgrb.height = rmcell.clientHeight;
            imgrb.width=9;
        }
        if(!mtable.style.innerHeight)
        {
            imgm.height = rmcell.clientHeight+61;
            imgm.width=1;
            imglb.height = rmcell.clientHeight+55;
            imglb.width=9;
            imgrb.height = rmcell.clientHeight;
            imgrb.width=9;
        }    
    }
}

function GetSize()
{
    var lmcell = document.getElementById('lm');
    var rmcell = document.getElementById('rm');
    
    if(lmcell.clientHeight + 190 >= rmcell.clientHeight + 90)
    {
        if(!rmcell.style.InnerHeight)
        {
            rmcell.style.InnerHeight = lmcell.clientHeight + 100;
        }
    }
    else
    {
        lmcell.style.InnerHeight =  rmcell.clientHeight - 100;
    }  
}


function submitform(){
	
	//alert("Denna funktion är inte byggd än.\n" + "Kommer inom kort...");
	if(formvalidation(document.offert)){
		document.offert.submit();
	}
}

function formvalidation(thisform){
	with (thisform){
		
		if (checkboxvalidation(varme,kyla)==false){
			alert("Du har inte valt vad du är intresserad av!");
			return false;
		}
		if (radiovalidation(strl)==false){
			alert("Du har inte valt vilken storlek ditt hus är!");
			return false;
		}
		if (radiovalidation(hustyp)==false){
			alert("Du har inte valt vilken typ av hus du har!");
			return false;
		}
		if (emptyvalidation(namn)==false){
			alert("Fyll i ditt namn!");
			namn.focus();
			return false;
		}
		if (emptyvalidation(tel)==false){
			alert("Fyll i ditt telefonnummer!");
			tel.focus();
			return false;
		}
	
		if (emptyvalidation(epost)==false){
			alert("Fyll i din epostadress");
			epost.focus();
			return false;
		}	

		if (emailvalidation(epost)==false){
			alert("Fyll i en korrekt epostadress");
			epost.select();
			return false;
		}
	}
	return true;
}

function checkboxvalidation(varme,kyla) {
	if (varme.checked || kyla.checked){
		return true;
	}
	else{
		return false;
	}
}

function radiovalidation(entered) {
	for (var i=0; i<entered.length; i++)  { 
		if (entered[i].checked)  {
			return true;
		} 
	} 
	return false;
}

function emailvalidation(entered){
	with (entered){
		apos=value.indexOf("@"); 
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) {
			return false;
		}
		else {
			return true;
		}
	}
} 

function emptyvalidation(entered){
	with (entered){
		if (value==null || value==""){
			return false;
		}
		else{
			return true;
		}
	}
} 