var klid;
function getXMLHTTPRequest() {
http=null
if (window.XMLHttpRequest)
{
req=new XMLHttpRequest()
}
else if (window.ActiveXObject)
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
req = null;
}
}
return req;
}
var http = getXMLHTTPRequest();
function ShowCommentFields(lid){
http.open("GET", "/includes/bloggfunktioner_ajax.asp?action=getCommentFields&lid=" + lid + "", true);
klid = lid;
http.onreadystatechange = ShowCommentFields_action;
http.send(null);
document.getElementById('comment_area'+klid).innerHTML = '
';
}
function ShowCommentFields_action() {
if (http.readyState==4 || http.readyState=='complete'){
document.getElementById('comment_area'+klid).innerHTML = http.responseText;
}
}
function ShowComments(lid){
http.open("GET", "/includes/bloggfunktioner_ajax.asp?action=getComments&lid=" + lid + "", true);
klid = lid;
http.onreadystatechange = ShowComments_action;
http.send(null);
document.getElementById('comment_area'+lid).innerHTML = '
';
}
function ShowComments_action() {
if (http.readyState==4 || http.readyState=='complete'){
document.getElementById('comment_area'+klid).innerHTML = http.responseText;
}
}
function CheckCommentCount() {
if(document.getElementById('comment_comment'+lid).value.length >= 1000) { document.getElementById('blogg_comment_counter').value = 'För många tecken!'; }
else { document.getElementById('blogg_comment_counter').value = '' + 1000 - 1 - document.getElementById('comment_comment').value.length + ' Tecken kvar'; }
}
function SendComment(){
if(document.getElementById('comment_comment').value.length >= 1000) { alert('test'); return false }
if(Echeck(document.getElementById('comment_epost').value) == true) {
if(document.getElementById('comment_namn').value == 'Namn...') { alert('Du måste fylla i ditt namn!'); return false }
if(document.getElementById('comment_namn').value == '') { alert('Du måste fylla i ditt namn!'); return false }
if(document.getElementById('comment_comment').value == 'Skriv kommentar här...') { alert('Du har inte skrivit någon kommentar!'); return false }
if(document.getElementById('comment_comment').value == '') { alert('Du har inte skrivit någon kommentar!'); return false }
http.open("GET", "/includes/bloggfunktioner_ajax.asp?action=saveComment&lid=" + klid + "&epost=" + escape(document.getElementById('comment_epost').value) + "&namn=" + escape(document.getElementById('comment_namn').value) + "&kommentar=" + escape(document.getElementById('comment_comment').value) , true);
http.onreadystatechange = SendComment_action;
http.send(null);
document.getElementById('comment_area'+klid).innerHTML = '
';
}
}
function SendComment_action() {
if (http.readyState==4 || http.readyState=='complete'){
document.getElementById('comment_area'+klid).innerHTML = http.responseText;
}
}
/**
* Detta är en e-post validator
*/
function Echeck_alert() { alert("Du har angett en felaktig E-postadress!") }
function Echeck(str) {
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){ Echeck_alert(); return false }
else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ Echeck_alert(); return false }
else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ Echeck_alert(); return false }
else if (str.indexOf(at,(lat+1))!=-1){ Echeck_alert(); return false }
else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ Echeck_alert(); return false }
else if (str.indexOf(dot,(lat+2))==-1){ Echeck_alert(); return false }
else if (str.indexOf(" ")!=-1){ alert("Du har angett en felaktig E-postadress!"); return false }
else { return true }
}