function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
	var path = "; path=/";
	//var domain = '; domain=http://www.artsagenda.co.uk';
    document.cookie = name+"="+value+expires+path;
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
 
/******************** FONT SIZE CHANGING ********************/

var originalFontSize = null;
// Reset Font Size
originalFontSize = $('html').css('font-size');
originalFontSize = parseFloat(originalFontSize, 9);
function original(){
    $("body").css('font-size','1.0em');
	$("body").css('line-height','16px');
	$("h5").css('line-height','1em');
	if(typeof(current_item_id) != 'undefined') {
		newheight = $("li[jcarouselindex='" + current_item + "']").height();
		$(current_item_id).animate({
				height: newheight
			}, 200);
	}
    createCookie("cookieFontSize","original",30);
    return false;
}
 
 
function bigger(){
    $("body").css('font-size','1.2em');
	$("body").css('line-height','18px');
	
	if(typeof(current_item_id) != 'undefined') {
		newheight = $("li[jcarouselindex='" + current_item + "']").height();
		$(current_item_id).animate({
				height: newheight
			}, 200);
	}
    createCookie("cookieFontSize","bigger",30);
    return false;
}
 
function biggest(){
    $("body").css('font-size','1.5em');
	$("body").css('line-height','22px');
    $("h5").css('line-height','1em');
	if(typeof(current_item_id) != 'undefined') {
		newheight = $("li[jcarouselindex='" + current_item + "']").height();
		$(current_item_id).animate({
				height: newheight
			}, 200);
	}
	createCookie("cookieFontSize","biggest",30);
    return false;
}
 
function setTextSize(){
	
    var currentFontSize = readCookie("cookieFontSize");
    if (currentFontSize == "original")
        original();
    else if (currentFontSize == "bigger")
        bigger();
    else if (currentFontSize == "biggest")
        biggest();
}

$(document).ready(function(){
    $('.img_box').hover(function(){
        $(".image_description", this).stop().animate({
            top:'120px'
        },{
            queue:false,
            duration:160
        });
    }, function() {
        $(".image_description", this).stop().animate({
            top:'180px'
        },{
            queue:false,
            duration:160
        });
    });
});

$(document).ready(function(){
    var links	= $(".social_link");
    links.each(function() {
        // console.log($(this).attr('href'));
        $(this).click(function(){
            // open in js popup
            window.open($(this).attr('href'));
            return false;
        });
    });
});
 
$(document).ready(function() {
    $("a.admin_area2").fancybox({
        'width'			: '70%',
        'height'			: '90%',
        'autoScale'                 : false,
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'type'			: 'iframe'

    });

});
 
$(document).ready(function() {
    $("a.widget_admin_area").fancybox({
        'padding'			: 10,
        'margin'			: 20,
        'autoDimensions'			: true,
        'autoScale'                 : false,
        'width'                     : 'auto',
        'height'        			: 'auto',
        'transitionIn'              : 'none',
        'transitionOut'             : 'none',
        'showCloseButton'           : false
    });
});
 
$(document).ready(function() {
    $("a.mailing_list").fancybox({
        'onClosed' : function() {
            $("#login_error").hide();
            // delete validation info
            $(".formErrorContent").detach();
            $(".formErrorArrow").detach();
        }
    }); 
});

