﻿// validate the form
function checked()
{

for (var i=0; i<document.mainform.checkbox.length; i++)  { 
if (document.mainform.checkbox[i].checked)  {
$("img#showCheckboxes").attr("src","/images/selectedtags.gif");
} 
} 
$("#checkboxes").fadeOut("slow");
} 


// the string trim() function
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }

function IsValidDate(str, separator) {
    if(separator == null){
        separator = '-';
    }
    if( //separators   
        str.substring(2, 3) == separator 
        && str.substring(5, 6) == separator        
        // all numbers
        && IsNumeric(str.replace(separator, '').replace(separator, ''))
        // dd < 32
        && parseInt(str.substring(0, 2)) < 32
        // MM < 13
        && parseInt(str.substring(3, 5)) < 13
        // yyyy
        && parseInt(str.substring(6, 10)) > 1900 && parseInt(str.substring(6, 8)) < 21
        
    ){
        return true;
    }
    
    return false;
}

function ajaxSubmitContestCode(userid, itemid, code){
       $.ajax({
        type: "GET",
        url: document.location.pathname + '?p=3&action=validateContestCode&userid=' + userid + '&itemid=' + itemid + '&code=' + code,        
        dataType: "json",
        //data: "p=3&id=" + id + "&comment=" + encodeURI(reason),
        success: function(msg){
                    if(msg.error != ''){
                        alert(msg.error);
                        return;
                    }
                    $('div#step1').hide('slow');$('div#step2').show('slow');
                }
        });
}

// /Contest functions

function UpdateNewsBox(itemid, result){

$("#switcherHolder").fadeTo("slow", 0.66);
$("#switcherHolder").html(result); 
$("#switcherHolder").fadeTo("slow", 1);
   
   for(j = 0; j < newsIds.length; j++){
       var obj = document.getElementById('p'+newsIds[j]);          
       if(obj){
          if(newsIds[j] == itemid){
             obj.className = "linkSelected";
              
          }
          else{
             obj.className = "linkNormal";               
          }
       }
   }
}

function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}


function IsValidEmail(val){
    var rx = new RegExp("^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$");
    var matches = rx.exec(val);                     
    return (matches != null && val == matches[0]);
}

function addOnloadHandler(handler){
    if(handler == null){
       return;
    }
    try{
        if(window.attachEvent){        
            window.attachEvent("onload", handler);
        }
        else if(window.addEventListener){
            window.addEventListener("load", handler, true);
        }       
    }
    catch(err){
         alert(err);
    }
}

function corners(){
    if(!NiftyCheck())
    return;
   /*
    Rounded("div.leftBoxDark","#ffffff","#4b4949");
    Rounded("div.leftBoxDarkThin","#ffffff","#4b4949");
    Rounded("div.leftBoxLight","#ffffff","#6c6969");
    Rounded("div.leftBoxLighta","#ffffff","#6c6969");
    Rounded("div.leftBoxLighter","#ffffff","#d0cccc");
    Rounded("div.leftBoxBlack","#ffffff","#313131");
    Rounded("div.leftBoxOneline","#ffffff","#4b4949");
    Rounded("div.input","#6c6969","#ffffff","small");     
	*/
};
 
$(document).ready(function(){
    $(".hidden").hide();
    $(".leftBoxTagMiniHidden").hide();
    $("#bookmark").hide();
    $("#checkboxes").hide();
    $("#clickBook").click(function(){ $("#mainContent").find("#bookmark").fadeIn("slow"); });
    $("#hideBookmark").click(function(){ $("#mainContent").find("#bookmark").fadeOut("slow"); });
    $("#seeAll").click(function(){ $("#tagsSettings").find("div.leftBoxTagMiniHidden").fadeIn("slow"); });
    $("#seeAll").click(function(){ $("#tagsSettings").find("div.leftBoxTagMiniButton").hide("fast"); });
    $("#hideTagging").click(function(){ $("#tagsSettings").find("div.leftBoxTagMiniHidden").fadeOut("slow"); });
    $("#hideTagging").click(function(){ $("#tagsSettings").find("div.leftBoxTagMiniButton").show("fast"); });
    $("#starbar").click(function(){ $("#mainContent").find(".hidden").show("fast"); });
    $("input.buttonBslideup").click(function(){ $("div.leftBoxDark").find(".hidden").show("fast"); });
    $("#hiddenComment").hide();
    $("input#buttonComment").click(function(){ $("div.leftBoxDark").find("#hiddenComment").fadeIn("fast"); });
    $("input.buttonClose").click(function(){ $("div.leftBoxDark").find("#hiddenComment").hide("fast"); });
    $("#showCheckboxes").click(function(){ $("#checkboxes").fadeIn("slow"); });
    });


