
   
    //We are using $(window).load here because we want to wait until the images are loaded  
jQuery(document).ready(function($) {
        //for each description div...  
        $('div.description').each(function(){  
            //...set the opacity to 0...  
            $(this).css('opacity', 1);  
            //..set width same as the image...  
            $(this).css('width', $(this).siblings('img').width());  
            //...get the parent (the wrapper) and set it's width same as the image width... '  
            $(this).parent().css('width', $(this).siblings('img').width());  
            //...set the display to block  
            $(this).css('display', 'block');  
        });  
      
        $('div.contentbox').hover(function(){  
            //when mouse hover over the wrapper div  
            //get it's children elements with class description '  
            //and show it using fadeTo  
          
            $(this).children('#label').stop().animate({top: "75"}, "slow");
            $(this).children('.description').children('.description_content').stop().animate({height: "40"}, "slow");
            /* $(this).children('.description').children('div#skills2').slideDown("slow"); */
            
            $(this).children('.description').children('div#skills2').stop().animate({height: "70"}, "slow");
           
            
            
           
        },function(){  
            //when mouse out of the wrapper div  
            //use fadeTo to hide the div  
            
            $(this).children('#label').stop().animate({top: "140"}, "slow"); 
            $(this).children('.description').children('.description_content').stop().animate({height: "0"}, "slow");
            /* $(this).children('.description').children('div#skills2').slideUp("slow"); */
           
            $(this).children('.description').children('div#skills2').stop().animate({height: "0"}, "slow");
        });  
      
    });  
    
    
    

    
    
    jQuery(document).ready(function($) {
        //for each description div...  
       
      $('#visit').each(function(){  
            //...set the opacity to 0...  
            $(this).css('opacity', 0);  
            });
        $('#textpostright a').hover(function(){  
            //when mouse hover over the wrapper div  
            //get it's children elements with class description '  
            //and show it using fadeTo  
          
            if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number

 if (ieversion>=7 || ieversion>=6 || ieversion>=5)
   $('#visit').stop().animate({opacity: ".6"}, "slow");

}
else{
 $('#visit').stop().animate({opacity: "1"}, "slow");
 
    }
         
           
            
            
           
        },function(){  
            //when mouse out of the wrapper div  
            //use fadeTo to hide the div  
            
           $('#visit').stop().animate({opacity: "0"}, "slow");
        });  
      
    });  

    
    
    
//  Daniel boxen    
/*
$(document).ready(function(){

	$("#navleft").hover(function() {
	  $("div#dropdowndaniel").animate({opacity: "show", top: "40"}, "slow");

	}, function() {
	  $("#dropdowndaniel").animate({opacity: "hide", top: "50"}, "fast");
	});
		
	
});
*/


/*
$(document).ready(function(){

	$("#navleft a.whois").hover(function() {
	  $("#navleft").animate({height: "400px"}, "slow");
	  alert('Hej');

	}, function() {
	  $("#navleft").animate({opacity: "hide", top: "50"}, "fast");
	});
	
	
$(document).ready(function(){

	$("#navleft a .whois").mouseover(function() {
	
	  $(this).alert("asd");

	});
	
});
	
*/
	
/*
	$(document).ready(function(){
	$("div.navleft").mouseover(function(){
    	$(this).removeClass().addClass("navleftover");
    }).mouseout(function(){
    	$(this).removeClass().addClass("navleft");		
    });
});
*/

/*
$(document).ready(function(){
	$("div#dropdowndaniel").hide();
	$("div.navleft").click(function(){
    	$('div#dropdowndaniel').slideToggle('slow', function() {
   
  $("div.navleft").mouseout(function(){
    $('div#dropdowndaniel').delay(500).slideUp();
    });




  });	

    });
    
    
    
 });
*/
 
 
 
 $(document).ready(function(){
 $("div#dropdowndaniel").hide();
 $("div.navleft, div#dropdowndaniel").mouseenter(function(){
    clearTimeout($("div.navleft").data('timeoutId'));
    $("div#dropdowndaniel").slideDown("slow");
}).mouseleave(function(){
    var someelement = this;
    var timeoutId = setTimeout(function(){ $("div#dropdowndaniel").slideUp("slow");}, 2000);
    $("div.navleft").data('timeoutId', timeoutId); //set the timeoutId, allowing us to clear this trigger if the mouse comes back over
});




 
 });
 
 
//  Shareboxen
/*

$(document).ready(function(){

	$("#sharebox").hover(function() {
	  $(this).stop().animate({left: "0"}, "slow");

	}, function() {
	  $(this).stop().animate({left: "-150"}, "fast");
	});
		
	
});

$(document).ready(function(){

	$("img.shareclass").hover(function() {
	  $(this).stop().animate({top: "-5"}, "slow");

	}, function() {
	  $(this).stop().animate({top: "-15"}, "slow");
	});
		
	
});
*/


