if ( !(myVar > 2) ) {var myVar = 2}
var contestRow
var theUsername
var designid

var border_style, border_width, border_color, attr_px, from, theinput, element, css, border_style, border_width, bcolor

function checkEmail(str) {
	email = str
	AtPos = email.indexOf("@")
	StopPos = email.lastIndexOf(".")
	badMail = false
	
	if (email == "") {
		badMail = true
	}
	
	if (AtPos == -1 || StopPos == -1) {
		badMail = true
	}
	
	if (StopPos < AtPos) {
		badMail = true
	}
	
	if (StopPos - AtPos == 1) {
		badMail = true
	}
	
	if (badMail == true) {return "0"} else {return "1"}
}

function validatePassword(str) {
	if (document.getElementById("password").value.length > 4) {
		document.getElementById("ajax_password").style.display = 'none'
		document.getElementById("approve_password").style.display = 'block'
	} else {
		document.getElementById("ajax_password").style.display = 'none'
		document.getElementById("disapprove_password").style.display = 'block'
	}
}

function validatePasswordVal(str) {
	if (document.getElementById("password").value == document.getElementById("passwordValidate").value) {
		document.getElementById("ajax_passwordValidate").style.display = 'none'
		document.getElementById("approve_passwordValidate").style.display = 'block'
	} else {
		document.getElementById("ajax_passwordValidate").style.display = 'none'
		document.getElementById("disapprove_passwordValidate").style.display = 'block'
	}
}

function validateWebsite(str) {
	if (document.getElementById("website").value.length > 4) {
		document.getElementById("ajax_website").style.display = 'none'
		document.getElementById("approve_website").style.display = 'block'
	} else {
		document.getElementById("ajax_website").style.display = 'none'
		document.getElementById("approve_website").style.display = 'none'
	}
}

function validateSignup(e) {
	
	if (e == 'email') {
		if(checkEmail(document.getElementById("email").value) == "0") {
			document.getElementById("ajax_"+e).style.display = 'none'
			document.getElementById("disapprove_"+e).style.display = 'block'
			return false
		}
	}
	
	var xmlhttp;
	if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest();}
	else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
	xmlhttp.onreadystatechange=function(){
	if(xmlhttp.readyState==1){
	}
	if(xmlhttp.readyState==4){
	//------------------------------------
		document.getElementById("ajax_"+e).style.display = 'none'
		msg=xmlhttp.responseText;
		if (msg == "0") {
				document.getElementById("approve_"+e).style.display = 'none'
				document.getElementById("disapprove_"+e).style.display = 'block'
		} else {
				document.getElementById("disapprove_"+e).style.display = 'none'
				document.getElementById("approve_"+e).style.display = 'block'
		};
	//------------------------------------
	}
	}
	xmlhttp.open("GET","/validate_signup.asp?str="+document.getElementById(e).value+"&t="+e,true);
	xmlhttp.send(null);
}

function del_thread() {
	if (document.getElementById("deleteThread").checked == true) {
		$("#moderatormessagediv").slideDown("slow",function() {
			document.getElementById("moderatormessage").focus()
		});
	}
	if (document.getElementById("deleteThread").checked == false) {
		$("#moderatormessagediv").slideUp("slow");
	}
}

function move_thread() {
	if (document.getElementById("move").checked == true) {
		$("#moderatormessagemovediv").slideDown("slow",function() {
			document.getElementById("moderatormessagemove").focus()
		});
	}
	if (document.getElementById("move").checked == false) {
		$("#moderatormessagemovediv").slideUp("slow");
	}
}


function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


function setCaretPosition(elemId) {
    var elem = document.getElementById(elemId);
	var caretPos = elem.value.length
    if(elem != null) {
        if(elem.createTextRange) {
            var range = elem.createTextRange();
            range.move('character', caretPos);
            range.select();
        }
        else {
            if(elem.selectionStart) {
                elem.focus();
                elem.setSelectionRange(caretPos, caretPos);
            }
            else
                elem.focus();
        }
    }
}

function getScrollY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfY ];
}

function getSelText()
{
    var txt = '';
     if (window.getSelection)
    {
        txt = window.getSelection();
             }
    else if (document.getSelection)
    {
        txt = document.getSelection();
            }
    else if (document.selection)
    {
        txt = document.selection.createRange().text;
            }
    else return;
//	alert(document.getElementById("message").selectionStart)
//document.form_message.content.value =  txt;
//document.selection.createRange().text = 'Some new text';

textEditorName = "message"

if(document.selection){
cDoc = document.getElementById(textEditorName);
range=cDoc.selection.createRange();

alert(range.text)

//range.pasteHTML("<span>"+range.text+"</span>");
cDoc.selection.empty();
} else if (window.getSelection) {

//cWin = document.getElementById(textEditorName).contentWindow;
//userSelection = cWin.getSelection();
//alert(userSelection)
//hiliteText = "<span>"+userSelection+"</span>";
//textEditor.contentWindow.document.execCommand('insertHTML',false,hiliteText); 
alert('FF')

}


}

	
function cancel_share_blog()
{
$(document).ready(function() {

$("#share_blog").fadeOut("fast");

})
	
}

function share_blog()
{
		var scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0
		var w = 464
		var h = 500
			var left = (screen.width/2)-(w/2);
			var top = (screen.height/2)-(h/2) + scrollTop;
				document.getElementById("share_blog").style.left = left+"px";
				document.getElementById("share_blog").style.top = top+"px";
	
	$(document).ready(function() {
		$("#share_blog").fadeIn("fast");
			document.getElementById("share_blog_box").select()
		})	
}


function attach_code()
{
	
	$("#attach_link").fadeOut("fast",function(){
		var scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0
		var w = 464
		var h = 500
			var left = (screen.width/2)-(w/2);
			var top = (screen.height/2)-(h/2) + scrollTop;
				document.getElementById("attach_code").style.left = left+"px";
				document.getElementById("attach_code").style.top = top+"px";
	
	$(document).ready(function() {
		$("#attach_code").fadeIn("fast");
			document.getElementById("attach_code_box").focus()
		})	
	});
}

function attach_code_return() {
	$("#attach_code").fadeOut("fast");			
	c = document.getElementById("attach_code_box").value
	document.getElementById("attach_code_box").value = ""
	document.getElementById("message").value = document.getElementById("message").value + " [code] " + c + " [/code] "
	document.getElementById("message").focus()
	setCaretPosition('message')

}

	
function cancel_attach_code()
{
$(document).ready(function() {

$("#attach_code").fadeOut("fast");

})
	
}










function attach_link()
{
	$("#attach_code").fadeOut("fast",function(){
		var scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0
		var w = 464
		var h = 500
			var left = (screen.width/2)-(w/2);
			var top = (screen.height/2)-(h/2) + scrollTop;
				document.getElementById("attach_link").style.left = left+"px";
				document.getElementById("attach_link").style.top = top+"px";
	
	$(document).ready(function() {
		$("#attach_link").fadeIn("fast");
			document.getElementById("attach_link_box").focus()
		})	
	});
}

function attach_link_return() {
	$("#attach_link").fadeOut("fast");			
	l = document.getElementById("attach_link_box").value
	document.getElementById("attach_link_box").value = ""
	document.getElementById("message").value = document.getElementById("message").value + " [url] " + l + " [/url] "
	document.getElementById("message").focus()
	setCaretPosition('message')
}

	
function cancel_attach_link()
{
$(document).ready(function() {

$("#attach_link").fadeOut("fast");

})
	
}








function pick_winner(id,uname,cid) {
	var answer = confirm('Vill du utse '+uname+' som vinnare för denna tävling?')
	if (answer) {
		
		$("#pick_winner_wait_"+id+"_"+cid).fadeIn("slow", function() {
			
			$.ajax({
			type: "GET",
			url: "/myportfolio/include/blogdesign/pick_winner.asp",
			data: "wid="+id+"&cid="+cid,
			success: function(msg) 
				{
					$("#pick_winner_wait_"+id+"_"+cid).fadeOut("slow")
					$(".pick_winner_"+cid).fadeOut("slow", function() {
						$("#pick_winner_button_"+cid).fadeOut("slow")
						$("#contest_winner_"+id+"_"+cid).fadeIn("slow", function() {
							$("#winner_picked_"+cid+"_"+id).fadeIn("slow")
						})										 
					})
				}
			});
				
		})

	}
}