function updateMyVote(vote, itemId, elemId){
    $.ajax({
        type: "GET",
        url: "/?sc_itemid=" + itemId,
        dataType:"json",
        data: "p=3&action=updateVote&rating=" + vote,
        success: function(msg){ 
                    if(msg.error != ''){
                        alert(msg.error);
                        return;
                    }          
                    var obj = document.getElementById(elemId);
                    if(obj != null){
                        obj.style.width = (vote * 17) + "px";
                        alert('New rating saved, now average rating is: ' + msg.newRating);

                    } 
        
                }
        });    
}

function updateVote(vote, extraparam){
    
    $.ajax({
        type: "GET",
        url: document.location.pathname ,
        dataType:"json",
        data: "p=3&action=updateVote&rating=" + vote + ((extraparam != null && extraparam != '') ? '&' + extraparam : ''),
        success: function(msg){
                    UpdateVotes(msg, vote);                    
                }
        });
}

function voter (vote, extraparam) {    

    $.ajax({
        type: "GET",
        url: document.location.pathname,
        dataType:"json",
        data: "p=3&action=vote&rating=" + vote + ((extraparam != null && extraparam != '') ? '&' + extraparam : ''),
        success: function(msg){
                    UpdateVotes(msg,vote);                    
                }
        });
        //data: "p=3&action=vote&rating=" + vote + ((extraparam != null && extraparam != '') ? '&' + extraparam : ''),
}

function UpdateVotes(result, vote){

    if(result.error != ''){
        alert(result.error);
        return;
    }
    var obj = document.getElementById('starbarUser');    
    if(obj != null){
        obj.style.width = (vote*17) +'px';
    }    
    obj = document.getElementById('starbar');
    if(obj != null){
        obj.style.width = (result.newRating * 17) + "px";
    }
    SetInnerHtml('totalRatingValue', result.newRating);
    SetInnerHtml('yourRating', vote);

}

function SetInnerHtml(element, html){
    var obj = document.getElementById(element);    
    if(obj != null){
        obj.innerHTML = html;
    }
}

function reportOneline(){
    var obj = document.getElementById('txtReason');        
    var comment = (obj != null ? obj.value: '');
    if(comment == ''){
        return;
    }
    obj = document.getElementById('hiddReportedId');
    if(obj == null){
        return;
    }
    ajaxReportOneline(obj.value, comment);   
    setTimeout('$("div#postReport").hide("slow")',500);
}

function reportDebate(){
    var obj = document.getElementById('txtReason');        
    var comment = (obj != null ? obj.value: '');
    if(comment == ''){
        return;
    }
    obj = document.getElementById('hiddReportedId');
    if(obj == null){
        return;
    }
    ajaxReportDebate(obj.value, comment);    
    setTimeout('$("div#postReport").hide("slow")',500);
}

function hideInputReport(){
    setTimeout('$("div#postReport").hide("slow")',500);
}

function showLoginStatus(msg, relativeObj){
    var obj = document.getElementById(relativeObj);

    if(obj){
        var dim = new Dimension(obj);
        obj = document.getElementById('loginStatus');
        if(obj){
            //obj.style.left = (dim.x + 50) + "px";
            //obj.style.top = (dim.y + 150) + "px";
            obj.style.height = "auto";
        }
    }
    $("div#loginStatusText").html(msg);
    $("div#loginStatus").show("slow");
    //setTimeout(showLoginStatusHelper, 5000);  
}
function showLoginStatusHelper(){
      
}

function showInputReport(src, id){
    $("div#postReport").show("slow");
    var dim = new Dimension(src);
    obj = document.getElementById('postReport');
    if(obj){
        obj.style.left = (dim.x - 50) + "px";
        obj.style.top = (dim.y) + "px";    
    }
    obj = document.getElementById('hiddReportedId');
    if(obj){obj.value = id;}
}

