var ShinobiCookie = {

set: function (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 = "";
}

document.cookie = name + "=" + value + expires + "; path=/";
},

get: function (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;
},

clear: function (name)
{
createCookie(name, "", -1);
}
};

var ShinobiURL = {

getParams: function()
{
var url = document.location.href.split('#/');

if(!ShinobiUtils.isEmpty(url[1]))
{
return url[1].split('/');
} else {
return false;
}
},

setParams: function(string)
{
document.location.href = '#' + string;
}
};

var ShinobiUtils = {

/*
 * Validates an Email address
 */
isEmail: function(str)
{
var re = /^.+@.+\..{2,3,4,6}$/;

if (!(re.test(str)))
{ 
       return false;
} else {

var chr = /[\(\)\<\>\,\;\:\\\/\"\[\]]/;

if (str.match(chr))
{
return false;
} else {
return true;
}
}
},

/*
 * Validates if variable is empty
 */
isEmpty: function(str)
{
if(str == null || str == undefined || str == '' || str == ' ')
{
return true;
} else {
return false;
}
},

/*
 * Validates a UK postcode
 */
isUKPostcode: function(str)
{
re = /^((GIR 0AA)|(TDCU 1ZZ)|(ASCN 1ZZ)|(BIQQ 1ZZ)|(BBND 1ZZ)|(FIQQ 1ZZ)|(PCRN 1ZZ)|(STHL 1ZZ)|(SIQQ 1ZZ)|(TKCA 1ZZ)|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW])[0-9][ABD-HJLNP-UW-Z]{2})$/;
if(re.test(str))
{
return true;
} else {
return false;
}
}
};
