// File:	Cookies.js
// Author:	public domain
// Created:	Piyush Dinker Pandya
//
// Functions:	getCookieVal()
//		SetCookie()
//		GetCookie()
//		DeleteCookie()
//		FixCookieDate()

// ------------------------------------------------------------------------------------------
// NAME:	getCookieVal()
// FUNCTION:	This function retrieves the value of a cookie specified by 'offset'.
// AUTHOR:	unknown
// CREATED:	
// PARAMETERS:	offset
// ------------------------------------------------------------------------------------------
function getCookieVal (offset) { 
  	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1) 
		endstr = document.cookie.length; 
	return unescape(document.cookie.substring(offset, endstr)); 
}

// ------------------------------------------------------------------------------------------
// NAME:	SetCookie()
// FUNCTION:	This function sets the value of a cookie.
// AUTHOR:	unknown
// CREATED:	
// PARAMETERS:	offset
// ------------------------------------------------------------------------------------------
function SetCookie (name,value,expires,path,domain,secure) { 

	document.cookie = name + "=" + escape (value) + 
	((expires) ? "; expires=" + expires.toGMTString() : "") + 
	((path) ? "; path=" + path : "") + 
	((domain) ? "; domain=" + domain : "") + 
	((secure) ? "; secure" : ""); 

}

// ------------------------------------------------------------------------------------------
// NAME:	GetCookie()
// FUNCTION:	This function retrieves the value of a cookie specified by 'offset'.
// AUTHOR:	unknown
// CREATED:	
// PARAMETERS:	offset
// ------------------------------------------------------------------------------------------
function GetCookie (name) { 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	
	while (i < clen) { 
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg) 
			return getCookieVal (j); 
		i = document.cookie.indexOf(" ", i) + 1; 
		if (i == 0) break;
	}
	return null;
}

// ------------------------------------------------------------------------------------------
// NAME:	DeleteCookie()
// FUNCTION:	This function retrieves the value of a cookie specified by 'offset'.
// AUTHOR:	unknown
// CREATED:	
// PARAMETERS:	offset
// ------------------------------------------------------------------------------------------
function DeleteCookie (name) { 
	var exp = new Date(); 
	// Set the cookie values to the choices selected.
	var expdate = new Date (); 
	expdate.setTime (expdate.getTime() - 1); 
	FixCookieDate (expdate); 
	SetCookie(name, "", expdate, "/");
} 

// ------------------------------------------------------------------------------------------
// NAME:	FixCookieDate()
// FUNCTION:	This function retrieves the value of a cookie specified by 'offset'.
// AUTHOR:	unknown
// CREATED:	
// PARAMETERS:	offset
// ------------------------------------------------------------------------------------------
function FixCookieDate (date) { 
	var base = new Date(0); 
	var skew = base.getTime();
	if(skew > 0)
		date.setTime (date.getTime() - skew);     
} 

// ------------------------------------------------------------------------------------------
// NAME:	CheckURL()
// AUTHOR:	Piyush Dinker Pandya
// CREATED:	10/22/00
// PARAMETERS:	offset
// ------------------------------------------------------------------------------------------
function checkURL() {

	currentURL = window.location.href;
	if (currentURL.search("abcdproductions") != -1 ) {
		window.location.href = "http://www.AmericanDesiMovie.com/NotFound.htm";
		if (navigator.appName != "Netscape") {
			history.go(0);
		}

	} 
}


function delcook() {
	DeleteCookie("ABCD2ADInform");
}

function oldstuff() {
	// alert("Attention Movie Fan!\n\nPlease note that the film formerly known as 
	// 'American Born Confused Desi'\nhas changed its title and is now called 'American 
	// Desi'.\n\nYou will now be redirected to the film's new website at\n\n 
	// http://www.AmericanDesiMovie.com/\n\nPlease update your bookmarks accordingly for 
	// future reference and\nthank you for your continued support of independent South 
	// Asian films.");


}