function close_contest_users(id) {
	d = document.getElementById("contest_users"+id)
	$(d).ready(function() {
	$(d).fadeOut("medium")
	})
}

function show_contesters(id) {
	d = document.getElementById("contest_users"+id)
	$(d).ready(function() {
	$(d).fadeIn("medium")
	})
}

function unique_info(e,t)
{
	d = document.getElementById("unique_info")
	
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
	if (d.style.display == 'none')
	{
	d.style.top = posy-10+'px'
	d.style.left = posx+16+'px'
	$(d).ready(function() {
	$(d).fadeIn("fast")
	})
	}

document.getElementById(t).src = "/bilder/icon_info_small_over.gif"
//	document.getElementById(t.id).src = ''
}

function unique_info_hide(t)
{
	d = document.getElementById("unique_info")
	$(d).ready(function() {
	$(d).fadeOut("fast")
	})
	

document.getElementById(t).src = "/bilder/icon_info_small.gif"
}


function prices_info(e,t)
{
	d = document.getElementById("prices_info")
	
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
	if (d.style.display == 'none')
	{
	d.style.top = posy-10+'px'
	d.style.left = posx+16+'px'
	$(d).ready(function() {
	$(d).fadeIn("fast")
	})
	}

document.getElementById(t).src = "/bilder/icon_info_small_over.gif"
//	document.getElementById(t.id).src = ''
}

function prices_info_hide(t)
{
	d = document.getElementById("prices_info")
	$(d).ready(function() {
	$(d).fadeOut("fast")
	})
	

document.getElementById(t).src = "/bilder/icon_info_small.gif"
}





function shipment_info(e,t)
{
	d = document.getElementById("shipment_info")
	
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
	if (d.style.display == 'none')
	{
	d.style.top = posy-10+'px'
	d.style.left = posx+16+'px'
	$(d).ready(function() {
	$(d).fadeIn("fast")
	})
	}
document.getElementById(t).src = "/bilder/icon_info_small_over.gif"
}

function shipment_info_hide(t)
{
	d = document.getElementById("shipment_info")
	$(d).ready(function() {
	$(d).fadeOut("fast")
	})
document.getElementById(t).src = "/bilder/icon_info_small.gif"
}






function personal_info(e,t)
{
	d = document.getElementById("personal_info")
	
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
	if (d.style.display == 'none')
	{
	d.style.top = posy-10+'px'
	d.style.left = posx+16+'px'
	$(d).ready(function() {
	$(d).fadeIn("fast")
	})
	}
document.getElementById(t).src = "/bilder/icon_info_small_over.gif"
}

function personal_info_hide(t)
{
	d = document.getElementById("personal_info")
	$(d).ready(function() {
	$(d).fadeOut("fast")
	})
document.getElementById(t).src = "/bilder/icon_info_small.gif"
}


function check_file_ext2(e)
{
document.getElementById("upload_design_screenshot_text").style.color = "#535353";
document.getElementById("file").style.color = "#000";

var app_file
var file_ext = e.value
var l = file_ext.length
file_ext = file_ext.slice(l-4,l)

if (file_ext==".jpg") {app_file=true}
if (file_ext==".gif") {app_file=true}

if (file_ext==".JPG") {app_file=true}
if (file_ext==".GIF") {app_file=true}


if (app_file==true) {

$("#upload_design_loading").ready(function(){
	$("#upload_design_error_2").fadeOut("fast")
	$("#upload_design_error_1").fadeOut("fast", function() {
	$("#upload_design_loading").fadeIn("fast")
	})
})

document.forms.form_upload_screenshot.submit()
}
else
{
alert('Du försöker att ladda upp en ogiltig fil. Giltiga filer att ladda upp är JPG och GIF' )
}



}

function check_file_ext(e)
{
var app_file
var file_ext = e.value
var l = file_ext.length
file_ext = file_ext.slice(l-4,l)

if (file_ext==".jpg") {app_file=true}
if (file_ext==".gif") {app_file=true}

if (file_ext==".JPG") {app_file=true}
if (file_ext==".GIF") {app_file=true}



if (app_file==true) {
document.getElementById("buttonScreenshot").disabled = false
document.forms.form_poll_image.submit()
}
else
{
alert('Du försöker att ladda upp en ogiltig fil. Giltiga filer att ladda upp är JPG och GIF' ) ; document.getElementById("buttonScreenshot").disabled = true
}



}

function checkHash(str)
{
	if ( location.hash.indexOf(str) != -1 ) { return true }
}

function forum_watch(fid,uid)
{
	
$(document).ready(function() {

	 $.ajax({
	   type: "GET",

	   url: "/include/functions.asp",
	   data: "",
	   success: function(msg){	
		$("#forum_watch").fadeOut("slow")
	   }
	})
})

}

function reply_forum()
{
	window.location = '#reply';
	tinyMCE.get('message').focus();
}

function change_email(userid)
{
	var e = document.getElementById("email")
	e.disabled = false;
	e.value = "";
	e.focus()
	//if (e.length = 0) {  }
}

function restore_email(email)
{
	var e = document.getElementById("email")
	if (e.value == "" ) { e.value = email }
}

function change_password()
{
	
	var	e = document.getElementById("change_password_1")
	if (e.style.display == 'none') {
		document.getElementById("change_password_1").style.display = '';
		document.getElementById("change_password_2").style.display = '';
		document.getElementById("change_password_3").style.display = '';
		document.getElementById("old_password").focus()
		document.getElementById("password_link_text").innerHTML = "Återställ till gamla l&ouml;senordet"
		document.getElementById("form_settings_account").action = "/?savesettings=account&password=new"
	}
	else
	{
		document.getElementById("change_password_1").style.display = 'none';
		document.getElementById("change_password_2").style.display = 'none';
		document.getElementById("change_password_3").style.display = 'none';
		document.getElementById("old_password").value = '';
		document.getElementById("new_password").value = '';
		document.getElementById("new_password_verify").value = '';
		document.getElementById("password_link_text").innerHTML = "Klicka h&auml;r f&ouml;r att byta l&ouml;senord"
		document.getElementById("form_settings_account").action = "/?savesettings=account"
	}
}

function save_settings_account()
{
	
}

function save_settings_profile(id)
{
var firstname = document.getElementById("firstname").value, lastname = document.getElementById("lastname").value, city = document.getElementById("city").value, website = document.getElementById("website").value, birthday_date = document.getElementById("birthday_date").value, birthday_month = document.getElementById("birthday_month").value, birthday_year = document.getElementById("birthday_year").value, button = document.getElementById("button_save_settings_profile")
window.location = "/?savesettings=profile&firstname="+firstname+"&lastname="+lastname+"&city="+city+"&website="+website+"&birthday_date="+birthday_date+"&birthday_month="+birthday_month+"&birthday_year="+birthday_year+""
}

function set_border(border,mid)
{
document.getElementById("border-type").innerHTML = border;
document.getElementById("td_border-style").innerHTML = "border-"+mid+"-style";
document.getElementById("td_border-width").innerHTML = "border-"+mid+"-width"
document.getElementById("td_border-color").innerHTML = "border-"+mid+"-color"

if (mid=="top") {info="överst"}
if (mid=="bottom") {info="nederst"}
if (mid=="left") {info="vänster"}
if (mid=="right") {info="höger"}

document.getElementById("td_border-style-info").innerHTML = "Justerar "+info+" kanttyp"
document.getElementById("td_border-width-info").innerHTML = "Justerar "+info+" kanttjocklek"
document.getElementById("td_border-color-info").innerHTML = "Justerar "+info+" kantfärg"
}


function update_code_element(style,attr)
{
	if (border_width==undefined){element="border-style: "+border_style}
	if (border_style==undefined){element="border-style: "+border_width}
	if (border_width!==undefined && border_style!==undefined) {element="border-style: "+border_style+"; border-width: "+border_width}
	e = document.getElementById("example_code_element")
	//if (border_style==undefined){css="{ <br /> border-style: "+border_width+"<br />}"}
	//if (border_width==undefined){css="{ <br /> border-style: "+border_style+"<br />}"}
	//if (border_width!==undefined && border_style!==undefined) {css="{ <br /> border-style: "+border_style+"<br />border-width: "+border_width+"<br />}"}
	if (border_color!==undefined) {element = element + "; border-color: "+border_color+""}	
	c = document.getElementById("example_code_css")
	
	e.innerHTML = "&lt;div style=\""+element+"\"&gt;"

}

