function setScreenSize()
	{
	var maxHeight;
	var sidbredd=1024;
	var sidhojd=768;
	var kroppHojd=800;
	var kroppBredd=1024;
	
if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    sidbredd = window.innerWidth;
    sidhojd = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    sidbredd = document.documentElement.clientWidth;
    sidhojd = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    sidbredd = document.body.clientWidth;
    sidhojd = document.body.clientHeight;
  }

  
    kroppHojd=sidhojd-195;
	kroppBredd=sidbredd;
	if (kroppHojd<400){kroppHojd=400;}
	if (kroppBredd<900){kroppBredd=900;}

	if(kroppBredd<1280){  //Liten skärm
			document.getElementById('sida1').style.width=kroppBredd-320 + "px";
		}
	else{
			document.getElementById('sida1').style.width=900 + "px";
		}
		
		
	document.getElementById('sida2').style.left=kroppBredd-280 + "px";
	

	if(document.getElementById('innehall1').offsetHeight+10>document.getElementById('sida1').offsetHeight)
		{document.getElementById('sida1').style.height=document.getElementById('innehall1').offsetHeight+10 + "px";}
	
	if(kroppHojd<document.getElementById('sida1').offsetHeight+100)
		{kroppHojd=document.getElementById('sida1').offsetHeight+100}
	
	
	document.getElementById('kropp').style.height=kroppHojd + "px";

	document.getElementById('kroppInreL').style.height=kroppHojd-40 + "px";
	document.getElementById('kroppInre').style.height=kroppHojd-30 + "px";
	document.getElementById('kroppInreR').style.height=kroppHojd-40 + "px";


	document.getElementById('kroppInre').style.width=kroppBredd-50 + "px";
	document.getElementById('fot').style.width=kroppBredd + "px";

	document.getElementById('kroppInreR').style.left=kroppBredd-30 + "px";
	document.getElementById('kroppInreRT').style.left=kroppBredd-30 + "px";

	}

function raderaBild(namn){
	if (confirm("Verifiera radering!\n\n Klicka OK om du är HELT SÄKER på att du vill radera denna bild (" + namn + ").\n\nOBS!!\nVar noga så du inte raderar bilder som används i någon post!")) {
	  window.location=".?go=raderabild&bildNamn=" + namn;
	}
}


function raderaPost(nr,oldgo){
	if (confirm("Verifiera radering!\n\n Klicka OK om du är HELT SÄKER på att du vill radera denna post.")) {
	  window.location=".?go=radera&nr=" + nr + "&oldgo=" +oldgo;
	}
}

function checkSubmit(form){
var aktuellStart, aktuelltStopp;
aktuelltStart="2000-01-01";
aktuelltStopp="2099-01-01";
for(i=0; i<form.elements.length; i++){
	if(form.elements[i].name=='AktuelltStart'){
		aktuelltStart=form.elements[i].value;
		form.elements[i].select();
		form.elements[i].focus();
		};
	if(form.elements[i].name=='AktuelltStopp'){aktuelltStopp=form.elements[i].value};
	}
	if(isDate(aktuelltStart)!=""){
		alert("Felaktigt startdatum\n(" + isDate(aktuelltStart) + ")")
		return false;
	}
	if(isDate(aktuelltStopp)!=""){
		alert("Felaktigt stoppdatum\n(" + isDate(aktuelltStopp) + ")")
		return false;
	}
	if(aktuelltStopp<aktuelltStart){
		alert("Startdatum måste vara tidigare än (eller samma som) stoppdatum");
		return false;
	}
	return true;
}

var minYear=1900;
var maxYear=2100;

function isDate(dtStr){
	var splitDate=dtStr.split("-");
	var strYear=splitDate[0];
	var strMonth=splitDate[1];
	var strDay=splitDate[2];
	
	
	var daysInMonth = DaysArray(12)
	if(!isInteger(strYear+strMonth+strYear)){
		return("Felaktigt tecken");
	}

	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)

	if (strMonth.length<1 || month<1 || month>12){
		return("Felaktig månad")
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return("Felaktig dag")
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return("Ange ett år mellan "+minYear+" och "+maxYear)
	}
return("");
}

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

