
window.onerror=function(desc,page,line,chr){
/* alert('JavaScript error occurred! \n'
  +'\nError description: \t'+desc
  +'\nPage address:      \t'+page
  +'\nLine number:       \t'+line
 );*/
}

$(function(){
 $('a').focus(function(){this.blur();});
 SI.Files.stylizeAll();
 slider.init();

 $('input.text-default').each(function(){
  $(this).attr('default',$(this).val());
 }).focus(function(){
  if($(this).val()==$(this).attr('default'))
   $(this).val('');
 }).blur(function(){
  if($(this).val()=='')
   $(this).val($(this).attr('default'));
 });

 $('input.text,textarea.text').focus(function(){
  $(this).addClass('textfocus');
 }).blur(function(){
  $(this).removeClass('textfocus');
 });

 var popopenobj=0,popopenaobj=null;
 $('a.popup').click(function(){
  var pid=$(this).attr('rel').split('|')[0],_os=parseInt($(this).attr('rel').split('|')[1]);
  var pobj=$('#'+pid);
  if(!pobj.length)
   return false;
  if(typeof popopenobj=='object' && popopenobj.attr('id')!=pid){
   popopenobj.hide(50);
   $(popopenaobj).parent().removeClass(popopenobj.attr('id').split('-')[1]+'-open');
   popopenobj=null;
  }
  return false;
 });
 $('p.images img').click(function(){
  var newbg=$(this).attr('src').split('bg/bg')[1].split('-thumb')[0];
  $(document.body).css('backgroundImage','url('+_siteRoot+'images/bg/bg'+newbg+'.jpg)');
 
  $(this).parent().find('img').removeClass('on');
  $(this).addClass('on');
  return false;
 });
 $(window).load(function(){
  //$.each(css_ims,function(){(new Image()).src=_siteRoot+'css/images/'+this;});
  /*$.each(css_cims,function(){
   var css_im=this;
   $.each(['blue','purple','pink','red','grey','green','yellow','orange'],function(){
    (new Image()).src=_siteRoot+'css/'+this+'/'+css_im;
   });
  });*/
 }); 
 $('div.sc-large div.img:has(div.tml)').each(function(){
  $('div.tml',this).hide();
  $(this).append('<a href="#" class="tml_open">&nbsp;</a>').find('a').css({
   left:parseInt($(this).offset().left)+864,top:parseInt($(this).offset().top)+1
  }).click(function(){
   $(this).siblings('div.tml').slideToggle();
   return false;
  }).focus(function(){this.blur();}); 
 });
});
var slider={
 num:-1,
 cur:0,
 cr:[],
 al:null,
 at:10*421,
 ar:true,
 init:function(){
  if(!slider.data || !slider.data.length)
   return false;

  var d=slider.data;
  slider.num=d.length;
  var pos=Math.floor(Math.random()*1);//slider.num);
  for(var i=0;i<slider.num;i++){
   $('#'+d[i].id).css({left:((i-pos)*421)});
   $('#slide-nav').append('<a id="slide-link-'+i+'" href="#" onclick="slider.slide('+i+');return false;" onfocus="this.blur();">'+(i+1)+'</a>');
  }

  $('img,div#slide-controls',$('div#slide-holder')).fadeIn();
  slider.text(d[pos]);
  slider.on(pos);
  slider.cur=pos;
  window.setTimeout('slider.auto();',slider.at);
 },
 auto:function(){
  if(!slider.ar)
   return false;

  var next=slider.cur+1;
  if(next>=slider.num) next=0;
  slider.slide(next);
 },
 slide:function(pos){
  if(pos<0 || pos>=slider.num || pos==slider.cur)
   return;

  window.clearTimeout(slider.al);
  slider.al=window.setTimeout('slider.auto();',slider.at);

  var d=slider.data;
  for(var i=0;i<slider.num;i++)
   $('#'+d[i].id).stop().animate({left:((i-pos)*421)},1000,'swing');
  
  slider.on(pos);
  slider.text(d[pos]);
  slider.cur=pos;
 },
 on:function(pos){
  $('#slide-nav a').removeClass('on');
  $('#slide-nav a#slide-link-'+pos).addClass('on');
 },
 text:function(di){
  slider.cr['a']=di.client;
  slider.cr['b']=di.desc;
  //slider.ticker('#slide-client span',di.client,0,'a');
  //slider.ticker('#slide-desc',di.desc,0,'b');
 },
 ticker:function(el,text,pos,unique){
  if(slider.cr[unique]!=text)
   return false;

  ctext=text.substring(0,pos)+(pos%2?'-':'_');
  $(el).html(ctext);

  if(pos==text.length)
   $(el).html(text);
  else
   window.setTimeout('slider.ticker("'+el+'","'+text+'",'+(pos+1)+',"'+unique+'");',30);
 }
};
// STYLING FILE INPUTS 1.0 | Shaun Inman <http://www.shauninman.com/> | 2007-09-07
if(!window.SI){var SI={};};
SI.Files={
 htmlClass:'SI-FILES-STYLIZED',
 fileClass:'file',
 wrapClass:'cabinet',
 
 fini:false,
 able:false,
 init:function(){
  this.fini=true;
 },
 stylize:function(elem){
  if(!this.fini){this.init();};
  if(!this.able){return;};
  
  elem.parentNode.file=elem;
  elem.parentNode.onmousemove=function(e){
   if(typeof e=='undefined') e=window.event;
   if(typeof e.pageY=='undefined' &&  typeof e.clientX=='number' && document.documentElement){
    e.pageX=e.clientX+document.documentElement.scrollLeft;
    e.pageY=e.clientY+document.documentElement.scrollTop;
   };
   var ox=oy=0;
   var elem=this;
   if(elem.offsetParent){
    ox=elem.offsetLeft;
    oy=elem.offsetTop;
    while(elem=elem.offsetParent){
     ox+=elem.offsetLeft;
     oy+=elem.offsetTop;
    };
   };
  };
 },
 stylizeAll:function(){
  if(!this.fini){this.init();};
  if(!this.able){return;};
 }
};

