var timerWidth=new Array();
var timerHeight=new Array();
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
var badBrowser = 0;
if (browser == "Microsoft Internet Explorer" && version < 5){
	badBrowser = 1;
}
function expandImg(id, widthOld, heightOld, widthNew, heightNew){	
	if (document.images["bloggImg"+id].width == widthOld && document.images["bloggImg"+id].height == heightOld){
		Timerw(id,widthOld,widthNew);
		Timerh(id,heightOld,heightNew);	 	
	}
	else{
		if (document.images["bloggImg"+id].width == "" && document.images["bloggImg"+id].height == ""){
			document.images["bloggImg"+id].width = widthOld;
			document.images["bloggImg"+id].height = heightOld;
			Timerw(id,widthOld,widthNew);
			Timerh(id,heightOld,heightNew);	 	
		}
		else{
			document.images["bloggImg"+id].width=widthOld;
			document.images["bloggImg"+id].height=heightOld;
			document.images["bloggImg"+id].style.marginRight="2px";
			document.images["bloggImg"+id].style.marginLeft="2px";
			document.images["bloggImg"+id].style.borderLeftStyle="solid";
			document.images["bloggImg"+id].style.borderRightStyle="solid";
			document.images["bloggImg"+id].style.borderBottomStyle="solid";
			clearTimeout(timerHeight[id]);
			clearTimeout(timerWidth[id]);
		}
	}
}

function Timerw(id,curWidth,widthNew){
	if (curWidth < widthNew){
		document.images["bloggImg"+id].width = curWidth;
		var alphaWidth = widthNew-curWidth;
		curWidth = curWidth+(alphaWidth*0.2);
		if (alphaWidth < 1.1){
			document.images["bloggImg"+id].width = widthNew;
			curWidth = widthNew;
			if (widthNew == 600){
				document.images["bloggImg"+id].style.borderLeftStyle="none";
				document.images["bloggImg"+id].style.borderRightStyle="none";
			}
		}
		else{
			document.images["bloggImg"+id].style.marginRight= (580-curWidth)/2+"px";
			document.images["bloggImg"+id].style.marginLeft=  (580-curWidth)/2+"px";
			timerWidth[id]=setTimeout("Timerw("+id+","+curWidth+","+widthNew+")",2);
		}
	}
}

function Timerh(id,curHeight,heightNew){
	if (curHeight < heightNew){
		document.images["bloggImg"+id].height=curHeight;
		alphaHeight = heightNew-curHeight;
		curHeight = curHeight+(alphaHeight*0.2);
		if (alphaHeight < 1.1){
			document.images["bloggImg"+id].height=heightNew;
			curHeight = heightNew;
		}
		else{
			timerHeight[id]=setTimeout("Timerh("+id+","+curHeight+","+heightNew+")",2);
		}
	}
}

function imgGetFocus(id){
	document.images["bloggImg"+id].style.borderColor = "white";
}
function imgLoseFocus(id){
	document.images["bloggImg"+id].style.borderColor = "#cecece";
}
function writeComment(location){
	document.getElementById("writeCommentBox").style.opacity = 0;
	document.getElementById("commentHeader").value = "Rubrik";
	if(badBrowser != 1) {
		document.getElementById("commentHeader").style.color = "grey";
	}
	document.getElementById("commentText").value = "Skriv din kommentar här...";
	if(badBrowser != 1) {
		document.getElementById("commentText").style.color = "grey";
	}
	document.getElementById("writeCommentBox").style.visibility = "visible";
	
	var scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	}
	
	
	document.getElementById("writeCommentBox").style.top = scrOfY + 50 + "px";
	document.getElementById("commentLocation").value = location;
	document.getElementById("commentHeader").focus();
	fadeUpComment(0);

}
timerFadeUpComment = 0;
function fadeUpComment(opacity){
	document.getElementById("writeCommentBox").style.visibility = "visible";
	document.getElementById("writeCommentBox").style.opacity = opacity/100;
	opacity += 10;
	if (opacity <= 100){
		timerFadeUpComment = setTimeout("fadeUpComment("+opacity+")",2);
	}
}


function closeCommentBox(){
	document.getElementById("writeCommentBox").style.visibility = "hidden";
	document.getElementById("writeCommentBox").style.opacity = 0;
	clearTimeout(timerFadeUpComment);
}
function clearText(id){
if (id.name == "header" && id.value == "Rubrik" || id.name == "text" && id.value == "Skriv din kommentar här..." || id.name == "author" && id.value == "Namn"){
		id.value = "";
	}
	if(badBrowser != 1) {
		id.style.color = "black";
	}
}

function blurText(id){
if (id.name == "header" && (id.value == "" || id.value == " ")){
		id.value = "Rubrik";
		if(badBrowser != 1) {
			id.style.color = "grey";
		}
	}
	if (id.name == "text" && (id.value == "" || id.value == " ")){
		id.value = "Skriv din kommentar här...";
		if(badBrowser != 1) {
			id.style.color = "grey";
		}
	}
	if (id.name == "author" && (id.value == "" || id.value == " ")){
		id.value = "Namn";
		if(badBrowser != 1) {
			id.style.color = "grey";
		}
	}
}