function set_border_style(div,attr,value)
{
	border_style = value
	e = document.getElementById(div)
	e.style.borderStyle = ""+value+""
	update_code_element(value,'border-style')
	document.getElementById("example_border_style").innerHTML = value + ";"
	document.getElementById("example_border_style_2").innerHTML = value
}

function set_border_width(div,attr,value)
{
	border_width = value
	e = document.getElementById(div)
	e.style.borderWidth = ""+value+""
	update_code_element(value,'border-width')
	document.getElementById("example_border_width").innerHTML = value + ";"
	document.getElementById("example_border_width_2").innerHTML = value
	
}

function set_border_width_pixel(div,attr,value)
{
	document.getElementById("pixel_div").style.display = "";
	document.getElementById("color_div").style.display = "none";
	document.getElementById("pixel").focus();
}

function set(input,id)
{
	theinput = id
}

function border_width_change()
{
	value = document.getElementById("pixel").value
	document.getElementById("pixel_div").style.display = "none";
	document.getElementById("border_div").style.borderWidth = ""+value+"px";
	document.getElementById("pixel").value = "";
	document.getElementById("example_border_width").innerHTML = value+"px;";

	border_width = value+"px";
	update_code_element(value,'border-width');
}

function border_color_change()
{
	str = document.getElementById("border_div").style.borderStyle
	//alert(str)
	
	border_color = document.getElementById("color").value
	value = document.getElementById("color").value
	bcolor = document.getElementById("color").value 
	document.getElementById("color_div").style.display = "none";
	document.getElementById("border_div").style.borderColor = ""+value+"";
	document.getElementById("color").value = "";
	document.getElementById("example_border_color").innerHTML = value + ";"
	update_code_element(border_color,'border-color')
	document.getElementById("example_border_color_2").innerHTML = value
}

function set_border_color()
{
	//value = document.getElementById("pixel").value
	document.getElementById("color_div").style.display = "";
	document.getElementById("pixel_div").style.display = "none";	
	document.getElementById("color").focus()

}

function enter_css_pixel(e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
border_width_change()
	
	document.getElementById("pixel").value = "";
	
   return false;
   }
else
   return true;
  
}

function enter_css_color(e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
border_color_change()
	
	document.getElementById("color").value = "";
	
   return false;
   }
else
   return true;
  
}











function swap_image(thisone,folder,pic) {
thisone.src = "http://bloggdesign.nu/bilder/"+pic+"_over.jpg";
}
function swapBack(thisone,folder,pic) {
thisone.src = "http://bloggdesign.nu/bilder/"+pic+".jpg";
}



function swap(thisone,folder,pic) {
thisone.src = "http://bloggdesign.nu/artiklar/"+folder+"/"+pic+"_over.jpg";
}
function swapBack(thisone,folder,pic) {
thisone.src = "http://bloggdesign.nu/artiklar/"+folder+"/"+pic+".jpg";
}

function commentdesign()
{
	window.location = "#writecomment"
	document.getElementById("comment_design_message").focus()
}

function delete_design(id)
{
var result = confirm('OBS! Vill du radera denna design?')
if (result) {window.location = "/?delete=design&id="+id+""}
}

function editpost(id,forum,topic,page)
{

	$(document).ready(function() {

	 $.ajax({
	   type: "GET",

	   url: "/include/functions_site.asp",
	   data: "editpost="+id+"&forum="+forum+"&topic="+topic+"&page="+page+"",
	   success: function(msg){
		  // msg = msg.replace(/&#229;/g,"å")
		 //  msg = msg.replace(/&#228;/g,"ä")
		//   msg = msg.replace(/&#246;/g,"ö")
		//   msg = msg.replace(/&#197;/g,"Å")
		//   msg = msg.replace(/&#196;/g,"Ä")
	//	   msg = msg.replace(/&#214;/g,"Ö")
//		   msg = msg.replace(/&amp;/g,"")
	document.getElementById("newPostMessage").value = msg
	document.getElementById("post_write_title").innerHTML = "Redigera inlägg"
	document.getElementById("post_write_button").value = "Spara ändringar"
	document.forms[1].action = "/?forum="+forum+"&topic="+topic+"&editpostsave="+id+"&page="+page+""

	window.location = "#writepost"
	   }
	})
})
	

}

function freetv(id,nr)
{
	var nr2
	$(document).ready(function() {
			   $.ajax({
			   type: "GET",
			   url: "/include/functions_site.asp",
			   data: "freetv="+id+"&nr="+nr+"",
			   success: function(msg){	
			   nr2 = nr - 1

				document.getElementById("bajja").innerHTML = "Visningen är nu betald! Förväntad kötid: "+msg+"min"
				if (nr2==0) {document.getElementById("free_tv_nrs").innerHTML = "Du har inga gratisvisningar kvar."}
				if (nr2==1) {document.getElementById("free_tv_nrs").innerHTML = "Du har 1 gratisvisning att anv&auml;nda."}
				if (nr2>1) {document.getElementById("free_tv_nrs").innerHTML = "Du har "+nr2+" gratisvisningar att anv&auml;nda."}
				$("#free_tv_button").fadeOut(500, function () {
											 $("#free_tv_payed").fadeIn(1000)
											 })
				
				
			   }
			   })
})
}

function show_delete(id)
{
document.getElementById("delete_design"+id+"").src = '/bilder/icon_design_delete.gif'
}

function hide_delete(id)
{
document.getElementById("delete_design"+id+"").src = '/bilder/icon_design_delete_off.gif'
}

function checkCommentDesign(id)
{
	var message = document.getElementById("comment_design_message").value, cmessage, cleanmessage = document.getElementById("comment_design_message").value
	
	cleanmessage = message.replace(/\n/g,"<br/>")
	cmessage = message.indexOf("\n")
	message = message.replace(/\n/g,"[--{br}--]")
	
	if (document.getElementById("comment_design_message").value == '')
	{
		alert('Du måste skriva ett meddelande för att kunna kommentera')
		document.getElementById("comment_design_message").focus()
		return false;
	}
	
	if (document.getElementById("comment_design_message").value.length < 4)
	{
		alert('Det där va vell lite snålt med text va? :)')
		document.getElementById("comment_design_message").focus()
		return false;
	}
	
	
$(document).ready(function() {
						   
		   
	$("#button2").fadeOut("medium", function () {
		$("#comment_wait").fadeIn("medium", function () {
		
			 $.ajax({
			   type: "GET",
			   //url: "/include/functions_site.asp",
				url: "/blogdesign/comment.asp",
			   data: "commentdesign="+id+"&message="+message+"",
			   success: function(msg){

				   var userid, username, userpicture
				   splitmsg = msg.split("|")
				   message = splitmsg[0]
				   username = splitmsg[1]
				   userid = splitmsg[2]
				   userpicture = splitmsg[3]
				   messagedate = splitmsg[4]
				   comments = splitmsg[5]
				   test = splitmsg[6]
				   //alert(userid+" "+userpicture)
				   if (userpicture == "nophoto.jpg") {
					   document.getElementById("new_comment_picture").src = '/bilder/nophoto70x93.jpg'   
				   } else {
					   document.getElementById("new_comment_picture").src = '/bilder/medlemmar/'+userid+'/70x93/'+userpicture+''   
				   }
				  //document.getElementById("new_comment_username").innerHTML = username
				   document.getElementById("new_comment_userlink").href = '?p=user&id='+userid+''
				   document.getElementById("new_comment_userlink").innerHTML = username
				   document.getElementById("new_comment_picturelink").href = '?p=user&id='+userid+''
				   message = message.replace("ä","&auml;")
				   document.getElementById("new_comment_text").innerHTML = cleanmessage
				   document.getElementById("new_comment_date").innerHTML = "Idag "+ messagedate
				   $(this).delay(110,function(){
						$("#comment_sent_hide").fadeOut(300, function () {
							$("#comment_sent").fadeIn(300, function () {
								document.getElementById("comment_design_message").value = ''
								$("#new_comment").slideDown("slow")
							})
							if (comments == 1) {document.getElementById("comments_title").innerHTML = comments+' kommentar'} else {document.getElementById("comments_title").innerHTML = comments + ' kommentarer'}
						})
				   })
			   }
			})
			 
		})
		
	})
		   
})

}


function setVoteShow(id)
{
	document.getElementById("setVote"+id+"").style.display = ''
	document.getElementById("showVote"+id+"").style.display = 'none'
}

