/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


Array.prototype.contains = function contains(element) 
{
    for (var i = 0; i < this.length; i++) 
    {
        if (this[i] == element) 
        {
            return true;
        }
    }
    return false;
};
      
Array.prototype.unique=function()
{
    var a=[],i;
    this.sort();
    for(i=0;i<this.length;i++)
    {
        if(this[i]!==this[i+1])
        {
            a[a.length]=this[i];
        }
    }
    return a;
}
 
/* Returns the index of the element matched from the behind */
Array.prototype.lastIndexOf=function(n)
{
    var i=this.length;
    while(i--)
    {
        if(this[i]===n)
        {
            return i;
        }
    }
    return -1;
}

/* Shuffles the Array elements randomly */
 Array.prototype.shuffle=function()
 {
     var i=this.length,j,t;
     while(i--)
     {
         j=Math.floor((i+1)*Math.random());
         t=arr[i];
         arr[i]=arr[j];
         arr[j]=t;
     }
 }
 
 
 /* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

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 = "";
	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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}



