// JavaScript Document
// JavaScript Document


function showForm(id) {
		
		Element.replace('writeComment', '<br /><hr /><br /><span class="text">Skriv din kommentar:</span><form id="formKommentar" name="formKommentar" method="post" action="" onsubmit="saveNote(' + id + '); return false;"><table border="0"><tr><td width="20">Alias:</td><td><input type="text" name="nick" id="nick" value="" maxlength="20" width="30" /> (visas som avsÃ¤ndare)</td></tr><tr><td>E-post:</td><td><input type="text" name="epost" id="epost" value="" maxlength="50" width="50" /> (visas inte pÃ¥ sidan)</td></tr><tr><td colspan="2">Kommentar:<br /><textarea name="kommentarForm" id="kommentarForm" cols="45" rows="5" ></textarea></td><tr><td colspan="2"><table><tr><td><img src="/includes/CaptchaSecurityImages.php" width="100" height="40" /></td><td>Skriv in kod:<br /><input type="text" name="security_code" id="security_code" value="" maxlength="8" width="10" /></td></tr></table></td></tr><td colspan="2"><label><input type="submit" name="submit" id="submit" value="Skicka kommentar" /></label></td></tr></table></form>');
		
}
// id is competition id
function saveNote(id) {
		//var id_pic = 'fav_'+val+'';
		var url = 'http://www.argalappen.se/comments.php';
		//var params = 'q=' + id + '&note=' + cat + '&sid=' + Math.random();
		//alert(params); 
		var ajax = new Ajax.Updater('showComments', url, { 
									method: 'post', 
									parameters: { q: id, note: $F('kommentarForm'), epost: $F('epost'), nick: $F('nick'), sec: $F('security_code'), sid: Math.random() }, 
									onFailure: reportErrorNewsletter
									}
									);
}

// id is competition id
function saveVote(id, vote) {
		var id_pic = 'vote'+id+'';
		var url = '/votes.php';
		//var params = 'q=' + id + '&note=' + cat + '&sid=' + Math.random();
		//alert(params); 
		var ajax = new Ajax.Updater(id_pic, url, { 
									method: 'post', 
									parameters: { q: id, note: vote, sid: Math.random() }, 
									onFailure: reportErrorNewsletter
									}
									);
}


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


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;
}
