// JavaScript Document

// id = 1 for mark comp as deltagit
// id = 2 for unmark comp as deltagit
// id = 3 for mark as favorit
// id = 4 for unmark as favorit
// val is comp_id, cat is category
function markComp(val, id, cat) {
		//var cat = $F('cat');
		var id_pic = 'fav_'+val+'';
		var url = 'http://www.blienvinner.no/member_save_comp.php';
		var params = 'q=' + id + '&comp='+ val +'&kategori=' + cat + '&sid=' + Math.random();
		//alert(params);
		var ajax = new Ajax.Updater(id_pic, url,
									{method: 'get', parameters: params, onFailure: reportErrorNewsletter}
									);
}
// id is competition id
function saveNote(id) {
		//var id_pic = 'fav_'+val+'';
		var url = 'http://www.blienvinner.no/member_save_comments.php';
		//var params = 'q=' + id + '&note=' + cat + '&sid=' + Math.random();
		//alert(params);
		var ajax = new Ajax.Updater('comments', url, { 
									method: 'post', 
									parameters: { q: id, note: $F('kommentarForm'), sid: Math.random() }, 
									onFailure: reportErrorNewsletter
									}
									);
}


function reportErrorNewsletter(request) {
	alert('A request not completed'); 
}

function saveNoteMem(id, res) {
	//alert('Test ' + id);
	var name = 'note_' + id + '';
	var url = 'http://www.blienvinner.no/member_save_notes.php';
	var params = 'q=' + id + '&note=' + res + '&sid=' + Math.random();
		//alert(params);
	var ajax = new Ajax.Updater(name, url, 
								{method: 'get', parameters: params, onFailure: reportErrorNewsletter} 
								);	
}

function searchComp() {
	//var id_pic = 'fav_'+val+'';
		var url = 'http://www.blienvinner.no/sokExec.php';
		//var params = 'altString=' + $F('alternativ_sok') + '&findString=' + $F('hitta_sok') + '&sid=' + Math.random();
		//alert(params);
		var ajax = new Ajax.Updater('searchresult', url, { 
									method: 'post', 
									parameters: { altString: $F('alternativ_sok'), findString: $F('hitta_sok'), sid: Math.random() }, 
									onFailure: reportErrorNewsletter
									}
									);
}

function markField(test) {
	$(test).activate();	
}

function loadmediadivwithtimeout(id, res) {
	var v = 'saveNoteMem(' + id + ',' + res + ')';
	window.setTimeout(v, 30);
}

function felanmalan(a)
{
	var w = 450, h = 250;
	wleft = (screen.width - w) / 2;
  	wtop = (screen.height - h) / 2;
	
   	msg=window.open(a,"popup","height=250,width=450,left="+wleft+",top="+wtop+",scrollbars=yes,toolbar=no,directories=no,status=no,menubar=no,resizable=no");
}

function openwin(a)
{
	var w = 500, h = 350;
	wleft = (screen.width - w) / 2;
  	wtop = (screen.height - h) / 2;
	
   	msg=window.open(a,"popup","height=350,width=500,left="+wleft+",top="+wtop+",scrollbars=yes,toolbar=no,directories=no,status=no,menubar=no,resizable=no");
}

function opennote(a)
{
	var w = 500, h = 250;
	wleft = (screen.width - w) / 2;
  	wtop = (screen.height - h) / 2;
	
   	msg=window.open(a,"popup","height="+h+",width="+w+",left="+wleft+",top="+wtop+",scrollbars=yes,toolbar=no,directories=no,status=no,menubar=no,resizable=no");
}

<!-- facebook -->
function fbs_click() { 
u=location.href;
t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
return false;
}