



















var tableTop_start;
var skip_waiting;


function redirect(url){
    location = url;
}

// browser detection
function Browser()
{
    var agent  = navigator.userAgent.toLowerCase();
    this.ns    = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
    if(agent.indexOf("msie") != -1){
        if(agent.indexOf("msie 6")>-1)
            this.ie = 6;
        else if(agent.indexOf("msie 7")>-1)
            this.ie = 7;
    }

    return this;
}


function scrollOneNews()
{    
    var tableTop = document.getElementById("newsTbl").offsetTop;
    if ( tableTop%25 != 0 )
    {
        document.getElementById("newsTbl").style.top = tableTop-1;
        setTimeout( "scrollOneNews()", 25 );
    }
}

function scrollNews()
{
    tableTop_start = document.getElementById("newsTbl").offsetTop;
    setTimeout ( "start_scrolling()", 2000 );
}

function start_scrolling()
{
    if ( document.getElementById("newsTbl") )
    {
        table = document.getElementById("newsTbl");
        numNews = table.rows.length;
        
        table.style.top = table.offsetTop-1;
        if ( table.offsetTop - tableTop_start < numNews*(-25) )
            document.getElementById("newsTbl").style.top = tableTop_start + 25;
        
        if ((((tableTop_start - table.offsetTop)/25)|0)==numNews)
            skip_waiting = true;
        else
            skip_waiting = false;
        
        if (skip_waiting==true)
        {
            start_scrolling();
        }
        else
        {
            scrollOneNews();
            setTimeout ( "start_scrolling()", 2000 );
        }
    }
}

function changeItemStyle(me, bgColor, fgColor, level)
{
    if (bgColor)
        me.style.backgroundColor = bgColor;
    if (fgColor)
        me.style.color = fgColor;
}

// Create poll bar results.
function createOneGp(Id, color, len, value, per, opoSide)
{
    elem = eval("document.all.gp" + Id);
    elemLab = eval("document.all.gpLab" + Id);
    str = "<div style='background-color:" + color + ";width:" + len + "%;'></div>";
    elem.innerHTML = str;
    //elemLab.innerHTML = per + "%";
    if (len < per)
        setTimeout("createOneGp(" + Id + ",'" + color + "'," + (len + 1) + "," + value + "," + per + ",'" + opoSide + "')", 10);
    else{    
        str = "<div style='background-color:" + color + ";width:" + len + "%;'></div>";
        elem.innerHTML = str;
        //elemLab.innerHTML = per + "%";
    }
}
                
function WithoutContent(ss)
{
    if(ss.length > 0)
        return false;
    return true;
}

function NoneWithContent(ss)
{
    for(var i = 0; i < ss.length; i++)
    {
        if(ss[i].value.length > 0)
            return false;
    }
    return true;
}

function NoneWithCheck(ss)
{
    for(var i = 0; i < ss.length; i++)
    {
        if(ss[i].checked)
            return false;
    }
    return true;
}

function WithoutCheck(ss)
{
    if(ss.checked)
        return false;
    return true;
}

function WithoutSelectionValue(ss)
{
    for(var i = 0; i < ss.length; i++)
    {
        if(ss[i].selected)
        {
            if(ss[i].value.length)
                return false;
        }
    }
    return true;
}
function cancelHighlight(){
    $("span.highlight, span.no-highlight").toggleClass("no-highlight").toggleClass("highlight");
}
function wordhighlight(Source, aWords)
{   
    // Extract HTML Tags
    aSourceObject = document.getElementById(Source);
    
    regexp = /<[^<>]*>/ig;
    vHTMLArray = aSourceObject.innerHTML.match(regexp);
    
    // Replace HTML tags
    vStrippedHTML = aSourceObject.innerHTML.replace(regexp,"$!$");
    // alert(vStrippedHTML);
    // Split Search Words.    
    arr = aWords.split(' ');
    vTemp = vStrippedHTML;
    for (var i=0 ; i < arr.length; i++)
    {


        regexp= new RegExp ("(" + arr[i] + ")", "gi");
        vTemp = vTemp.replace(regexp,'<span class="highlight">$1</span>');
    }
    //Reinsert HTML
    for(i=0;vTemp.indexOf("$!$") > -1;i++)
        vTemp = vTemp.replace("$!$", vHTMLArray[i]);
    
    // Diaply Result
    aSourceObject.innerHTML = vTemp;
}
//validating e-mail
function validEmail(email)
{
    s = email;
    if(s != "")
    {
        if((pos = s.indexOf("@")) == -1)
            return false; 
        else
        {
            newS = s.substr(pos + 1)
            if((pos = newS.indexOf(".")) == -1)
                return false;
            else if(newS.charAt(pos + 1) == "")
                return false;
        }
    }
    return true;
}

