﻿// JScript File

//function set_cookie(cookie_name, cookie_value, cookie_expire, cookie_path, 
//          cookie_domain, cookie_secure) {

//  // Begin the cookie parameter string
//  var cookie_string = cookie_name + "=" + cookie_value
//  
//  // Add the expiration date, if it was specified
//  if (cookie_expire) {
//    var expire_date = new Date()
//    var ms_from_now = cookie_expire * 24 * 60 * 60 * 1000
//    expire_date.setTime(expire_date.getTime() + ms_from_now)
//    var expire_string = expire_date.toGMTString()
//    cookie_string += "; expires=" + expire_string
//  }
//  
//  // Add the path, if it was specified
//  if (cookie_path) {
//    cookie_string += "; path=" + cookie_path
//  }

//  // Add the domain, if it was specified
//  if (cookie_domain) {
//    cookie_string += "; domain=" + cookie_domain
//  }
//  
//  // Add the secure Boolean, if it's true
//  if (cookie_secure) {
//    cookie_string += "; true"
//  }
//  
//  // Set the cookie
//  document.cookie = cookie_string

//}

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);
}