// Rounded corner image
$(document).ready(function(){
$("div#indexcontentbox img").each(function() { // 2
$(this).wrap('<div class="roundedCorners" />'); // 3
var imgSrc = $(this).attr("src"); // 4
var imgHeight = $(this).height(); // 4
var imgWidth = $(this).width(); // 4
$(this).parent()
.css("background-image", "url(" + imgSrc + ")")
.css("background-repeat","no-repeat")
.css("height", imgHeight + "px")
.css("width", imgWidth + "px"); // 5
$(this).remove(); // 6
});
});

// Move images
/*
$(document).ready(function(){
$("div#textpost img").each(function() { // 2
$(this).wrap('<div class="roundedCorners" />'); // 3
var imgSrc = $(this).attr("src"); // 4
var imgHeight = $(this).height(); // 4
var imgWidth = $(this).width(); // 4
$(this).parent()
.css("background-image", "url(" + imgSrc + ")")
.css("background-repeat","no-repeat")
.css("height", imgHeight + "px")
.css("width", imgWidth + "px"); // 5
$(this).remove(); // 6
});
});
*/

/*
$(document).ready(function(){
$("div#textpost img, div#textpost2 img").appendTo("div#onlyimages ul");
$("div#onlyimages ul img").attr("id", function (arr) {
  return "slide-img-" + arr;
  
});
$("div#onlyimages img").attr("class", "slide");
$("div#onlyimages ul img").wrap('<li>');
});

$(document).ready(function(){
$("div.description img").remove();
});
*/





$(document).ready(function(){
$("div#sliderpost img").appendTo("div#slider ul").wrap('<li>');
$("div.sliderpost").remove();

});

$(document).ready(function(){
$("div#textpost img, div#textpost2 img").appendTo("div#onlyimages ul").wrap('<li>');
$("div#textpost img, div#textpost2 img").remove();

});



//window height fix

/*
jQuery(document).ready(function() {


var h = $('div#contentport').height() -90;
	
$('div#contentport').height(h);



var ch = $(document).height();
var bh = $(window).height();
var scroll = $('html').scrollTop();


if( ch > bh ) {
$(window).resize(function(){
        $('div#contentport') .css({'height': (($(window).height()) - 90)+'px'});
       
    });
   
}



});
*/


////// FORM  /////////


/**
* The following variables may be adjusted
*/
var active_color = '#fff'; // Colour of user provided text
var inactive_color = '#5e5e5e'; // Colour of default text
var active_background = '#555666';
var inactive_background = '#9eb1a0';

/**
* No need to modify anything below this line
*/

$(document).ready(function() {
  $("input#namn, input#foretag, input#amne, input#telefon").css("color", inactive_color);
  var default_values = new Array();
  $("input#namn, input#foretag, input#amne, input#telefon").focus(function() {
    if (!default_values[this.id]) {
      default_values[this.id] = this.value;
    }
    if (this.value == default_values[this.id]) {
      this.value = '';
      this.style.color = active_color;
      this.style.backgroundColor = active_background;
    }
    $(this).blur(function() {
      if (this.value == '') {
        this.style.color = inactive_color;
        this.style.backgroundColor = inactive_background;
        this.value = default_values[this.id];
      }
    });
  });
});

$(document).ready(function() {
$("input#email").css("color", inactive_color);
  var default_values = new Array();
  $("input#email").focus(function() {
    if (!default_values[this.id]) {
      default_values[this.id] = this.value;
    }
    if (this.value == default_values[this.id]) {
      this.value = '';
      this.style.color = active_color;
      this.style.backgroundColor = active_background;
      
    }
});
  $("input#email").blur(function() {
  
var atpos=this.value.indexOf('@');
var dotpos=this.value.lastIndexOf('.');

if (atpos<1 || dotpos<atpos+2 || dotpos+2>=this.value.length)
  {
 if (this.value == ''){
  $("#hojt").css("display", "none");
    	this.style.backgroundColor = inactive_background;
    	this.style.backgroundImage = 'url("images/forminputbg.jpg")';
    	 this.style.backgroundColor = inactive_background;
    	this.value = default_values[this.id];
    	this.style.color = inactive_color;
    	this.style.borderWidth = '0px';
    	this.style.width = '290px';
    	 this.style.height = '30px';
    	 $("input.skicka").css("background-color", "#c3c3c3");
   		$("input.skicka").css("color", inactive_color);
   		$("#foretag").css("margin-top", "20px");
    	 
    	
    	/*
this.style.borderColor = '#cccccc';
    	 this.style.borderStyle = 'dashed';
*/
    	
 }else{
 		
         $("#hojt").css("display", "block");
         $("#foretag").css("margin-top", "10px");
    	 $("#hojt").html("<p>Du måste ange en giltig email adress.</p>");
    	/*  this.style.backgroundColor = '#cc6666'; */
    	 this.style.borderColor = '#993333';
    	 this.style.backgroundColor = '#555666';
    	 this.style.borderStyle = 'solid';
    	 this.style.borderWidth = '2px';
    	 this.style.width = '286px';
    	 this.style.height = '26px';
    	 this.style.backgroundImage = 'none';
    	 $("input.skicka").css("background-color", "#c3c3c3");
   		$("input.skicka").css("color", inactive_color);
    	
    	}
  } else {
  		$("#foretag").css("margin-top", "20px");
    	$("#hojt").css("display", "none");
    	this.style.backgroundColor = '#555666';
    	this.style.backgroundImage = 'url("images/forminputbg.jpg")';
    	 this.style.borderWidth = '0px';
    	 this.style.width = '290px';
    	 this.style.height = '30px';
    	 var mailen = 'okej';
    	 
   		
   		
    	 
    	  
    	
    	/*
this.style.borderColor = '#cccccc';
    	 this.style.borderStyle = 'dashed';
*/
  
  }
  
    /*
if(this.value.search("@")>=0 || this.value == '')         

    {
    	$("#hojt").css("display", "none");
    	this.style.backgroundColor = '#ffffff';
    	this.style.backgroundImage = 'url("images/forminputbg.jpg")';
    } else {
    		
    	 $("#hojt").css("display", "block");
    	 $("#hojt").html("<p>Du måste ange en giltig email adress.</p>");
    	 this.style.backgroundColor = '#cc6666';
    	 this.style.backgroundImage = 'none';
    
    	 
    }
*/
    })});





