function _score_comment(url, id, type, newInt){
         //
         var counter = $('comment_score_count_' + id);
         
         if (parseInt(counter.innerHTML) < newInt) {
	         new Ajax.Request(url + '?type=' + type + '&id=' + id,
	                          {method:'get',
	                           onSuccess: function(transport){
	                                           //
	                                           $('comment_score_' + id).addClassName('rated').addClassName('rated' + type);
	                                           // Count + 1
	                                           counter.update(newInt);
																		         // Insert iframe
																		         new Insertion.Bottom(counter, '<iframe src="/core/stats/tag/_comment_artikel_/nielsen/1/google/1/ivw/1" style="border:0px #FFFFFF none;display:none;"></iframe>');
	                                     },
	                           onFailure: function(){
	                                             alert('Something went wrong...');
	                                      }
	                          }
	                         );
          }
}


function check_alert(form, id) {
         //
         var bool = true;

         //
         for(var i = 0; i < form.elements.length; i++){
             if(form.elements[i].value == '') bool = false;
         }

         if(!bool) Effect.Appear('alert_error_'+id);
         return bool;
}

function _comments_get_more(url, obj_id){
         //
         new Ajax.Request(url,
                          {method:'get',
                           onSuccess: function(transport){
                                              // alert(transport.responseText);
                                              $('comment_more_link_' + obj_id).hide();
                                              new Insertion.Bottom($('comments_' + obj_id), transport.responseText);
                                              // insert iframe
                                              new Insertion.Bottom($('comments_' + obj_id), '<iframe src="/core/stats/tag/_comment_artikel_/nielsen/1/google/1/ivw/1" style="border:0px #FFFFFF none;display:none;"></iframe>');

                                     },
                           onFailure: function(){
                                             alert('Something went wrong...');
                                      }
                          }
                         );
}

function _toggle_down(open, close){
	var op = $(open);
	var cl = $(close);
	
	// Open when closed
	if (op){
			if(op.style.display == 'none') {
				Effect.BlindDown(op);
				// Close other when open
				if (cl) {
					if (cl.style.display != 'none') {
						Effect.BlindUp(cl);
					}
				}
			}
			else Effect.BlindUp(op);
	}
}

function countMax(id) 
{ 
	//
	var el_textarea = $('comment_' + id);

	if(el_textarea){
		//
		var current_text_length = el_textarea.value.length;
		var output = $('textarea_counter_text_' + id);
		var max = 500;
			
		if(current_text_length > max){
			//
			el_textarea.value = el_textarea.value.substr(0, max);
		}
		output.innerHTML = max - el_textarea.value.length;
	}
}

function updateSwfSize(obj, w, h){
		 var player = document.getElementById('audioplayer_' + obj + '_player');
		 if(player){
		    // alert('player object there => player nr: ' + obj + ' w: ' + w + ' h: ' + h);
			//
			player.width = w;
			player.height = h;
			player.parentNode.width = w + 2;
			player.parentNode.height = h + 2;
		 }
		 // else alert('!!!!!!player object not there => player nr: ' + obj + ' w: ' + w + ' h: ' + h);
}

function check_form(form){
         //
         var bool = true;

         //
         for(var i = 0; i < form.elements.length; i++){
             if(form.elements[i].value == '') bool = false;
         }

         if(!bool) alert('Bitte füllen Sie alle Felder aus!');
         return bool;
}

function showhide(name){
        //
        var e = document.getElementById(name);
        e.style.display = (e.style.display == 'block') ? 'none' : 'block';
}

function poll_set_row(answer_id, poll_id){
         var e = document.getElementById(answer_id + '_' + poll_id);
         if(e){
            if(e.checked == false) {
               set_row_inactive(answer_id, poll_id);
            }
         }
}

function poll_set_checked(id){
         var e = document.getElementById(id);
         if(e){
            // alert(e.checked);
            if(e.checked == true) {
               e.checked = false;
            }
            else e.checked = true;
         }
}

function poll_radio_set_checked(id){
         var e = document.getElementById(id);
         if(e){
            e.checked = true;
         }
}

