﻿function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// Used to prevent multiple submit button clicks
clickcounter = 0;
function NoRepeat() {
	if(clickcounter == 1) { return false; }
	clickcounter = 1;
	return true;
}

// ---------------------------
// function to prevent email being spidered
function noEspam(theName, theDomain, theLink) {
	if (theLink.length ==0){
		theLink = theName + '@' + theDomain
	}
	document.write('<a href="mailto:' + theName + '@' + theDomain + '">' + theLink + '</a>')
}

// FCKEditor now supports this, using this funcion
function mto(domain,name,subject,body) {
  location.href = 'mailto:' + name + '@' + domain + '?subject=' + subject + '&body=' + body;
}

function setSelected() {

    $("#nav a").removeClass("selected");

    if ((window.location.pathname == "/scotlands-favourites/add.aspx")) {
        $(".n03 a").addClass("selected");
        return;
    }
    
    
    $("#nav a").each(function() {
        if ((window.location.pathname + "").indexOf($(this).attr("href")) == 0) {
            $(this).addClass("selected");
        }
    });

}


function setDays() {

    var startDate = new Date;
    var endDate = "2009/11/30";
    var one_day = 1000 * 60 * 60 * 24;

    var daysLeft = (Date.parse(endDate) - startDate) / one_day;
    
    if (daysLeft > 0)
        $(".days").html(parseInt(daysLeft) + 1);
    else
        $(".days").html(parseInt(daysLeft));

}

function setCheckbox() {

    $("label.checkbox").click(function() {
        if($(this).hasClass("tick"))
        {            
            $(this).removeClass("tick");
            $(this).addClass("cross");
        }
        else {
            $(this).removeClass("cross");
            $(this).addClass("tick");
        }
    });
}
