var si=0;
var op;
var psobj=null;
var cont=null;
var simages=null;
var ssi=0;


function pic_switch(){
  cont=document.getElementById('picswitch');
  simages=cont.getElementsByTagName('IMG');
  var loadpic=document.getElementById('loadpic');
  loadpic.style.zIndex=1000;
  loadpic.style.filter='alpha(opacity=0)';
  loadpic.style.opacity=0;
  swap();
}

function swap(){
  psobj=simages[simages.length-1];
  op=500;
  ssi=setInterval("swapanim()",10);
}

function swapanim(){
  op-=2;
  if (op<100){
    if (op==0){
      op=100;
      clearInterval(ssi);
      first=simages[0];
      psobj.removeNode;
      cont.insertBefore(psobj,first);
    }
    psobj.style.filter='alpha(opacity='+op+')';
    psobj.style.opacity=String(op/100);
    if (op==100) swap();
  }
}

window.onunload=function(){clearInterval(ssi);}

function mailme(t){
    t.href=t.href.replace(/nsp./g, '');
}

function mslide(){
   $(".oc_title").each(function(){
        var tn=$(this).next();
        var h=tn.height();
       $(this).click(function(event){
         
         if (tn.is(":hidden")) {
            tn.animate({height:h, opacity:1},{queue:false,duration:500});
            $(this).css({'background-image' : 'url(../images/oc_bg_minus.png)'});
         }
         else {
            tn.animate({height:0, opacity:0},{queue:false,duration:500});
            $(this).css({'background-image' : 'url(../images/oc_bg_plus.png)'});
        }
         event.preventDefault();
       });
   });
}

function timedRedirect(rt,url){
    rt--;
    if (rt>0){
        document.getElementById('r_timer').innerHTML="("+rt+")";
        setTimeout('timedRedirect('+rt+',"'+url+'");',1000);
    }
    else window.location.href=url;
}

function setCol(o,c1,c2){
    o.style.backgroundColor=c1;
    o.style.color=c2;
}

function mysubmit(o){
    var tmp=window.location.href.split(':');
    o.action='/formproc.php?l='+tmp[2];
    //alert(o.action);
    var reg,errors=0;
    
    
    reg=/^([^0-9\/_]{2,25})$/;
	if (!reg.test(o.firstname.value)) {
        setCol(o.firstname,'#D93131','#fff');
        errors++;
    }
	else setCol(o.firstname,'#fff','#000');
	
	reg=/^([^0-9\/_]{2,25})$/;
	if (!reg.test(o.lastname.value)) {
        setCol(o.lastname,'#D93131','#fff');
        errors++;
    }
	else setCol(o.lastname,'#fff','#000');
	
	reg=/^[0-9\/+ -]{7,20}/;
	if (!reg.test(o.telephone.value)) {
        setCol(o.telephone,'#D93131','#fff');
        errors++;
    }
	else setCol(o.telephone,'#fff','#000');
	
	reg=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	if (!reg.test(o.email.value)) {
        setCol(o.email,'#D93131','#fff');
        errors++;
    }
	else setCol(o.email,'#fff','#000');
	
	reg=/^([^0-9]+)$/;
	if (!reg.test(o.comment.value)) {
        setCol(o.comment,'#D93131','#fff');
        errors++;
    }
	else setCol(o.comment,'#fff','#000');
	
    
    if (errors==0) o.submit();
}

$(document).ready(function(){

//     $('#leftmenu li').hover(function(){
//         $(this).animate({width:'282px'},{queue:false, duration:200, easing:'easeInSine'});
//     },
//     function(){
//         $(this).animate({width:'306px'},{queue:false, duration:200, easing:'easeOutSine'});
//     });
//     
//     $('#topmenu li a').hover(function(){
//         $(this).parent().animate({marginTop:'5px'},{queue:false, duration:200, easing:'easeInSine'});
//     },
//     function(){
//         $(this).parent().animate({marginTop:'0px'},{queue:false, duration:200, easing:'easeOutSine'});
//     });
    
    $('.aNode').each(function(){
        var tmp = $(this).attr('class').split(" ");
        if (tmp.length > 1) var groupClass = tmp.pop();
        var aTitle = $(this).children();
        var oh = aTitle.next().height();
        aTitle.next().css({height: 0,opacity: 0});
        aTitle.hover(function(){
            $(this).addClass('over');
        }, function(){
            $(this).removeClass('over');
        }).click(function(){
            if ($(this).hasClass('opened')) $(this).removeClass('opened').next().animate({opacity: 0,height: 0}, {queue: false});
            else {
                if (groupClass) $(this).parent().siblings().filter("." + groupClass).children().removeClass('opened').next().animate({opacity: 0,height: 0}, {queue: false});
                $(this).addClass('opened').next().animate({opacity: 1,height: oh + 'px'}, {queue: false});
            }
        });
    });

});