/**
* The following variables may be adjusted
*/


/**
* No need to modify anything below this line
*/
var dittMeddelande = " Ditt meddelande"
$(document).ready(function() {
  $("textarea.test").css("color", inactive_color);
  var default_html = new Array();
  $("textarea.test").focus(function() {
    if (!default_html[this.id]) {
      default_html[this.id] = this.innerHTML;
    }
    if (this.innerHTML == default_html[this.id], this.value == default_html[this.id]) {
      this.innerHTML = '';
      this.value =''
      this.style.color = active_color;
      this.style.backgroundColor = active_background;
    }
   
    $(this).blur(function() {
      if (this.value == '') {
        this.style.color = inactive_color;
        this.style.backgroundColor = inactive_background;
        
       
        this.value = default_html[this.id];
      }
    });
  });
});





/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


/***** form spamfilter ******/
/*
$(document).ready(function($) {
$("#kontaktformular2 p").click(function(){

if (document.form.meddelande.value == " Ditt meddelande" || document.form.meddelande.innerHTML == " Ditt meddelande" || document.form.meddelande.innerHTML == ""){
    	
    	$("input.skicka").css("background-color", "#c3c3c3");
   		$("input.skicka").css("color", "#000");
    
    } else {
    $("input.skicka").css("background-color", "#555666");
   		$("input.skicka").css("color", "#fff");
    }
   
});});
*/






function ValidateForm(frm) {

var atpos=frm.email.value.indexOf('@');
var dotpos=frm.email.value.lastIndexOf('.');
    if (frm.phone.value != "phone" || atpos<1 || dotpos<atpos+2 || dotpos+2>=frm.email.value.length) {
       return false;
    }
    if (frm.meddelande.value == " Ditt meddelande" || frm.meddelande.innerHTML == " Ditt meddelande"){
    	$('#meddelandehojt').css("display", "block");
    	return false;
    
    }
   var namn = $("input#namn").val();  
var email = $("input#email").val();
var foretag = $("input#foretag").val();  
var telefon = $("input#telefon").val();
var amne = $("input#amne").val();
var meddelande = $("textarea#meddelande").val();

		var dataString = 'namn='+ namn + '&email=' + email + '&foretag=' + foretag + '&telefon=' + telefon + '&amne=' + amne + '&meddelande=' + meddelande;
		
		
		$.ajax({
      type: "POST",
      url: "/wp-content/themes/danielmeyer/kontaktform.php" ,
      data: dataString,
      success: function() {
      var w = $('input#email').width();
      var h = $('div#kontaktformular').height();
       $('div#tack').css("display", "block");
      $('div#tack').animate({opacity: ".9"}, "slow");
      
      }
     });

return false;
    
}

$(document).ready(function() {

$('ul#menu-meny li a').contents().wrap('<li class="menyli">');

});

// Meny hover
jQuery(document).ready(function($) {

$('li.menyli').hover(function(){  
            //when mouse hover over the wrapper div  
            //get it's children elements with class description '  
            //and show it using fadeTo  
          
           
            $(this).css("background-color","#d8eef4");
            $(this).parent().css("color","#000");
           
        },function(){  
            //when mouse out of the wrapper div  
            //use fadeTo to hide the div  
            
            $(this).parent('a').css("color","#fff");
            $(this).css("background-color","transparent");
        });  
      
     });

/*

function ValidateForm(frm) {
    var atpos=frm.email.value.indexOf('@');
var dotpos=frm.email.value.lastIndexOf('.');
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=frm.email.value.length)
 {
        
        return false;
    }
    return true;
}
*/
/*
jQuery(document).ready(function($) {
$("#kontaktformular2 p").click(function() {

if (meddelanderutan == 'okej'){
alert('hoj');
 $("input.skicka").css("background-color", "#555666");
   		$("input.skicka").css("color", "#fff");
}
alert('hoj');
});

});
*/