function showInputForm(src, ptid, title){
      if (document.getElementById('pTitle') != 'undefined' && document.getElementById('pTitle')!=null)
      {                        
          //alert(document.getElementById('ptid').value);       
          var obj = document.getElementById('ptid').value = ptid;
          if(obj){
            obj.value = ptid;
          }
          obj = document.getElementById('pTitle');
          if(obj){
            obj.innerHTML = title;
          }
          
          var dim = new Dimension(src);
          obj = document.getElementById('postForm');
          if(obj){
            obj.style.left = (dim.x + 100) + "px";
            obj.style.top = (dim.y - 50) + "px";
          }
          //show('postForm');
          $("div#postForm").show("slow");
          obj = document.getElementById('txtTitle');
          if(obj != null && obj.focus){
            obj.focus();
          }  
      }
}

function hideInputForm(){
    setTimeout('$("div#postForm").hide("slow")',500);
}

function postComment(){
   var txtComment = document.getElementById('txtComment');
   var txtTitle = document.getElementById('txtTitle');
   var pid = document.getElementById('ptid');
   if(txtComment != null  && txtTitle != null && txtComment.value.trim() != '' && txtTitle.value.trim() != ''){
       ajaxPostComment(pid.value, txtTitle.value, txtComment.value);
   }
   else{
      alert('Titel og kommentar skal udfyldes!');
   }
}

function ajaxReportOneline(id, reason){

       $.ajax({
        type: "POST",
        url: document.location.pathname + '?p=3&action=reportOneline',
        dataType:"json",
        data: "p=3&id=" + id + "&comment=" + encodeURI(reason),
        success: function(msg){
                    if(msg.error != ''){
                        alert("Error: " + msg.error);
                        return;
                    }
                    MarkAsReported(id);
                }
        });
}

function ajaxReportDebate(id, reason){
       $.ajax({
        type: "POST",
        url: document.location.pathname + '?p=3&action=reportMessage',
        dataType:"json",
        data: "p=3&id=" + id + "&comment=" + encodeURI(reason),
        success: function(msg){
                    if(msg.error != ''){
                        alert("Error: " + msg.error);
                        return;
                    }
                    MarkAsReported(id);
                }
        });
}
function MarkAsReported(id){    
    var obj = document.getElementById('r' + id);
    if(obj){
        obj.style.color = "blue";
        obj.disabled = true;
    }
}

function ajaxPostComment(ptid, title, comment, emailNotify){   
    var parentid = '';
    var topicid = '';
    if(ptid != ''){
        parentid = ptid.substring(0,38);
        topicid = ptid.substring(38,76);
    }
   $.ajax({
        type: "POST",
        url: document.location.pathname + '?p=3&action=postComment',
        dataType:"html",
        data: "p=3&action=postComment&parentid=" + parentid + "&title=" + encodeURI(title) + "&comment=" + encodeURI(comment) + "&topicid=" + encodeURI(topicid) + "&emailNotify=" + (emailNotify ? "1" : "0"),
        success: function(msg){
                    UpdatePosts(msg, parentid);                    
                }
        });
}

function ajaxRateComment(commentId, rating){
   $.ajax({
        type: "POST",
        url: document.location.pathname + '?p=3&action=rateComment',
        dataType:"json",
        data: "commentId=" + commentId + "&rating=" + rating,
        success: function(msg){
                    if(msg.error != ""){
                        alert(msg.error);
                        return;
                    }
                    SetInnerHtml('R' + commentId, msg.newrating);                  
                }
        });    
}

function openPopUp(pUrl,w,h) {	
	var l= getWindowPosition("width")-(w/2);
	var t= getWindowPosition("height")-(h/2);
	window.open(pUrl, 'popUp', 'width='+w+',height='+h+',left='+l+',top='+t+',resizable=yes');
}

function getWindowPosition(dim){
  var myWidth = 0, myHeight = 0;
// a little check cos IE doens't support window innerWidth

  if(typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
 
    theTop = document.documentElement.scrollTop;
    theHeight = window.innerHeight/2;
  
	theLeft = document.documentElement.scrollLeft;
    theWidth  = window.innerWidth/2;
    
    myWidth = theLeft+theWidth;
    myHeight = theTop+theHeight;

  }
  else if( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight )) {
    //IE 6+ in 'standards compliant mode'
    theTop = document.documentElement.scrollTop;
    theHeight = document.documentElement.clientHeight/2;
  
	theLeft = document.documentElement.scrollLeft;
    theWidth  = document.documentElement.clientWidth/2;
       
    myWidth = theLeft+theWidth;
    myHeight = theHeight+theTop;

  } else if( document.body && (document.body.clientWidth || document.body.clientHeight )) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  if(dim == 'width'){
	return myWidth;
  }
  else{
	return myHeight;
  }

}