// change mod in post
function change_mod(){
   var argv = change_mod.arguments;
   var argc = argv.length;
  
   if (argc==0) {
          return false;
   }
    form1 = document.getElementById(argv[0][0]);
   if(argv[0][1] != undefined)
        form1.mod.value = argv[0][1];
    if(argv[0][2] != undefined)
        form1.act.value = argv[0][2];
    if(argv[0][3] != undefined)
        form1.sub.value = argv[0][3];
       for (var i=1; i<argc; i=i+2) {
        if(argv[i+1] != undefined){
               var objID = document.getElementById(argv[0][0]);
                 var btn = document.createElement('input');
            btn.type = "hidden";
            btn.name = argv[i];
            btn.value = argv[i+1];
              objID.appendChild(btn);
        }
   }
     form1.submit();  
}
















(function ($) {
// VERTICALLY ALIGN FUNCTION
$.fn.vAlign = function() {
    return this.each(function(i){
    var ah = $(this).height();
    var ph = $(this).parent().height();
    var mh = (ph - ah) / 2;
    $(this).css('margin-top', mh);
    });
};
})(jQuery);


 $(document).ready(function(){ 
   
   
    var $userForms = $(".userForm");
    if($userForms.length > 0){
        $.extend(true,$.validator.messages, {
                        required: "This field is required",
                        remote: "Please fix this field",
                        email: "Please enter a valid email address",
                        url: "Please enter a valid URL",
                        date: "Please enter a valid date",
                        dateISO: "Please enter a valid date (ISO)",
                        number: "Please enter a valid number",
                        numberDE: "Bitte geben Sie eine Nummer ein",
                        digits: "Please enter only digits",
                        creditcard: "Please enter a valid credit card number",
                        equalTo: "Please enter the same value again.",
                        accept: "Please enter a value with a valid extension.",
                        maxlength: $.format("Please enter no more than {0} characters."),
                        minlength: $.format("Please enter at least {0} characters."),
                        rangelength: $.format("Please enter a value between {0} and {1} characters long."),
                        range: $.format("Please enter a value between {0} and {1}."),
                        max: $.format("Please enter a value less than or equal to {0}."),
                        min: $.format("Please enter a value greater than or equal to {0}.")
                    });

        $userForms.each(function(index, Element){
            var $userForm = $(this);
            
            $userForm.validate({ 
                errorPlacement: function($error, $element) {
                    
                    $element.wrap('<div class="fieldBox" />');
                    $element.after($error  );
                }
            
            });
            
            $userForm.find('input[type!="hidden"][type!="image"], textarea,select').each(function(index, element){
                    
                $input = $(element);
                if($input.attr("required")==1){
                    
                    $input.rules("add", {
                        required: true
                    });    
                }    
            });    

            
        });        
    }
  
     
   $("div#header #mainMenu li a").each(function(index, Element){
       
       //$(this).valign({wraps:true});
       $(this).vAlign();
       $(this).css('color','#ffffff');     
       
   });
   
   $(document).pngFix();
    $('.slide_box').show(); 
    $('#slide').cycle({ 
        delay:  1000, 
        speed:  500,  
        height: 272
    }); 
    
    
    var $storyImg  =$(".storyBody img");
    if($storyImg.length > 0){
        $storyImg.each(function(index) {
            var $this = $(this);
            if($this.attr("hspace") >= 0){
                $this.css("margin-right",$this.attr("hspace"));  
                $this.css("margin-left",$this.attr("hspace"));          
            }
            if($this.attr("vspace") >= 0){
                $this.css("margin-top",$this.attr("hspace"));  
                $this.css("margin-bottom",$this.attr("hspace"));          
            }

            if($this.attr("align")=="right" || $this.attr("align")=="left"){
                $this.css("float",$this.attr("align"));  
                
            }
             
        });        
    }
    
    
    
    $("#mainMenu li.mi_unselected").mouseover(function(){
    
            $(this).addClass('mi_selected');  
            $(this).removeClass('mi_unselected');    


    });
    $("#mainMenu li.mi_unselected").mouseout(function(){

            $(this).addClass('mi_unselected'); 
            $(this).removeClass('mi_selected');      

    });
    
//     $("#mainMenu li a").mouseover(function(){
//        if(!$(this).parent().hasClass('mi_selected')){
//               
//            $(this).parent().addClass('mi_selected notInit');  
//            $(this).parent().removeClass('mi_unselected');       
//        }
//        

//    });
//    $("#mainMenu li a").mouseout(function(){
//        if(!$(this).parent().hasClass('mi_selected notInit')){
//              
//            $(this).parent().addClass('mi_unselected');   
//            $(this).parent().removeClass('mi_selected');     
//        }

//    });











});



 
