/* Author: Alastair Campbell webmaster@ukwindsurfing.com for the UKWA */

// Site variables for use in the functions
var ukwa = {
    "domain" : "http://ukwindsurfing.com",
    "linkify" : [
        {
         "box" : ".content article",
         "alink" : "h3 a"   
        },
        {
         "box" : ".links-list li",
         "alink" : "h3 a"   
        },
        {
         "box" : ".relatedbox .vevent",
         "alink" : "a.summary"
        }
    ] 
};


// link up the boxes
function linkBoxes() {
    
    // for each type of box we're linking up.
    for (j in ukwa.linkify) {
        
        // grab each article / link type thing
        var boxes = $(ukwa.linkify[j].box);
        
        // for each box, link it up and add a class
        $(boxes).each(function(i) {
            var box = boxes[i];
            var link = $(ukwa.linkify[j].alink, box).attr('href');
            //console.log(link);
			if (link) {
	           $(box).click(function() {
	               location.href = link;
	           });
	           $(box).addClass("linkify");
			}
        });
    }
}


// Functions to call on DOM ready.
$(document).ready(function() {
	linkBoxes();
});
