////////////////////////
//Contact form
////////////////////////

$(document).ready(function(){
	$("#myform").validate({
		debug: false,
		rules: {
			subject: "required",
			detail: "required",
			name: "required",
			customer_human: "required",
			customer_mail: {
				required: true,
				email: true
			}
		},
		messages: {
			subject: "<br /><small>Write a subject</small>",
			detail: "<br /><small>Write a message</small>",
			name: "<br /><small>Write your name</small>",
			customer_human: "<br /><small>Write the answer (The answer is 5)</small>",
			customer_mail: "<br /><small>That's not a valid email</small> ",
		},
		submitHandler: function(form) {
			// do other stuff for a valid form
			$.post('process.php', $("#myform").serialize(), function(data) {
				$('#results').html(data);
			});
		}
	});
});

//
// Kollapsbara divvar!
//

animatedcollapse.addDiv('index', 'fade=1,speed=500,group=dqv')
animatedcollapse.addDiv('front', 'fade=1,speed=500,group=dqv')
animatedcollapse.init()

//
// Ladda projekt i en div
//

$(document).ready(function() {
        $('.loadPage').click(function(e){
            e.preventDefault();
            $('#target')
                .hide()
                .load(this.href, function() {
                    $(this).fadeIn(1000);
                });
        });
    });


//
// Ersätt myImage src med en annan bilds src
//
/*
$(document).ready(function() {
    $('.loadImage').click(function(){
        $('#myImage')
            .attr('src', this.name, function() {
                $(this).fadeIn(1000);
            });
    });
});
*/
$(document).ready(function() {
        $('.loadImage').click(function(e){
            e.preventDefault();
            $('.image_container')
                .hide()
                .load(this.href, function() {
                    $(this).fadeIn(1000);
                });
        });
    });

//
// Ladda in medarbetare yeaaaah!
//

$(document).ready(function() {
        $('.loadWorker').click(function(e){
            e.preventDefault();
            $('#target_two')
                .hide()
                .load(this.href, function() {
                    $(this).fadeIn(500);
                });
        });
    });


//
// Ladda in text!
//

$(document).ready(function() {
        $('.loadInfo').click(function(e){
            e.preventDefault();
            $('#target_three')
                .hide()
                .load(this.href, function() {
                    $(this).fadeIn(1000);
                });
        });
    });


//
// Sätt rätt färg på rätt länk i menyn
//

/*<![CDATA[*/
var Lst;
 
function CngClass(obj){
 if (typeof(obj)=='string') obj=document.getElementById(obj);
 if (Lst) Lst.className='';
 obj.className='black';
 Lst=obj;
}
 
/*]]>*/

/*<![CDATA[*/
var Ast;
 
function CngClassTwo(obj){
 if (typeof(obj)=='string') obj=document.getElementById(obj);
 if (Ast) Ast.className='';
 obj.className='bould';
 Ast=obj;
}
 
/*]]>*/



////////////////////////
//Toggle DIV
////////////////////////

function toggle_visibility(id) {
   var e = document.getElementById(id);
   if(e.style.display == 'block')
      e.style.display = 'none';
   else
      e.style.display = 'block';
}
