//Loading dynamic links:
	function Link(div, tar){
			$(div).load(tar, function()
					  {$(div).find('a');}
			);
	}

//Initiate Connection

  var xhr = false;
  
  if (window.XMLHttpRequest){
	xhr = new XMLHttpRequest();
  } else if(window.ActiveXObject) {
  xhr = new ActiveXObject("Microsoft.XMLHTTP");
  }

function getData(dataSource, divID){
  if (xhr) {
  	var obj = document.getElementById(divID);
	xhr.open("GET", dataSource);
	
	xhr.onreadystatechange = function(){
	  if (xhr.readyState == 4 && xhr.status == 200) {
		  document.getElementById("targetDiv").innerHTML = "Received:" + xhr.responseText;
	  	obj.innerHTML = xhr.responseText;
	  } else {
		  document.getElementById("targetDiv").innerHTML = "Error code " + xhr.status;
	  }
	}
	xhr.send(null);
  }
}

//Minimize function
$(document).ready(function(){ 
	
	//Navigation hover effect 
 	$("#topnav li").prepend("<span></span>"); //Throws an empty span tag right before the a tag

	$("#topnav li").each(function() { //For each list item...
		var linkText = $(this).find("a").html(); //Find the text inside of the <a> tag
		$(this).find("span").show().html(linkText); //Add the text in the <span> tag
	}); 

	$("#topnav li").hover(function() {	//On hover...
		$(this).find("span").stop().animate({
			marginTop: "-40" //Find the <span> tag and move it up 40 pixels
		}, 250);
	} , function() { //On hover out...
		$(this).find("span").stop().animate({
			marginTop: "0"  //Move the <span> back to its original state (0px)
		}, 250);
	});

 //Pageflip effect
 $("#pageflip").hover(function() { //On hover...
	$("#pageflip img , .msg_block").stop()
		.animate({ //Animate and expand the image and the msg_block (Width + height)
			width: '307px',
			height: '319px'
		}, 500);
	} , function() {
	$("#pageflip img").stop() //On hover out, go back to original size 50x52
		.animate({
			width: '50px',
			height: '52px'
		}, 220);
	$(".msg_block").stop() //On hover out, go back to original size 50x50
		.animate({
			width: '50px',
			height: '50px'
		}, 200); //Note this one retracts a bit faster (to prevent glitching in IE)
});
	
/*	//Product Boxes:
	 lastBlock = $("#a1");
		maxWidth = 400;
		minWidth = 110;	
	
		$("#product_boxes ul li a").hover(
		  function(){
			$(lastBlock).animate({width: minWidth+"px"}, { queue:false, duration:400 });
		$(this).animate({width: maxWidth+"px"}, { queue:false, duration:400});
		lastBlock = this;
		  }
		);*/

	
	//Content
	
	//Height of content div
/*	var h= $("#content").height();
	
	$("a.minimizer").toggle( 
				function () { 
					$("#content").animate({height: "20px"}, {queue:false, duration: 1700, easing: 'easeInOutQuart'});
					$("#content .article").fadeOut("slow");

                }, 
                function () { 
					$("#content").animate({height: h}, {queue:false, duration: 1700, easing: 'easeInOutQuart'});
					$("#content .article").fadeIn("slow");
				} 
	);
	
	//Height of article2 in content div
	var h_a2= $("#content #article2").height();
	$("a.minimizer2").toggle( 
				function () {
 					$("#content #article2").animate({height: "20px"}, {queue:false, duration: 1700, easing: 'easeInOutQuart'});
					h=h-h_a2;
					$("#content").animate({height:  h}, {queue:false, duration: 1700, easing: 'easeInOutQuart'});
					$("#content #article2 p").fadeOut("slow");
					$("#content #article2 ul").fadeOut("slow");

                }, 
                function () { 
					$("#content #article2").animate({height: h_a2}, {queue:false, duration: 1700, easing: 'easeInOutQuart'});
					h=h+h_a2;
					$("#content").animate({height: h}, {queue:false, duration: 1700, easing: 'easeInOutQuart'});
					$("#content #article2 p").fadeIn("slow");
					$("#content #article2 ul").fadeIn("slow");
				} 
	); 
	
	//Height of article1 in content div
	var h_a1= $("#content #article1").height();
	$("a.minimizer1").toggle( 
				function () {
					var art_no=" #article1";
 					$("#content"+art_no).animate({height: "20px"}, {queue:false, duration: 1700, easing: 'easeInOutQuart'});
					h=h-h_a1;
					$("#content").animate({height:  h}, {queue:false, duration: 1700, easing: 'easeInOutQuart'});
					$("#content"+art_no+" p").fadeOut("slow");
					$("#content"+art_no+" ul").fadeOut("slow");

                }, 
                function () {
					var art_no=" #article1";
					$("#content "+art_no).animate({height: h_a1}, {queue:false, duration: 1700, easing: 'easeInOutQuart'});
					h=h+h_a1;
					$("#content").animate({height: h}, {queue:false, duration: 1700, easing: 'easeInOutQuart'});
					$("#content"+art_no+" p").fadeIn("slow");
					$("#content"+art_no+" ul").fadeIn("slow");
				} 
	); */
});