//// Slider Sag blok

$(function(){
	$('.news-container').vTicker({showItems: 3});

});



/**
 * jQuery.seekAttention
 * Copyright (c) 2008 James Padolsey - jp(at)qd9(dot)co.uk | http://enhance.qd-creative.co.uk
 * Dual licensed under MIT and GPL.
 * Date: 17/09/08
 *
 * @projectDescription Focus user's attention towards elements
 * http://enhance.qd-creative.co.uk/demo/seekAttention/
 * Tested with jQuery 1.2.6. On FF 2/3, IE 6/7, Opera 9.5 and Safari 3. on Windows XP.
 *
 * @author James Padolsey
 * @version 1.0
 *
 * @id jQuery.seekAttention
 * @id jQuery.fn.seekAttention
 */
jQuery.fn.seekAttention = function(o){
    /* Default options: */
    var defaultOptions = {
        color: '#333333',
        opacity: 0.55,
        fade: true,
        fadeSpeed: 400,
        hideOnClick: true,
        hideOnHover: true,
        pulse: true,
        blur: true,
        pulseSpeed: 400,
        paddingTop: 0,
        paddingRight: 0,
        paddingBottom: 0,
        paddingLeft: 0,
        container: 'body'
    };
    // Checking that correct data type has been passed for each option:
    for (var i in o) {
        if(i!=='container') {
            if(o[i]&&o[i]!=='undefined') {
                if(typeof o[i] !== typeof defaultOptions[i]) {return;}
            }
        } else {
            if(typeof o[i] !== 'object' && typeof o[i] !== 'string' ) {
                return;
            }
        }
    }
    var options = $.extend(defaultOptions,o);
    /* Make sure there are no remains of the last attention seeker: */
    $('.sa-overlay,.sa-pulse-overlay,div[class*="sa-blur"]').remove();
    function getHorPadding(elem) {
        if(elem===document) {return 0;}
        /* Get computed left and right padding of an element: */
        return parseInt($(elem).css('paddingLeft').replace('px',''),10) + parseInt($(elem).css('paddingRight').replace('px',''),10);
    }
    function getVerPadding(elem) {
        if(elem===document) {return 0;}
        /* Get computed top and bottom padding of an element: */
        return parseInt($(elem).css('paddingTop').replace('px',''),10) + parseInt($(elem).css('paddingBottom').replace('px',''),10);
    }
    function pixelateBorders(elem) {
        if(elem===document) {return 0;}
        /* A function to pixelate all border widths defined in words (thin/medium/thick): */
        var blw = 'borderLeftWidth';
        var brw = 'borderRightWidth';
        var btw = 'borderTopWidth';
        var bbw = 'borderBottomWidth';
        function makeNumerical(prop) {
            if($(elem).css(prop).indexOf('i')>-1) {
                if($(elem).css(prop)==='thin') {$(elem).css(prop,'2px');}
                if($(elem).css(prop)==='medium') {$(elem).css(prop,'4px');}
                if($(elem).css(prop)==='thick') {$(elem).css(prop,'6px');}
            }
        }
        makeNumerical(blw);
        makeNumerical(brw);
        makeNumerical(btw);
        makeNumerical(bbw);
    }
    function getHorBorder(elem) {
        if(elem===document) {return 0;}
        /* Get computed left and right border widths: */
        var horBorder = 0;
        var borderLeftWidth = $(elem).css('borderLeftWidth');
        var borderRightWidth = $(elem).css('borderRightWidth');
        if($(elem).css('borderLeftStyle')!=='none') {
            horBorder += parseInt(borderLeftWidth.replace('px',''),10);
        }
        if($(elem).css('borderRightStyle')!=='none') {
            horBorder += parseInt(borderRightWidth.replace('px',''),10);
        }
        return horBorder;
    }
    function getVerBorder(elem) {
        if(elem===document) {return 0;}
        /* Get computed top and bottom border widths: */
        var verBorder = 0;
        var borderTopWidth = $(elem).css('borderTopWidth');
        var borderBottomWidth = $(elem).css('borderBottomWidth');
        if($(elem).css('borderTopStyle')!=='none') {
            verBorder += parseInt(borderTopWidth.replace('px',''),10);
        }
        if($(elem).css('borderBottomStyle')!=='none') {
            verBorder += parseInt(borderBottomWidth.replace('px',''),10);
        }
        return verBorder;
    }
    function newBox(t,l,h,w,c) {
        /* Create new div and assign style props and a class then append to body: */
        $('<div/>').css({
            top: t+'px',
            left: l+'px',
            position: 'absolute',
            zIndex: 9999,
            height: h+'px',
            width: w+'px',
            background: options.color,
            opacity: 0,
            display: 'none'
        }).addClass(c||'sa-overlay').appendTo('body').show();
    }
    $(this).each(function(i){
        if(i>0) {return;}

        pixelateBorders(this);
        var containerIsDocument = (options.container==='body'||options.container===document) ? true : false;

        /* Retrieve all dimensions needed: */
        var container = (containerIsDocument) ? document : $(options.container);
        var containerHeight = $(container).height() + getVerPadding(container) + getVerBorder(container);
        var containerWidth = $(container).width() + getHorPadding(container) + getHorBorder(container);
        var containerTop = (containerIsDocument) ? 0 : $(container).offset().top;
        var containerLeft = (containerIsDocument) ? 0 : $(container).offset().left;
        var width = $(this).width() + getHorPadding(this) + getHorBorder(this) + options.paddingLeft + options.paddingRight;
        var height = $(this).height() + getVerPadding(this) + getVerBorder(this) + options.paddingTop + options.paddingBottom;
        var left = $(this).offset().left - options.paddingLeft;
        var top = $(this).offset().top - options.paddingTop;
        var right = containerWidth - (width+left);
        var bottom = containerHeight - (height+top);

        /* If the target element is not positioned within the "container" element then STOP: */
        if(left<containerLeft||top<containerTop||left>containerLeft+containerWidth||top>containerTop+containerHeight) {return;}

        /* Just encase the above assignments result in an invalid negative value: */
        right = (right.toString().indexOf('-')>-1) ? 0 : right;
        bottom = (bottom.toString().indexOf('-')>-1) ? 0 : bottom;
        top = (top.toString().indexOf('-')>-1) ? 0 : top;
        left = (left.toString().indexOf('-')>-1) ? 0 : left;

        /* We need five new boxes including the pulsing box */
        newBox(containerTop,containerLeft,containerHeight,left-containerLeft);
        newBox(containerTop,containerLeft+(left-containerLeft),top-containerTop,width);
        newBox(containerTop,(left-containerLeft)+containerLeft+width,containerHeight,containerWidth-(left-containerLeft)-width);
        newBox((top-containerTop)+containerTop+height,left,containerHeight-((top-containerTop))-height,width);
        /* The pulse box is needed regardless of whether you've set options.pulse to true/false: */
        newBox(top,left,height,width,'sa-pulse-overlay');

        var blur = ($.browser.msie&&$.browser.version<=6) ? false : options.blur;
        if(blur) {
            /* We need 4 shadow/blur levels to make it look nice ;-) */
            /* Obvously there will only be a blur if it is set to true in options */
            $([1,2,3,4]).each(function(i){
                newBox(top+i,left+i,height-(i*2),1,'sa-blur'+i);
                newBox(top+i,left+1+i,1,width-(2+(2*i)),'sa-blur'+i);
                newBox(top+i,left+width-(i+1),height-(2*i),1,'sa-blur'+i);
                newBox(top+height-(i+1),left+1+i,1,width-(2+(2*i)),'sa-blur'+i);
                $('.sa-blur'+i).css({
                    backgroundColor: options.color,
                    opacity: 0
                }).attr('id','sa-blur'+(options.opacity/2-(i/8)).toString());
            });
        }
        var hasScrolled = false;
        var scrolled = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
        var viewportHeight = (parseInt($(window).height(),10)>window.innerHeight) ? window.innerHeight : parseInt($(window).height(),10);
        // Tests if target element is visible, if it's not then the page will scroll to it.
        if(top>(scrolled+viewportHeight)||top+height>(scrolled+viewportHeight)||top<scrolled) {
            var where = top-Math.round(viewportHeight/2);
            /* Smoothly scrolls page to position of target element: */
            $('html, body').animate({ scrollTop: where }, 1000);
            hasScrolled = true;
        }
        /* setTimeout - no point in starting the fading too soon */
        setTimeout(function(){
            if(options.fade) {
                /* Fade in the overlay */
                $('.sa-overlay').animate({opacity:options.opacity},options.fadeSpeed);
                $('div[class*="sa-blur"]').each(function(){
                    /* Get required opacity (in ID attribute) and animate to that opacity */
                    $(this).animate({opacity:$(this).attr('id').substr(7)});
                });
                /* Attach the click/hover events once above fading has occured */
                setTimeout(function(){attachEvents();},options.fadeSpeed);
            } else {
                $('.sa-overlay').css({opacity:options.opacity});
                $('div[class*="sa-blur"]').each(function(){
                    /* Get required opacity (in ID attribute) and apply that opacity */
                    $(this).css({opacity:$(this).attr('id').substr(7)});
                });
                /* Wait 100 millisecs and then attach hover/click events (to avoid dblclick fury) */
                setTimeout(function(){attachEvents();},200);
            }
            function pulseElement() {
                $('.sa-pulse-overlay').animate({opacity:options.opacity/2},options.pulseSpeed,function(){
                    $(this).animate({opacity:0},options.pulseSpeed,function(){
                        pulseElement();
                    });
                });
            }
            if(options.pulse) {
                pulseElement();
            }
        },(hasScrolled) ? 1000 : 500);
        function attachEvents() {
            /* Attach the click 'hide' event to the entire overlay and the hover 'hide' event to the element overlay (pulse) */
            if(options.hideOnHover) {
                $('.sa-pulse-overlay').mouseover(function(){
                    $('.sa-pulse-overlay').remove();
                    $('div[class*="sa-blur"],.sa-overlay,').fadeOut(400,function(){
                         $('div[class*="sa-blur"],.sa-overlay,').remove();
                    });
                });
            }
            if(options.hideOnClick) {
                $('.sa-overlay,.sa-pulse-overlay').click(function(){
                   $('.sa-overlay,.sa-pulse-overlay').remove();
                   $('div[class*="sa-blur"]').remove();
                });
            }
        }
    });
};