function clearField(name){
    var obj = document.getElementById(name);
    if(obj){
        obj.value = '';
    }
}
function showInline(name){
var el = document.getElementById(name);
    if(el){
      el.style.display = 'inline';
      el.style.visibility = 'visible';
    }
}
function show(name){
     var el = document.getElementById(name);
     if(el){
        el.style.visibility = 'visible';
        if(el.name != 'login$txtPassword')
        {
            el.style.display = 'inline';
        }
        else
        {
            el.style.display = 'inline';
        }
     }
}
function hide(name){
     var el = document.getElementById(name);
     if(el){
        el.style.visibility = 'hidden';
        el.style.display = 'none';
     }
}

function UpdatePosts(resultHtml, parentid){    
    // if it's level 0 topic
    if(parentid == ''){
        var parent = document.getElementById('topicsContainer');
        if(parent.innerHTML == ''){
            parent.innerHTML = parent.innerHTML + '<ul id="topics">' + resultHtml + '</ul>';
        }        
        else{
            parent = document.getElementById('topics');
            parent.innerHTML = resultHtml + parent.innerHTML;
        }
    }
    else{
        var parent = document.getElementById('u' + parentid);
        if(parent != null){
            parent.innerHTML = resultHtml + parent.innerHTML;
        }
        else{
            parent = document.getElementById('p' + parentid);
            if(parent != null){
                parent.innerHTML = parent.innerHTML + '<ul id="u' + parentid + '" class=\"subTopic\">' + resultHtml + '</ul>';
            }
        }
    }    
    // clean up
    //hide('postForm');
    
    clearField('txtComment');
    clearField('txtTitle');
    clearField('parentid');
    hideInputForm();
    
}

function UpdateVotes(result, vote){
    if(result.error != ''){
        alert(result.error);
        return;
    }
    var obj = document.getElementById('starbarUser');    
    if(obj != null){
        obj.style.width = (vote*17) +'px';
    }    

    obj = document.getElementById('starbar');
    if(obj != null){
        obj.style.width = (result.newRating * 17) + "px";
    }
    SetInnerHtml('totalRatingValue', result.newRating);
    SetInnerHtml('yourRating', vote);

}

function SetInnerHtml(element, html){
    var obj = document.getElementById(element);
    if(obj != null){
        obj.innerHTML = html;
    }
}

 function callFlash($Kunstner, $sang, $fil) {
   
    if (window.document) {       
        //if(window.document.vi_unge_video_player)
            window.document.vi_unge_video_player.setVideo($Kunstner, $sang, $fil, $play);
        $("strong").remove();
        $("#tester").after("<strong>&lt;object&gt;&lt;param name=&quot;movie&quot; value=&quot;http://allerweb8/flash/vi_unge_video_player.swf&quot;&gt;&lt;embed width=&quot;456&quot; height=&quot;350&quot; type=&quot;application/x-shockwave-flash&quot; flashvars=&quot;artist="+$Kunstner+"&amp;song="+$sang+"&amp;flv="+$fil+"&quot; menu=&quot;false&quot; devicefont=&quot;false&quot; bgcolor=&quot;#ffffff&quot; scale=&quot;showall&quot; play=&quot;true&quot; pluginspage=&quot;https://www.macromedia.com/go/getflashplayer&quot; src=&quot;http://allerweb8/flash/vi_unge_video_player.swf&quot;&gt;&lt;object&gt; </strong>");
        document.mainform.filmUrl.value='<object><param name="movie" value="http://allerweb8/flash/vi_unge_video_player.swf"><embed width="456" height="350" type="application/x-shockwave-flash" flashvars="artist='+$Kunstner+'&song='+$sang+'&flv='+$fil+'&doPlay=1" menu="false" name="vi_unge_video_player" devicefont="false" bgcolor="#ffffff" scale="showall" play="true" pluginspage="https://www.macromedia.com/go/getflashplayer" src="http://allerweb8/flash/vi_unge_video_player.swf"/></object>'
    }else
    {        
        document.vi_unge_video_player.setVideo($Kunstner, $sang, $fil);
        document.mainform.filmUrl.value='<object><param name="movie" value="http://allerweb8/flash/vi_unge_video_player.swf"><embed width="456" height="350" type="application/x-shockwave-flash" flashvars="artist='+$Kunstner+'&song='+$sang+'&flv='+$fil+'&doPlay=1" menu="false" name="vi_unge_video_player" devicefont="false" bgcolor="#ffffff" scale="showall" play="true" pluginspage="https://www.macromedia.com/go/getflashplayer" src="http://allerweb8/flash/vi_unge_video_player.swf"/></object>'
    }    
}