function poll_set_row_active2(answer_id, poll_id){
         //
         var e = document.getElementById('div2_' + answer_id + '_' + poll_id);
         if(e){
            e.className = 'color';
         }
}


function poll_set_row_active(answer_id, poll_id){
         //
         for(i = 0; i < 60; i++){
             set_row_inactive(i, poll_id);
         }

         //
         var e = document.getElementById('div2_' + answer_id + '_' + poll_id);
         if(e){
            e.className = 'color';
         }

}

function set_row_inactive(answer_id, poll_id){
         var e = document.getElementById('div2_' + answer_id + '_' + poll_id);
         if(e){
            e.className = '';
         }
}



function showvotingdiv()
{
	document.getElementById("voting_win_layer").style.visibility = 'visible';
	return false;
}

function closevotingdiv()
{
	document.getElementById("voting_win_layer").style.visibility = 'hidden';
}

function fullsizeImage(url)
{
	wndShow=window.open(url,'fullsize','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=500,screenX=50,screenY=50,top=50,left=50');
	wndShow.focus();
}

function fullsizeImageFormat(url,el)
{
	var thisImage  = el.firstChild;
	var thisWidth  = thisImage.offsetWidth;
	var thisHeight = thisImage.offsetHeight;

	var setWidth  = 800;
	var setHeight = 500;

	if(thisWidth < thisHeight){
		setWidth  = 600;
		setHeight = 800;
	}

	wndShow=window.open(url,'fullsize','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+setWidth+',height='+setHeight+',screenX=50,screenY=50,top=50,left=50');
	wndShow.focus();
}

function fullsizeImageFormatWithGivenSize(url, el, w, h)
{
	var thisImage  = el.firstChild;
	var thisWidth  = thisImage.offsetWidth;
	var thisHeight = thisImage.offsetHeight;

	var setWidth  = w; //800;
	var setHeight = h; //500;

	if(thisWidth < thisHeight && setWidth > setHeight){
		setWidth  = h; // 600;
		setHeight = w; // 800;
	}

	wndShow=window.open(url,'fullsize','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+setWidth+',height='+setHeight+',screenX=50,screenY=50,top=50,left=50');
	wndShow.focus();
}


function changeTeaserContent(key, cur, qty)
{
	for(i = 1; i <= qty; i++)
    {
    	document.getElementById(key+"_"+i).style.display = 'none';
    }
    document.getElementById(key+"_"+cur).style.display = 'block';
}

function showTooltip(name)
{
	document.getElementById("vip_rel_tooltip").firstChild.data = name;
	document.getElementById("vip_rel_tooltip").style.visibility = 'visible';
}

function hideTooltip()
{
	document.getElementById("vip_rel_tooltip").style.visibility = 'hidden';
}

function pnc_openWin(url,name,popWidth,popHeight,scroll,popLeft,popTop)
{
	leftPos=!isNaN(popLeft) ? popLeft : screen.width ? (screen.width-popWidth)/2 : 20;
	topPos=!isNaN(popTop) ? popTop : screen.height ? (screen.height-popHeight)/2 : 20;
    eval("pnc_"+name+"=window.open('"+url+"','"+name+"','"+",scrollbars="+scroll+",width="+popWidth+",height="+popHeight+",left="+leftPos+",top="+topPos+"');");
    eval("pnc_"+name+".focus()");
}

function topFlopVoting(value,vid)
{
	document.tf_form.tf_val.value = value;
	document.tf_form.tf_v_id.value = vid;
	document.tf_form.submit();
}

function showMoreTrackbacks()
{
	document.getElementById("tb_more").style.display = 'block';
	document.getElementById("tb_more_href").style.display = 'none';
}

function addBookmarkUrl(url, title)
{
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	}
	else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title);
	}
	else if(window.opera && window.print) { // Opera Hotlist
		return true;
	}
}

function setFinderRatingLayer()
{
  var Res =  document.URL.search(eval("/#rated/"));

  if (Res != -1)
  {
  	document.getElementById('rating_form').style.display = 'none';
  	document.getElementById('rating_thanks').style.display = 'block';
  }
}
