if($.cookie("marketsize"))
{	
	var ckvalue = $.cookie("marketsize");		
	
	switch(ckvalue)
	{
		case "smaller":   
			$('body').css('font-size', '76%');
		break;
		
		case "medium":
			$('body').css('font-size', '86%');
		break;
		
		case "larger":
			$('body').css('font-size', '96%');
		break;
	}
}		
	
$(function() {
	$('.map').maphilight({ fillColor: "afc345" });
});			
	
function getData(id)
{			
	var xmlhttp;
	
	if(window.XMLHttpRequest)
	{
		xmlhttp = new XMLHttpRequest();
	}			
	else
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}		
	
	xmlhttp.open("get","/home/?details=" + id,true);
	xmlhttp.send();
			
	xmlhttp.onreadystatechange = function()
	{				
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{						
			$('.gray-text-box').show();			
			
			var sections = xmlhttp.responseText.split("__s__");
			var standText = document.createTextNode(sections[1]);
			
			$('.gray-text-box-header').html(sections[0]);
			$('#ajaxResult').html(sections[1]);
			
			$('#ajaxTel').html(sections[2]);
			$('#ajaxEmail').html(sections[3]);
								
			if(sections[4] != undefined)
			{	
				$('.gray-text-box-image').show();			
				$('.gray-text-box-image').html('<img src="cd-content/uploads/images/' + sections[4] + '" alt="">'); //<img src="cd-content/uploads/images/' + sections[4] + '" alt="">');						
			}
			else
			{
				$('.gray-text-box-image').hide();
			}
		}			
	}			  			  
}

var yellow = "cd-content/themes/markethall/gui/yellow-box.png";
var gray = "cd-content/themes/markethall/gui/gray-box.png";

function onAfter(curr, next, opts) 
{
	$('.slide-box').attr('src', gray);
	$('#' + (opts.currSlide + 1)).attr('src', yellow);			
	$('#home-subtitle').attr('src', 'cd-content/themes/markethall/gui/home-subtitle' + opts.currSlide + '.png');
}
				
$('.text-smaller').click(function() {
	$('body').css('font-size', '76%');
	$.cookie("marketsize", "smaller", { expires: 7 });
});

$('.text-medium').click(function() {
	$('body').css('font-size', '86%');
	$.cookie("marketsize", "medium", { expires: 7 });
});

$('.text-larger').click(function() {
	$('body').css('font-size', '96%');
	$.cookie("marketsize", "larger", { expires: 7 });
});
				
$('#pageid_12').click(function() {
	$('#ul_12').slideToggle();
	$('#ul_14').slideUp();	
});

$('#pageid_14').click(function() {
	$('#ul_14').slideToggle();
	$('#ul_12').slideUp();	
});		
	
$('#slideshow').cycle(
	{ after: onAfter }	
);

$('.slide-box').click(function() {			
	$('#slideshow').cycle(parseInt($(this).attr('id')) - 1);	
	$('.slide-box').attr('src', gray);
	$(this).attr('src', yellow);		
});

$('area').click(function() {
	getData($(this).attr('id'));													
});		

$('document').ready(function() {			   
   $('area').each(function()
   {
	  $(this).qtip(
	  {
		 content: $(this).attr('alt'),
		 style: {
			name: 'dark', 
			border: {
			   width: 0, 
			   radius: 4 
			}, 
			tip: true
		 },
		 position: {
			 target: 'mouse'
		 }
	  });
   });		
});

$('.shop-over-link').hover(function() {
	$('#' + $(this).attr('rel')).mouseover();
}, function() {
	$('#' + $(this).attr('rel')).mouseout();
});

$('.shop-over-link').click(function() {
	getData($(this).attr('rel'));
});