function header(heading) {
    
    if (AC_FL_RunContent == 0) {
    alert("This page requires AC_RunActiveContent.js. In Flash, run \"Apply Active Content Update\" in the Commands menu to copy AC_RunActiveContent.js to the HTML output folder.");
    } else {
    AC_FL_RunContent(
   
    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
    'width', '230',
    'height', '40',
    'src', '/flash/header',
    'quality', 'high',
    'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
    'align', 'middle',
    'play', 'true',
    'loop', 'true',
    'scale', 'showall',
    'wmode', 'window',
    'devicefont', 'false',
    'id', 'header_v8',
    'bgcolor', '#ffffff',
    'name', 'header',
    'menu', 'true',
    'allowScriptAccess','sameDomain',
    'movie', '/flash/header',
    'FlashVars', 'headline='+heading+'',
    'salign', ''
    ); 
    }
    }


function movieplayer(movie,artist,song,play){
    
    if (AC_FL_RunContent == 0) {
        alert("This page requires AC_RunActiveContent.js. In Flash, run \"Apply Active Content Update\" in the Commands menu to copy AC_RunActiveContent.js to the HTML output folder.");
    } else {
        AC_FL_RunContent(
            'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
            'width', '456',
            'height', '350',
            'src', 'vi_unge_video_player',
            'quality', 'high',
            'pluginspage', 'https://www.macromedia.com/go/getflashplayer',
            'play', 'true',
            'loop', 'true',
            'scale', 'showall',
            'bgcolor', '#ffffff',
            'devicefont', 'false',
            'name', 'vi_unge_video_player',
            'menu', 'false',
            'allowScriptAccess','sameDomain',
            'movie', '/flash/vi_unge_video_player',
            'FlashVars','artist='+artist+'&#38;song='+song+'&#38;flv='+movie+'&#38;doPlay='+play+''); 
        }
    }
    

	
	
// clear form fields

function clearDefault(el, defaultText) {
    var defaultValue = defaultText;
    if (defaultValue==el.value){el.value = "";}
}
/*
function clearPassword(el, passBox, defaultText){
    var defaultValue = defaultText;
    if (defaultValue==el.value){hide(el.id); show(passBox);}
    var obj = document.getElementById(passBox);
    if(obj && obj.focus){obj.focus();}
}*/
// code rewritten with the help of jquery due to some problems cause by the previous script in the design part
 
$(document).ready(function(){
	$('#dummyText').focus( function(){
		$(this).hide();
		$("#login_txtPassword").show();
		$("#login_txtPassword").focus();  //this cause an javascript error
		})
});


/*****************************************************
**   Objekt Dimension                               **
*****************************************************/
function Dimension(element){
		this.x=-1;
		this.y=-1;
		this.w=0;
		this.h=0;
		if (element==document){
			this.x=element.body.scrollLeft;
			this.y=element.body.scrollTop;
			this.w=element.body.clientWidth;
			this.h=element.body.clientHeight;
		}else if (element!=null){
			var e=element;
			var left=e.offsetLeft;
			while ((e=e.offsetParent)!=null) { 
				left+=e.offsetLeft; 
			}
			var e=element;
			var top=e.offsetTop;
			while((e=e.offsetParent)!=null) { 
				top+=e.offsetTop; 
			}
			this.x=left;
			this.y=top;
			this.w=element.offsetWidth;
			this.h=element.offsetHeight;
		}
	}
	