function setVoteHide(id)
{
	document.getElementById("setVote"+id+"").style.display = 'none'
	document.getElementById("showVote"+id+"").style.display = ''
}


function showVote(star,id)
{
	if (star==1)
	{
	document.getElementById("star2_"+id+"").src = '/bilder/votestardisable.gif';
	document.getElementById("star3_"+id+"").src = '/bilder/votestardisable.gif';
	document.getElementById("star4_"+id+"").src = '/bilder/votestardisable.gif';
	document.getElementById("star5_"+id+"").src = '/bilder/votestardisable.gif';
	}
	if (star==2)
	{
	document.getElementById("star3_"+id+"").src = '/bilder/votestardisable.gif';
	document.getElementById("star4_"+id+"").src = '/bilder/votestardisable.gif';
	document.getElementById("star5_"+id+"").src = '/bilder/votestardisable.gif';
	}
	if (star==3)
	{
	document.getElementById("star4_"+id+"").src = '/bilder/votestardisable.gif';
	document.getElementById("star5_"+id+"").src = '/bilder/votestardisable.gif';
	}
	if (star==4)
	{
	document.getElementById("star5_"+id+"").src = '/bilder/votestardisable.gif';
	}
	if (star==5)
	{
	document.getElementById("star1_"+id+"").src = '/bilder/votestar.gif';
	document.getElementById("star2_"+id+"").src = '/bilder/votestar.gif';
	document.getElementById("star3_"+id+"").src = '/bilder/votestar.gif';
	document.getElementById("star4_"+id+"").src = '/bilder/votestar.gif';
	document.getElementById("star5_"+id+"").src = '/bilder/votestar.gif';
	}
}

function clearVote(id)
{
	document.getElementById("star1_"+id+"").src = '/bilder/votestar.gif';
	document.getElementById("star2_"+id+"").src = '/bilder/votestar.gif';
	document.getElementById("star3_"+id+"").src = '/bilder/votestar.gif';
	document.getElementById("star4_"+id+"").src = '/bilder/votestar.gif';
	document.getElementById("star5_"+id+"").src = '/bilder/votestar.gif';
}


function roundToHalf(value) {
   var converted = parseFloat(value); // Make sure we have a number
   var decimal = (converted - parseInt(converted, 10));
   decimal = Math.round(decimal * 10);
   if (decimal == 5) { return (parseInt(converted, 10)+0.5); }
   if ( (decimal < 3) || (decimal > 7) ) {
      return Math.round(converted);
   } else {
      return (parseInt(converted, 10)+0.5);
   }
} 

