function update_ivw(agof, nav_id, iww_add) {

  if (document.images) {
    //ivw
    document.images["ivw"].src = 'http://artmaga.ivwbox.de/cgi-bin/ivw/CP/'+ agof +';'+ nav_id + ',,'+ iww_add +',?p='+(Math.random()*100000);
  }
  
  // sitecatalyst
  if(typeof s == 'object')
  {
    savehier = s.hier1;
    s.hier1= s.hier1 + ",Ajax," + iww_add;
    void(s.t());
    s.hier1 = savehier; 
  } 

  // googleAnalytics
  if((typeof _gaq != 'undefined') && (_gaq != null))
  {
    _gaq.push(['_trackEvent', 'TrackingManager', iww_add]);
  } 
}

///////////////////////////
//Start comment section //

/*
The following section contains functions that are essential for the comment functionality.
*/

//First define a global variable that is being used in several places.
var errorMessage = "Bitte füllen Sie dieses Feld aus.";
errorCount       = 0;

/*
  This function handles the submitted comment form.
  It uses the checkFields() function to check the field contents' validity. Only if no input or validity errors are being found
  is the addComment.php script being called (using ajax) to actually submit the comment.
  In case of a field being invalid or empty, javascript and CSS are being used to highlight the field and inform the user about
  the problem.
*/
function sendForm() {
  var userName     = document.getElementById('userName').value;
  var commentTitle = document.getElementById('commentTitle').value;
  var commentText  = document.getElementById('commentText').value;
  var article_id   = document.getElementById('art').value;
  var action       = document.getElementById('action').value;
  var formAction   = document.getElementById('formAction').value;
  
  // This array contains information about the field names, their valid content (regular expression) and their original CSS classes
  var checkFields = Array('userName@@@\\S+@@@inputtext', 'commentTitle@@@\\S+@@@inputtext', 'commentText@@@\\S+@@@inputtextarea');

  // Iterate over all form fields and check their contents for validity
  for (fieldCounter = 0; fieldCounter < checkFields.length; fieldCounter++) {
    checkFieldContent(checkFields[fieldCounter]);
  }

  // Now make sure no one uses any of the "restricted" comment sender names
  var lowerUserName = userName.toLowerCase();
  if (lowerUserName.match("^art-magazin.de$") || lowerUserName.match("^art redaktion$") || lowerUserName.match("^redaktion$") || lowerUserName.match("^art$") || lowerUserName.match("^hannes ludwig$") || lowerUserName.match("^tim sommer$") || lowerUserName.match("^ralf schl[Ã¼|ü]ter$") || lowerUserName.match(errorMessage.toLowerCase())) {
    document.getElementById('userName').className = "inputtext inputerror";
    errorCount++;
  }

  // If any of the "restricted" sender names is being used in its "correct" syntax (starting and ending with "@@@") cut off these "@" characters
  if (lowerUserName == '@@@art-magazin.de@@@' || lowerUserName == '@@@art redaktion@@@' || lowerUserName == '@@@redaktion@@@' || lowerUserName == '@@@art@@@' || lowerUserName == '@@@hannes ludwig@@@' || lowerUserName == '@@@tim sommer@@@' || lowerUserName.match("^@@@ralf schl[Ã¼|ü]ter@@@$")) {
    userName = lowerUserName.replace(/^@@@(.+)@@@$/, "$1");
  }

  if (errorCount > 0) {
    errorCount = 0;
    return false;
  } else {
    if (formAction.search(/htdocs/)) {
      // This is on the TeamSite server
      formAction = formAction.replace(/(\S*\/htdocs)\/(\S*)/, "$1/_components/comment/addComment.php");
    } else {
      // This is on the "real" webserver/website
      formAction = formAction.replace(/(\S*art-magazin\.de)\/(\S*)/, "$1/_components/comment/addComment.php");
    }

    // Call the correct addComment.php script via ajax
    $.post(formAction, { 'userName': userName, 'commentTitle': commentTitle, 'commentText': commentText, 'art': article_id, 'action': action }, function(data) {fillCommentDiv(data);});
  }
}

/*
  This function appends the handed over string (data) to the <div> element with the ID "reloadableComments" 
  and empties the <input> fields of the element with the ID "commentForm".
*/
function fillCommentDiv(data) {
  $("#reloadableComments").empty().prepend(data);
  $("#commentForm input").val("");
  document.getElementById('commentText').value = "";
}

/*
  This function checks the field content for its validity. It uses regular expressions defined in the calling function sendForm().
  The handed over string (checkField) contains the field name, the regular expression and the field's CSS class, concatenated with
  the glue string "@@@".
  If the field's content starts and ends with "@@@" it is considered to be a "special" user who has entered the comment.
  In case the regular expression does not match the field's submitted value, the CSS class "inputerror" is appended to the field's
  original class name. Via the CSS the field background image is changed to visually display the input error.
*/
function checkFieldContent (checkField) {
  var fieldElements = checkField.split("@@@");
  var fieldID       = fieldElements[0];
  var fieldRegex    = fieldElements[1];
  var fieldClass    = fieldElements[2];

  var fieldContent = document.getElementById(fieldID).value;
  
  if (!fieldContent.match("@@@\\S+@@@")) {
    if (!fieldContent.match(fieldRegex) || fieldContent.match(errorMessage)) {
      document.getElementById(fieldID).className = fieldClass + " inputerror";
      document.getElementById(fieldID).value = errorMessage;
      errorCount++;
    } else {
      document.getElementById(fieldID).className = fieldClass;
    }
  } else {
    document.getElementById(fieldID).className = fieldClass;
  }
  
}

// End comment section //
/////////////////////////

/////////////////////////////
// Start bookmarks section //

/*
  This function switches on and off the display of the bookmarks <div> via CSS
*/
function toggleBookmarks(element) {
  var linkid = element.id;
  var listid = linkid + "list";
  var list = document.getElementById(listid);
  var listVisibility = list.style.display;

  var nextStatus = (listVisibility == "block") ? "none" : "block";

  list.style.display = nextStatus;

}

// End bookmarks section //
/////////////////////////////

////////////////////////////////////
//Start news ticker section //
//initialize jquery objects after document is ready
$(document).ready(function(){

// grab images 
var up=$("#newsitem-up");
var down=$("#newsitem-down");

// put click-event on down-button, make button inactive, find and animate ul#newslist
down.click(function() {
  $(this).addClass("inactive")
  .parents(".newswrapper").find(".newslist").animate({marginTop:-244}, "slow");
  // make up-bottom ctive 
  up.removeClass('inactive');
  up.addClass('active');
  pixel_ticker();
  return false;
});

// put click-event on up-button, make button inactive, find and animate ul#newslist
up.click(function() {
  $(this).addClass("inactive")
  .parents(".newswrapper").find(".newslist").animate({marginTop:0}, "slow");
  // make down-bottom ctive
  down.removeClass('inactive');
  down.addClass('active');
  pixel_ticker();
  return false;
});

///////////////////////////////
// Hover-Effect on Newsitems //
$(".newsitem").hover(
  function() {
    $(this).addClass("hover").find("a.black").addClass("hover");
  },
  function(){
    $(this).removeClass("hover").find("a.black").removeClass("hover");
  }
);

// ivw- und google analytics aufruf aus dem ticker-scroller
  function pixel_ticker() {
    
    stemp = s.hier1;
    s.hier1+=",ajax";
    void(s.t());
    s.hier1 = stemp;
    
    document.images["ivw"].src = ivw_string_ticker;
    pageTracker._trackPageview("ticker");
    return false;
  }

});
//End newsticker section //
/////////////////////////////