function DisplayActionMessage(message,objToCenter, placement)
{
    $("#tagsSettings").append("<div id='actionMessage'><p>" + message + "<p></div>");
   
    var element = document.getElementById("actionMessage");
    var dim = new Dimension(objToCenter);
        
    element.style.top = dim.y + "px";
    element.style.left = dim.x + "px";
             
    $("#actionMessage").show("slow");
    
    setTimeout('$("#actionMessage").hide("slow")',1000);
}

function checkMail(email)
{
	
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email))
	    return true;
	else 
	    return false;
}


function makeQueryString(BaseURL)
{

    var querystring=BaseURL;
    for(var i = 0; i < arguments.length; i++ ) {
    
        
        if (i==0)
        {
            querystring += "?";
        }
        
        if (i % 2)
        {
           var name = arguments[i];
           var value = arguments[i+1];
           
           querystring += name+"="+value+"&";
                 
        }        		
	}
	
	return querystring;
}


//call on onload on a Iframe.
function setIframeHeight(objIframe)
{
    
    var getBrowserVersion=navigator.userAgent.split("/")[1]
    var isIE = getBrowserVersion.indexOf("MSIE") > 1 ? true : false
        
    if (isIE)
    {        
        //check if content has been loaded (ie Onload bad behavior)
        if (objIframe.contentWindow.document != "undefined" && objIframe.contentWindow.document != null && objIframe.contentWindow.document.body.scrollHeight!="undefined" && objIframe.contentWindow.document.body.scrollHeight!=null)
        {
            //IE SPECIFIC
            objIframe.height=objIframe.contentWindow.document.body.scrollHeight;
        }
        else
        {               
            setTimeout("setIframeHeight(document.getElementById('" + objIframe.id + "'))",1000);
        }
    }
    else
    {
        //FIREFOX AND OPERA
        objIframe.height=objIframe.contentWindow.scrollMaxY;
    }
    
    return;
}
function whatIs() {
    $("#whatIsTagging").after("<div id='replyIsTagging'>Tags er viunge.dk's måde at holde styr på indholdet og vi håber du vil være med. Skriv et ord som du mener passer til indholdet, eller stem på et allerede eksisterende ord og så er du dermed med til at gøre viunge.dk endnu bedre.</div>");
    $("#replyIsTagging").fadeIn("slow");
    $("#replyIsTagging").click(function() {
    $(this).fadeOut("slow")});
}

// <Oneliners functions>
function ajaxAddLine(defaultText, id){
  var txtBox = document.getElementById('txtOneLine');
  if(txtBox == null){
    return;
  }
  if(txtBox.value.replace(' ', '') == '' || txtBox.value == defaultText){
    return;
  }
  $.post(document.location.pathname + '?p=3&action=addOneLine', {itemid:id,comment:txtBox.value}, function(result){
    UpdateLines(result);
  });    
}
function UpdateLines(result){
  if(result == ''){
    alert('A server side error occured. Please contact the system administrator.');
    return;
  }
  var txtBox = document.getElementById('txtOneLine');
  if(txtBox == null){
    return;
  }
  var list = document.getElementById('articleComments');
  if(list){
    list.innerHTML = result + list.innerHTML;
    txtBox.value = '';
  }      
}
function UpdateRating(id, result){    
  var r = document.getElementById('R' + id);      
  if(r != null && parseInt(result) != 'NaN'){      
    r.innerHTML = result;
  }
}
// </Oneliners functions

// <Video search functions>
function chooseYear(){
    var yearList=document.getElementById("yearList");
    document.getElementById("txtYear").value=yearList.options[yearList.selectedIndex].value;
    var year=yearList.options[yearList.selectedIndex].value;
    return year;
}
function chooseMonth(){
    var monthList=document.getElementById("monthList");
    document.getElementById("txtMonth").value=monthList.options[monthList.selectedIndex].value;	  
    var month=monthList.options[monthList.selectedIndex].value;
    return month;
}
function getURL(sYear, sMonth){      
    window.location ="/VIDEO/searchVideo.aspx?year="+sYear+"&month="+sMonth;
}
// </Video search functions>

//081217 mrr submt  to newsletter function
 function submitNewsletter(email, list, subscribe)
{
     var sub = ((subscribe) ? "&subscribe=Tilmeld" : "&unsubscribe=Afmeld");
     document.location.href = "http://nyhedsliste.allerint.dk/subscribe.asp?email=" + email + "&list=" + list + sub;
}