function setVote(star,id)
{
	
$(document).ready(function() {


	 $.ajax({
	   type: "GET",
	   url: "/include/functions_site.asp",
	   data: "setVote="+id+"&star="+star+"",
	   success: function(msg){	
	 	
		
		var vts, newVoteNrs, newVote
		vts = msg.split("|")
		newVoteNrs = vts[0]
		newVote = vts[1]
		newVoteScore = vts[2]
		newVote = roundToHalf(newVote / newVoteNrs)
	 	document.getElementById("voteStatus"+id+"").innerHTML = "Tack för din röst!"
		
			document.getElementById("votes"+id+"").style.display = 'none'
			if (star==1) 
			{
				document.getElementById("starDisabled2_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("starDisabled3_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("starDisabled4_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("starDisabled5_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("votesDisabled"+id+"").style.display = ''
			}
			if (star==2) 
			{
				document.getElementById("starDisabled3_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("starDisabled4_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("starDisabled5_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("votesDisabled"+id+"").style.display = ''
			}
			if (star==3) 
			{
				document.getElementById("starDisabled4_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("starDisabled5_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("votesDisabled"+id+"").style.display = ''
			}
			if (star==4) 
			{
				document.getElementById("starDisabled5_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("votesDisabled"+id+"").style.display = ''
			}
			if (star==5) 
			{
				document.getElementById("star1_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("star2_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("star3_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("star4_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("star5_"+id+"").src = '/bilder/votestardisable.gif';
				document.getElementById("votesDisabled"+id+"").style.display = ''
			}
			$("#votesDisabled"+id+"").fadeOut("medium", function () {
				$("#votesDisabled"+id+"").fadeIn("medium", function () {
					$(this).delay(3000,function(){
						document.getElementById("showVoteScore"+id+"").src = "/bilder/votes"+newVoteScore+".gif"
						document.getElementById("setVote"+id+"").style.display = 'none'
						document.getElementById("showVote"+id+"").style.display = ''
						document.getElementById("votes"+id+"").onmouseover = ''
						$("#votesDisabled"+id+"").fadeOut("medium", function () {
							$("#votes"+id+"").fadeIn("medium", function () {
	 						if (newVoteNrs==1) 
							{
								document.getElementById("voteStatus"+id+"").innerHTML = newVoteNrs+" röst"
							}
	 						else
							{
								document.getElementById("voteStatus"+id+"").innerHTML = newVoteNrs+" röster"
							}
	//						document.getElementById("showVoteScore"+id+"").onmouseover = 'alert(\'\')'
							})
						})
					})
				})
			})
	   }
	})
})
	
}

function deleteDesign(id)
{
	var answer=confirm("Denna design kommer att försvinna ur din portfölj och kommer ej att kunna fås tillbaka.\nÄr du säker du vill utföra denna åtgärd?")
	if(answer){
		window.location = "/?deletedesign="+id+""
	}
}

function chooseWinnerButton(id,name,bdid) {
	name = document.getElementById("thewinner").value
	var answer=confirm("Är det korrekt att du vill ange "+name+" som vinnare för tävlingen?")
	if(answer){
		checkWinner('',name,bdid)
	}

}


function contestusers(cid)
{
	
$(document).ready(function() {

	 $.ajax({
	   type: "GET",
	   url: "/include/functions_site.asp",
	   data: "contestusers="+cid+"",
	   success: function(msg){	
	   document.getElementById("contestusers").innerHTML = ""
	   var users = msg.split(",,"), userid, username, userid, userpicture, user
	   
			for (counter = 0; counter < users.length; counter++)
			{
				userid = users[counter].replace(",","")
			   $.ajax({
			   type: "GET",
			   url: "/include/functions_site.asp",
			   data: "contestusers="+cid+"&getuser="+userid+"",
			   success: function(msg){	
					user = msg.split("|")
					username = user[0]
					userid = user[1]
					userpicture = user[2]
					document.getElementById("contestusers").innerHTML = document.getElementById("contestusers").innerHTML + "<table width=\"72\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"contestUser\" style=\"margin-bottom:0px;margin-right:0px\"><tr><td width=\"68\"><a href=\"/?p=user&amp;id="+userid+"\"><img src=\"/bilder/medlemmar/"+userid+"/70x93/"+userpicture+"\" width=\"70\" height=\"93\" style=\"padding:0px;margin-bottom:5px\" border=\"0\"/></a><br /><div style=\"text-align:center\"> <a href=\"/?p=user&amp;id="+userid+"\" style=\"text-align:center;font-size:11px\">"+username+"</a></div></td></tr><tr><td align=\"center\"></td></tr></table>"

			   }
			   })

			}
		if (document.getElementById("contestlink").innerHTML !== '(klicka för att dölja deltagarna)')
		{
			document.getElementById("contestlink").innerHTML = "(klicka för att dölja deltagarna)"
			$("#contestusers_wrapper").fadeIn(1000)
			}
		else
		{
			document.getElementById("contestlink").innerHTML = "(klicka för att visa deltagarna)"
			$("#contestusers_wrapper").slideUp(1000)
			
			
			}
//		document.getElementById("contestlink").innerHTML = "(klicka för att dölja deltagarna)"
		
		
		}
	
	})
})

}

function chooseWinner(id,name,bdid)
{
	if (id!=='') { document.getElementById("thewinner").value = name } else { name = document.getElementById("thewinner").value }

	if (name.length == 0)
	{
		alert('Du måste ange en vinnare')
		document.getElementById('thewinner').focus();
	}
	else
	{
		var answer=confirm("Är det korrekt att du vill ange "+name+" som vinnare för tävlingen?")
		if(answer){
			checkWinner(id,name,bdid)
		}
	}
}

function pickWinner(name,id)
{
	document.getElementById("thewinner").value = name
}


function checkWinner(id,name,bdid) {
	
$(document).ready(function() {

	 $.ajax({
	   type: "GET",

	   url: "/include/functions_site.asp",
	   data: "check=winner&wid="+id+"&wname="+name+"&bid="+bdid+"",
	   success: function(msg){	
		 if(msg.length == '0') {
			 alert("Det finns ingen deltagare med användarnamnet \""+document.getElementById("thewinner").value+"\" anmäld till denna tävling. Är du säker du stavat rätt?")
			 document.getElementById('thewinner').focus();
			 return false
			 }
		 setWinner(id,name,bdid)
	   }
	})
})

}


function setWinner(id,name,bdid) {

$(document).ready(function() {

	var winnerid, winnername, winnerpicture
	
	winnerid = id
	winnername = name
	blogdesignid = bdid
	
	 $.ajax({
	   type: "GET",
	   url: "/include/functions_site.asp",
	   data: "set=winner&wname="+winnername+"&bid="+blogdesignid+"",
	   success: function(msg){	

	   var theData = msg.split("|")
	   winnername = theData[0]
	   winnerid = theData[1]
	   winnerpicture = theData[2]
	   winneremail = theData[3]
		$(".winnerLink").attr({ href: "/?p=user&id="+winnerid+"" });
		$("#winnerPicture").attr({ src: "/bilder/medlemmar/"+winnerid+"/70x93/"+winnerpicture+"" });
		$("#winnerName").text(winnername);
		$("#chooseWinner").fadeOut(500, function () {
		$("#pickedWinnerAlt").fadeIn(500, function () {
		$("#winner_email_text").text(winneremail);
		$("#winner_email_link").attr({ href: "/?p=user&id="+winnerid+""});
		$("#winner_email").slideDown(800)		
		
		});	
	});
	   }
	})
})

}

function signupContest(id,bid,uid)
{
//var stopIt
$(document).ready(function() {

 $.ajax({
   type: "GET",
   url: "/include/functions_site.asp",
  data: "set=contest&check=status&cid="+id+"",
   success: function(msg){

	if (msg=="endIt") {
		alert("Denna tävling har avslutats.")	
		window.location = "/?p=blogdesign"
		stopIt = true
	}
	else
	{

		stopIt = false
		$.ajax({
   type: "GET",
   url: "/include/functions_site.asp",
   data: "set=contest&addUser="+uid+"&cid="+id+"",
   success: function(msg){
	$("#signupContestDiv").fadeOut(1000, function () {
     $("#signupContestDivTrue").fadeIn(1000, function () {
		//window.location = "#contest"
	   document.getElementById("usersNr").innerHTML = ""
	   document.getElementById("usersNrNew").innerHTML = msg+" st"
			
			
		 });
      });
   }
 });
	}
   }
 });

   
   
});
}

function sendPayment(id, image)
{
	designid = id
	document.getElementById('paymentImage').src = "../designer/"+id+"/screenshotsmall_"+image+"";
	document.getElementById('paymentNumber').innerHTML = id
	$(document).ready(function() {
		$("#writePayment").slideDown(300, function () {
		window.location = "#top";
		document.getElementById("message").focus();
		})
	})

}

function checkSendPayment(id)
{
	var message = document.getElementById("message").value

	if (message == '')
	{
		alert('Du måste ange en betalningsbeskrivning.')
		document.getElementById("message").focus()
		return false;
	}

		
	$(document).ready(function() {
		var answer = confirm('Är denna betalningsinformation korrekt? Detta meddelade går ej ändra efter det är skickat.');
		if (answer) {
			$("#writePaymentWait").fadeIn(300);
			document.getElementById('writePaymentButton').disabled = true;
			
			
$.ajax({
	type: "GET",
	url: "http://bloggdesign.nu/include/functions_site.asp",
	data: "writepayment="+designid+"&message="+message+"",
	success: function(msg){

		$(this).delay(1000,function(){
			$("#writePayment").slideUp(300, function () {
			document.getElementById('writePaymentButton').disabled = false;
			document.getElementById('writePaymentWait').style.display = 'none'
			document.getElementById('message').value = ''
				$("#writePayedDiv"+designid+"").fadeOut(500, function () {
					$("#setPayedDiv"+designid+"Tmp").fadeIn(500)
				})
			})
		})
	}
});
		
		}

	})
}



function markPayed_design_view(id)
{
		var answer = confirm ("Vill du markera denna design som betald?")
		if (answer)
		{
$(document).ready(function() {
								
								
	$("#setPayed").slideUp(1500, function () {
											   
			var xmlHttp;
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
			{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
		  catch (e)
			{
			try
			  {
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			catch (e)
			  {
			  alert("Du använder en väldigt gammal eller ovanlig webbläsare vilken gör att vissa funktioner på denna webbsida ej kommer att kunna köras.");
			  return false;
			  }
			}
		  }
			xmlHttp.onreadystatechange=function()
			{
			if(xmlHttp.readyState==1)
			  {
				//alert('börja')
			  }
			if(xmlHttp.readyState==4)
			  {
	

			  }
	  
   			}
	
			var url = "/include/functions_site.asp?markPayed="+id
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);	
		})

});					   
	//window.location = '?markPayed='+id
		}
		else
		{

		}
}


function markPayed(id)
{
		var answer = confirm ("Vill du markera denna design som betald?")
		if (answer)
		{
$(document).ready(function() {
								
								
	$("#setPayedButton"+id+"").fadeOut(300, function () {
		$("#setPayedComplete"+id+"").fadeIn(300, function () {												   
			var xmlHttp;
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xmlHttp=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
			{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
		  catch (e)
			{
			try
			  {
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			catch (e)
			  {
			  alert("Du använder en väldigt gammal eller ovanlig webbläsare vilken gör att vissa funktioner på denna webbsida ej kommer att kunna köras.");
			  return false;
			  }
			}
		  }
			xmlHttp.onreadystatechange=function()
			{
			if(xmlHttp.readyState==1)
			  {
				//alert('börja')
			  }
			if(xmlHttp.readyState==4)
			  {
				  $("#setPayedWait"+id+"").fadeOut(300, function () {
				  	$("#setPayedDone"+id+"").fadeIn(300, function () {
						$(this).delay(2000,function(){ $("#setPayedDone"+id+"").fadeOut(1000) })
					})
				  })
			  }
	  
   			}
	
			var url = "/include/functions_site.asp?markPayed="+id
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);	
		})
	})

});					   
	//window.location = '?markPayed='+id
		}
		else
		{

		}
}



function acceptUploadRules()
{

	if (document.getElementById('rules').checked = "false")
	{
		document.getElementById('rules').checked = "true"
	}
	
	if (document.getElementById('rules').checked = "true")
	{
		document.getElementById('rules').checked = "false"
	}
}

function checkContest()
{
	if (document.formcontest.contestMoment1.value == '')
	{
		alert('Tävlingen måste minst innehålla ett tävlingsmoment.');
		document.formcontest.contestMoment1.focus()
		return false
	}
}


function checkDesignAlt()
{
	var radio_choice = false;

	
	for (counter = 0; counter < document.formalt.needmodify.length; counter++)
	{
		if (document.formalt.needmodify[counter].checked)
		radio_choice = true; 
	}
	
	if (!radio_choice)
	{
		alert("Du måste ange ett alternativ")
		return (false);
	}

}


function checkDownloadDesign(id)
	{
		var answer = confirm ("Vill du spara denna design i din portfölj?")
		if (answer)
		{
	window.location = '?download=design&id='+id
	//window.location = '?do=buyDesign&id='+id;
		}
		else
		{

		}
	}
	


function checkBuyDesign(price,id)
	{
		var answer = confirm ("Är du säker du vill köpa denna design för "+price+"kr? Alla köp är bindande.")
		if (answer)
		{
//window.location = '?p=blogdesign&do=buydesign&bought='+id
	window.location = '?do=buyDesign&id='+id;
		}
		else
		{

		}
	}


function checkcss()
{
	if (document.formcss.css.value == "")
	{
		alert('Du måste bifoga koden ur designens stilmall innan du kan fortsätta.');
		document.formcss.css.focus()
		return false;
	}
	checkCodeCSS();
}

function checkUploadCode()
{
	
	if (document.formCode.frontpage.value == "")
	{
		alert('Frontpage saknar kod');
		document.formCode.frontpage.focus()
		return false;
	}
	if (document.formCode.entrypage.value == "")
	{
		alert('Entrypage saknar kod');
		document.formCode.entrypage.focus();
		return false;
	}
	if (document.formCode.categorypage.value == "")
	{
		alert('Categorypage saknar kod');
		document.formCode.categorypage.focus();
		return false;
	}
	if (document.formCode.archivepage.value == "")
	{
		alert('Archivepage saknar kod');
		document.formCode.archivepage.focus();
		return false;
	}
	
	checkCodeA();
//	alert(foundFiles)
	//return false;
	
	//window.location = '/?p=myportfolio&do=upload&uploadstep=3'	
}
function checkUploadRules() {

			if (document.getElementById("rules").checked != true)
				{
				alert("Du måste godkänna dem allmänna villkoren");
				return false;		
				}
			else
			{
				window.location = '/?p=myportfolio&do=upload&uploadstep=1a';
			}
}

function checkScreenshot()
	{
			if (document.getElementById("file").value  == "")
				{
				alert("Du måste ange en visningsbild.");
				return false;		
				}
			else
			{
			document.getElementById("waitDivScreenshot").style.display = '';
			document.getElementById("buttonScreenshot").disabled = true;
			}
	}

function checkScreenshot2()
	{
			document.getElementById("formUploadImages").action = "/include/upload/design.aspx?do="+document.getElementById("file").text
			alert(document.getElementById("formUploadImages").action)
	}
	
	
function addContestLine()
{
$('<tr><td width="67" style=\"padding-top:5px;padding-bottom:5px\">'+myVar+'.</td><td width="633" style=\"padding-top:5px;padding-bottom:5px\"><input name="contestMoment'+myVar+'" type="text" class="contestRule" onclick="contestRow = this.id" id="contestMoment'+myVar+'"/></td></tr>').appendTo('#contestLines'); 
document.getElementById("contestMoment"+myVar+"").focus()
contestRow = "contestMoment"+myVar;
document.getElementById("formcontest").action = "/?p=myportfolio&do=upload&uploadstep=4c&contestLines="+myVar+""
myVar = myVar + 1;
}


function checkPersonalForm()
{
	 if (document.getElementById("contestMoment1").value == "" ) {
		 alert("Du måste minst ange en personlig del. Om designen inte är personlig klickar du på \"Tilbaka\"")
		document.getElementById("contestMoment1").focus()
		 return false
	 }
}

function addPersonalImage(id)
{
	imageVar = id
	$("#personalImageAdd"+imageVar+"").fadeOut(500, function () {
		$("#personalImageDiv"+imageVar+"").fadeIn(500, function () {
		})
	})


}


function addPersonalImageFile()
{

$(document).ready(function() {
	$("#personalImageChoose"+imageVar+"").fadeOut(500, function () {
		$("#personalImageAddWait"+imageVar+"").fadeIn(500, function () {
			$(this).delay(10,function (){

var formname = "formPersonal"+imageVar

document.getElementById(formname).action = document.getElementById(formname).action + "?id=" + imageVar

//document.formPersonal1.submit();
document.getElementById("formPersonal"+imageVar+"").submit();

//	 $.ajax({
//	   type: "GET",
//	   url: "/include/functions_site.asp",
//	   data: "addPersonalImage=",
//	   success: function(msg){	
//	   alert('easd');
//	   }
//	})									

			})
		})
	})

})

}

function showImage()
{

}

function addPersonalLine()
{

$('<tr><td width="67" style=\"padding-top:5px;padding-bottom:5px\">'+myVar+'.</td><td width="633" style=\"padding-top:5px;padding-bottom:5px\"><input name="contestMoment'+myVar+'" type="text" class="contestRule" onclick="contestRow = this.id" id="contestMoment'+myVar+'"/></td></tr><td width=\"3%\" style=\"padding-top:5px;padding-bottom:5px\"></td><td width=\"97%\" style=\"padding-top:5px;padding-bottom:0x;height:5px\"></td></tr>').appendTo('#contestLines'); 
document.getElementById("contestMoment"+myVar+"").focus()
contestRow = "contestMoment"+myVar;
//document.getElementById("formPersonal").action = "/?p=myportfolio&do=upload&uploadstep=4aa&personalLines="+myVar+""
myVar = myVar + 1;
}

function addContestLink()
{


  var myWidth = 0, myHeight = 0, myScroll = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
	window.scrollMaxY
  } 
  else if( document.documentElement && 
  	( document.documentElement.clientWidth ||
  	  document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
	//myScroll = document.documentElement.scroll
  } 
  else if( document.body && 
  	( document.body.clientWidth || 
  	  document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
	myScroll = document.body.scrollHeight
  }
  
var answer=prompt("Ange adress","http://")
if(answer){
document.getElementById(contestRow).focus();
document.getElementById(contestRow).value = document.getElementById(contestRow).value + "[url]" + answer + "[/url] "
}
//document.getElementById('fat').style.display = '';
//document.getElementById("fat").style.width = myWidth+"px"
//document.getElementById("fat").style.height = myScroll + myHeight+"px"
//
//document.getElementById('fat2').style.display = '';
//document.getElementById('fat2').style.width = "480px"
//document.getElementById('fat2').style.height = "25px"
//document.getElementById('fat2').style.left = myWidth/2-350+"px"
//document.getElementById('fat2').style.top = myHeight/2-80+"px"
//
//document.getElementById("contestLink").focus();
//document.getElementById("contestLink").value = 'http://'
//	alert(document.getElementById("fat").style.display)
}

function putContestLink()
{
	document.getElementById('fat').style.display = 'none';
	document.getElementById('fat2').style.display = 'none';
	document.getElementById(contestRow).value = document.getElementById(contestRow).value + '[url]' + document.getElementById('contestLink').value + '[/url] '
	document.getElementById(contestRow).focus();
}

function exitContestLink()
{
	var answer=prompt("please enter your name")
if(answer=="ncthakur"){
window.location="js04.htm"
}
	//document.getElementById('fat').style.display = 'none';
	//document.getElementById('fat2').style.display = 'none';
	//document.getElementById(contestRow).focus();
}

function addContestLinkBlogg()
{
	
	document.getElementById(contestRow).value = document.getElementById(contestRow).value + '[url]' + theUsername + '[/url] '
	document.getElementById(contestRow).focus()
}

function showCode3(thefile)
{
	getFile('/artikelkoder/'+thefile+'.html');
}

function showCode(thefile,folder)
{
	getFile('/artiklar/'+folder+'/'+thefile+'.html');
}

function updateCode()
{
	document.getElementById("codeResult3").innerHTML = document.getElementById("codeExample").value
}

function getFile(pURL) {
   if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
      xmlhttp=new XMLHttpRequest();
      xmlhttp.onreadystatechange=postFileReady;
      xmlhttp.open("GET", pURL, true);
      xmlhttp.send(null);
   } else if (window.ActiveXObject) { //IE 
      xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
      if (xmlhttp) {
         xmlhttp.onreadystatechange=postFileReady;
         xmlhttp.open('GET', pURL, true);
         xmlhttp.send();
      }
   }
}

// function to handle asynchronous call
function postFileReady() {
   if (xmlhttp.readyState==4) { 
      if (xmlhttp.status==200) { 
         //document.getElementById('codeResult').innerHTML=xmlhttp.responseText;
		 //var texta
 		 texta = xmlhttp.responseText.replace(/</g,"&lt;")
		 texta = texta.replace(/>/g,"&gt;")
		// texta = texta.replace("&lt;style&gt;","<span style=\"color:#CE3ABC\">&lt;style&gt;</span>")
		 //texta = texta.replace("&lt;\/style&gt;","<span style=\"color:#CE3ABC\">&lt;/\style&gt;</span>")
		 texta = texta.replace(/\r\n|\r|\n/g,"<br/>")
		 document.getElementById("codeExample").innerHTML = texta;
      }
   }
}


function checkReply()
	{
		if (document.formMessageReply.messageReply.value.length < 3)
			{
				alert('Ditt svar måste minns innehålla 3 tecken.');
				document.formMessageReply.messageReply.focus();
				return false
			}
	}
	
function messageDelete()
	{
		var answer = confirm ("Är du säker du vill radera de markerade meddelanden?")
		if (answer)
		{
	document.getElementById("formEditMessage").action = '?delete=message';
	document.getElementById("formEditMessage").submit();
		}
		else
		{

		}
	}
	
	
	
	
function checkUploadDescription()
{
	




var radio_choice = false;


for (counter = 0; counter < document.formUploadDescription.platform.length; counter++)
{
	if (document.formUploadDescription.platform[counter].checked)
	radio_choice = true; 
}

if (!radio_choice)
{
	alert("Du måste ange en plattform")
	return (false);
}



radio_choice = false;


for (counter = 0; counter < document.formUploadDescription.sellfor.length; counter++)
{
	if (document.formUploadDescription.sellfor[counter].checked)
	radio_choice = true; 
}

	if (document.formUploadDescription.sellfor[2].checked) {
		
		if (document.getElementById("sellforPrice").value == "") {
			alert("Du måste ange ett pris om du har tänkt sälja designen.");
			document.getElementById("sellforPrice").focus();
			return false;
		}
	}
	
if (!radio_choice)
{
	alert("Du måste ange ett prisalternativ")
	return (false);
}



	document.formUploadDescription.submit();
}




function getfromBD()
{
	document.getElementById('blogRow').style.display='none'
	document.getElementById('blogRow2').style.display='none'
	document.getElementById('blogRow3').style.display='none'
}

function getfromBlog()
{
	document.getElementById('blogRow').style.display=''
	document.getElementById('blogRow2').style.display=''
	document.getElementById('blogRow3').style.display=''
}

function uploadBlogdesign()
{
	if (document.getElementById("attach1").value != '')
	{
	document.getElementById("formUpload").action = 'include/uploadBlogdesignScreenshot.asp';
	document.getElementById("formUpload").submit();
	}
}

function checkBloggTV()
{
			if (document.formBloggTV.writeBloggTV.value.length <= 1)
				{
				  alert("Du måst ange ett meddelande.");
				  document.getElementById("writeBloggTV").focus();
				  return false
				}
				document.getElementById("formBloggTV").submit();
}

function countLetters(e)
	{
	if (e.keyCode) k =e.keyCode;
	else if (e) k = e.which;
		if(k != 8 && k != 0 && k != 13 && k != 125)
		{
					
		var thelengd = document.getElementById("writeBloggTV").value.length;
		var lengleft = 91 - thelengd;
		
			if(lengleft < 1)
			{
				document.getElementById("writeBloggTV").value.slice(0,90)
				return false;
			}
			else
			{
				document.getElementById("lettersDiv").innerHTML = 90 - thelengd;
				if(lengleft == 1) lengleft = '0';
				else lengleft = lengleft-1;
				return true;
				
			}
		}
		else
		{
	
			return true;

		}
	}


function forcelogout()
{
	//alert('Du har varit inaktiv i 20 minuter och kommer nu loggas ut.');
	window.location = '?do=logout';
}

function checkAnswer()
	{
			if (document.formAnswer.theAnswer.value.length <= 5 || document.formAnswer.theAnswer.value == 'Skriv ditt svar här...')
				{
				  alert("Ditt svar måste minns vara 5 bokstäver långt.");
				  document.getElementById("theAnswer").focus();
				  return false
				}
				document.getElementById("formAnswer").submit();
	}

function checkPoll()
{
var i=0;
for (i=0;i<=10;i++)
{
	try {
		var opt = document.formPoll.pollOpt[i].checked
		if(opt == true)
		{
			document.getElementById("formPoll").submit();
		}
	}
	catch(err)
	{
		return false
	}
}


}
	
function savePicture()
{
	document.getElementById("formpicture").action = '?save=picture';
	document.getElementById("formpicture").submit();
}


function updatePicture()
{
	if (document.getElementById("attach1").value != '')
	{
	document.getElementById("waitUpload").style.display = '';
	document.getElementById("nowaitUpload").style.display = 'none';
	document.getElementById("formpicture").action = 'include/upload/portrait.asp';
	document.getElementById("formpicture").submit();
	}
}

function checkNewPost()
	{
		if (document.formNewPost.newPostMessage.value.length < 4)
			{
				alert('Ditt svar måste minns innehålla 3 tecken.');
				document.formNewPost.newPostMessage.focus();
				return false
			}
	}

function checkNewTopic()
	{
		if (document.formNewTopic.newtopictitel.value.length < 4)
			{
				alert('Din rubrik är för kort för att kunna sparas.');
				document.formNewTopic.newtopictitel.focus();
				return false
			}
		if (document.getElementById("newtopictext").value.length < 10)
			{
				alert('Du måste skriva ett längre meddelande för att kunna spara tråden.');
				document.formNewTopic.newtopictext.focus();
				return false
			}
	}
function settingscheck()
	{
		if (document.formaccount.newpassword.value != "")
		{
			if (document.formaccount.newpasswordvalidate.value != document.formaccount.newpassword.value )
				{
					alert('Verifieringen av ditt nya lösenord misslyckades.');
					document.formaccount.newpasswordvalidate.select();
					return false;
				}
		}
		if (document.formaccount.oldpassword.value != "" && document.formaccount.newpassword.value == "")
			{
				alert('Fältet för ditt lösenord är inte tomt, vill du byta lösenord? Ange i detta fall ditt nuvarande lösenord samt det nya lösenordet du vill börja använda och en verifiering av detta.');
				document.formaccount.oldpassword.select();
				return false;
			}
			//document.getElementById("formaccount").enctype = '';
			//alert(document.getElementById("formaccount").enctype);
			document.getElementById("formaccount").submit()
	}
function checkPassword()
	{
		  if (document.formGetPassword.getPassword.value.length <= 5 || document.formGetPassword.getPassword.value == "")
			  {
				  alert("Du måste ange din E-postadres");
				  document.getElementById("getPassword").focus();
				  return false;
			  }
			  else
			  {
				  email = document.formGetPassword.getPassword.value
				  AtPos = email.indexOf("@")
				  StopPos = email.lastIndexOf(".")
				  Message = ""
				  
				  if (email == "") {
				  alert("Du angav inte en korrekt E-postadress");
				  document.getElementById("getPassword").focus();
				  return false;
				  }
				  
				  if (AtPos == -1 || StopPos == -1) {
				  alert("Du angav inte en korrekt E-postadress");
				  document.getElementById("getPassword").focus();
				  return false;
				  }
				  
				  if (StopPos < AtPos) {
				  alert("Du angav inte en korrekt E-postadress");
				  document.getElementById("getPassword").focus();
				  return false;
				  }
				  
				  if (StopPos - AtPos == 1) {
				  alert("Du angav inte en korrekt E-postadress");
				  document.getElementById("getPassword").focus();
				  return false;
				  }
			  }
	}
function doRate(id)
{
	document.getElementById("ratingNone"+id).style.display = 'none';
	document.getElementById("ratingLeave"+id).style.display = '';
}


function confirmBuy(id,price,unique)
	{
		var answer = confirm ("Vill du köpa denna bloggdesign ej unik för "+price+"kronor? Kom ihåg att alla köp är bindande!")
		if (answer)
		{
			window.location = '?do=buyDesign&id='+id;
		}
		else
		{
		}
	}
	
function confirmBuyUnique(id,price)
	{
		var answer = confirm ("Vill du köpa denna bloggdesign unik för "+price+"kronor? Kom ihåg att alla köp är bindande!")
		if (answer)
		{
			window.location = '?do=buyDesign&unique=yes&id='+id;
		}
		else
		{
		}
	}
	
function checkDeleteDesign(id)
	{
		var answer = confirm ("Är du säker du vill ta bort denna blogdesign? Denna åtgärd går inte att ångra!")
		if (answer)
		{
			window.location = '?do=deleteDesign&id='+id;
		}
		else
		{
		}
	}
	
function sendThumb()
	{
		document.getElementById('plsWait').innerHTML = "Var god vänta! <br/>Bilden laddas upp!";
		document.forms[1].action = "/include/uploadtester.asp?save=thumb";
		//document.forms[1}.enctype = "multipart/form-data";
		document.forms[1].submit();
	}

function stopWatch(id)
	{
		var answer = confirm ("Är du säker du vill sluta bevaka denna tråd? ")
		if (answer)
		{
			window.location = '?do=stopWatch&id='+id;
		}
		else
		{
		}
	}
	
	function markFriend(friend)
	{
		//alert(friend);
		document.getElementById("to").value = document.getElementById('friends').value
		//document.getElementById("to").disabled = true;
	}

function messageMarkRead()
	{
		document.forms[0].action = "?message=markRead";
		document.forms[0].submit();

	}

function messageDeleteOut()
	{
		var answer = confirm ("Är du säker du vill radera de markerade meddelanden?")
		if (answer)
		{
			document.forms[0].action = "?message=deleteOut"
			document.forms[0].submit()
		}
		else
		{
		}
	}
	
function writeComment()
	{
		window.location = '#writecomment';
		document.getElementById("comment").focus();
	}

function writeCommentGuest()
	{
		window.location = '#writecomment';
	}
	
function checkMessageReply()
	{
			if (document.formMessageReply.message.value.length <= 2)
				{
				  alert("Du får nog ta och skriva lite mer än sådär om du vill skicka iväg ett meddelande.");
				  document.getElementById("message").focus();
				  return false
				}
	}

function checkMessage()
	{
		  if (document.formWriteMessage.sendto.value.length <= 2)
			  {
				  alert("Du måste ange en användare att skicka till.");
				  document.getElementById("sendto").focus();
				  return false
			  }
		  if (document.formWriteMessage.sendtoTitel.value.length <= 2)
			  {
				  alert("Du måste skriva en titel på minst tre bokstäver.");
				  document.getElementById("sendtoTitel").focus();
				  return false
			  }
			if (document.formWriteMessage.writemessage.value.length <= 2)
				{
				  alert("Ditt meddelande får inte vara kortare än tre bokstäver.");
				  document.getElementById("writemessage").focus();
				  return false
				}
	}
	
function checkContact()
	{
		  if (document.formContact.email.value.length <= 5 || document.formContact.email.value == "")
			  {
				  alert("Du måste ange din E-postadres");
				  document.getElementById("email").focus();
				  return false;
			  }
			  else
			  {
				  email = document.formContact.email.value
				  AtPos = email.indexOf("@")
				  StopPos = email.lastIndexOf(".")
				  Message = ""
				  
				  if (email == "") {
				  alert("Du angav inte en korrekt E-postadress");
				  document.getElementById("email").focus();
				  return false;
				  }
				  
				  if (AtPos == -1 || StopPos == -1) {
				  alert("Du angav inte en korrekt E-postadress");
				  document.getElementById("email").focus();
				  return false;
				  }
				  
				  if (StopPos < AtPos) {
				  alert("Du angav inte en korrekt E-postadress");
				  document.getElementById("email").focus();
				  return false;
				  }
				  
				  if (StopPos - AtPos == 1) {
				  alert("Du angav inte en korrekt E-postadress");
				  document.getElementById("email").focus();
				  return false;
				  }
			  }
			if (document.formContact.message.value == "" || document.formContact.message.value.length <= 10)
				{
				  alert("Du får nog ta och skriva lite mer än sådär om du vill skicka iväg ett meddelande");
				  document.getElementById("message").focus();
				  return false;	
				}
	}

function checkComment()
	{		
			if (document.formComment.username.value.length <= 2 || document.formComment.username.value == "Namn *")
				{
				alert("Du måste ange ditt namn");
				document.getElementById("username").focus();
				return false;
				}
			if (document.formComment.email.value.length <= 5 || document.formComment.email.value == "E-post *")
				{
					alert("Du måste ange din E-postadress (Den kommer inte att visas för andra besökare på sidan)");
					document.getElementById("email").focus();
					return false;
				}
				else
				{
					email = document.formComment.email.value
					AtPos = email.indexOf("@")
					StopPos = email.lastIndexOf(".")
					Message = ""
					
					if (email == "") {
					alert("Du angav inte en korrekt E-postadress");
					document.getElementById("email").focus();
					return false;
					}
					
					if (AtPos == -1 || StopPos == -1) {
					alert("Du angav inte en korrekt E-postadress");
					document.getElementById("email").focus();
					return false;
					}
					
					if (StopPos < AtPos) {
					alert("Du angav inte en korrekt E-postadress");
					document.getElementById("email").focus();
					return false;
					}
					
					if (StopPos - AtPos == 1) {
					alert("Du angav inte en korrekt E-postadress");
					document.getElementById("email").focus();
					return false;
					}
				}
			if (document.formComment.comment.value == "" || document.formComment.comment.value.length <= 5 || document.formComment.comment.value == "Kommentera här...")
				{
				  alert("Du får nog ta och skriva lite mer än sådär om du vill skriva en kommentar");
				  document.getElementById("comment").focus();
				  return false;	
				}
	}
	
function checkSignUp()
	{		
	form = document.formSignUp
	
			if (form.username.value.length <= 2)
				{
				alert("Du måste välja en användarnamn som innehåller minst 3 bokstäver");
				document.getElementById("ajax_username").style.display = "none"
				document.getElementById("approve_username").style.display = "none"
				document.getElementById("disapprove_username").style.display = "block"
				document.getElementById("username").focus();
				return false;
				}
			if (form.email.value.length <= 5)
				{
					document.getElementById("ajax_email").style.display = "none"
					document.getElementById("approve_email").style.display = "none"
					document.getElementById("disapprove_email").style.display = "block"
					alert("Du måste ange din E-postadress (Den kommer inte att visas för andra besökare på sidan)");
					document.getElementById("email").focus();
					return false;
				}
				else
				{
					email = form.email.value
					AtPos = email.indexOf("@")
					StopPos = email.lastIndexOf(".")
					Message = ""
					
					if (email == "") {
					document.getElementById("ajax_email").style.display = "none"
					document.getElementById("approve_email").style.display = "none"
					document.getElementById("disapprove_email").style.display = "block"
					alert("Du angav inte en korrekt E-postadress");
					document.getElementById("email").focus();
					return false;
					}
					
					if (AtPos == -1 || StopPos == -1) {
					document.getElementById("ajax_email").style.display = "none"
					document.getElementById("approve_email").style.display = "none"
					document.getElementById("disapprove_email").style.display = "block"
					alert("Du angav inte en korrekt E-postadress");
					document.getElementById("email").focus();
					return false;
					}
					
					if (StopPos < AtPos) {
					document.getElementById("ajax_email").style.display = "none"
					document.getElementById("approve_email").style.display = "none"
					document.getElementById("disapprove_email").style.display = "block"
					alert("Du angav inte en korrekt E-postadress");
					document.getElementById("email").focus();
					return false;
					}
					
					if (StopPos - AtPos == 1) {
					document.getElementById("ajax_email").style.display = "none"
					document.getElementById("approve_email").style.display = "none"
					document.getElementById("disapprove_email").style.display = "block"
					alert("Du angav inte en korrekt E-postadress");
					document.getElementById("email").focus();
					return false;
					}
				}
			if (form.password.value.length < 4)
				{
				document.getElementById("ajax_password").style.display = "none"
				document.getElementById("approve_password").style.display = "none"
				document.getElementById("disapprove_password").style.display = "block"
				alert("Lösenordet måste minst innehålla minst 4 bokstäver");
				document.getElementById("password").focus();
				return false;
				}
			if (form.password.value == '')
				{
				document.getElementById("ajax_password").style.display = "none"
				document.getElementById("approve_password").style.display = "none"
				document.getElementById("disapprove_password").style.display = "block"
				alert("Du måste ange ett lösenord");
				document.getElementById("password").focus();
				return false;		
				}
				
			if (form.password.value !== form.passwordValidate.value & form.password.value !== '')
				{
				document.getElementById("ajax_passwordValidate").style.display = "none"
				document.getElementById("approve_passwordValidate").style.display = "none"
				document.getElementById("disapprove_passwordValidate").style.display = "block"
				alert("Ditt upprepade lösenord stämmer inte överens med lösenordet du angav");
				document.getElementById("passwordValidate").focus();
				return false;
				}
				
			if (form.rules.checked != true)
				{
				alert("Du måste godkänna reglerna");
				return false;		
				}

			document.getElementById("waitDiv").style.display = '';
			form.submit()
			
	}
	
function checkQuestion()
	{
				if (document.formNewThread.titel.value.length < 4 || document.formNewThread.titel.value == 'Rubrik...')
					{
					alert("Du måste ange en titel till din fråga");
					document.getElementById("titel").focus();
					return false;
					}
				if (document.formNewThread.description.value.length < 4 || document.formNewThread.description.value == 'Beskrivning...')
					{
					alert("Du måste ange en beskrivning till din fråga");
					document.getElementById("description").focus();
					return false;
					}
	}
	
function voteQuestion(id)
{
window.location ='?do=voteQuestion&id='+id
}