<!--//

/* ####################### start set cookie  ####################### */

function setNoEscapeCookie(name, value, expires, path, domain, secure) {

  var thisCookie = name + "=" + value +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = thisCookie;
}


function setCookie(name, value, expires, path, domain, secure) {
var exdate=new Date();
exdate.setDate(exdate.getDate()+30)


  var thisCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + exdate : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = thisCookie;
}
/* ####################### start show cookie ####################### */

function showCookie(){

alert(unescape(document.cookie));
}
/* ####################### start get cookie value ####################### */

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
/* ####################### end get cookie value ####################### */

}
/* ####################### start get cookie (name) ####################### */

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;
}
/* ####################### end get cookie (name) ####################### */

/* ####################### start delete cookie ####################### */
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
/* ####################### end of delete cookie ####################### */


/* ####################### start setSubCookieAndCookie ####################### */
function setSubCookieAndCookie(cookieName, subCookieName, subCookieValue)
{
	var cookieValue = GetCookie(cookieName);
	if (cookieValue == null) {
		cookieValue = "";
	}
	if(cookieValue.length ==0) {
		cookieValue = subCookieName + '=' + subCookieValue;
	}
	else {
		var posStart = cookieValue.indexOf(subCookieName + '=');
		var posEnd = cookieValue.indexOf('&', posStart+1);
		if (posEnd == -1) {
			posEnd = cookieValue.length;
		}
		if (posStart >= 0 && posEnd > 0) {
			cookieValue = cookieValue.substring(0, posStart) +
			subCookieName + '=' + subCookieValue +
			cookieValue.substring(posEnd, cookieValue.length);
			}
		else {
			if (cookieValue.length > 0){
				cookieValue = cookieValue + '&' + subCookieName + '=' + subCookieValue;
				}
			}
		
	}
	setNoEscapeCookie(cookieName, cookieValue);
}

function myCustomAlert()
{
	alert("myCustomAlert");
}
/* ####################### end setSubCookieAndCookie ####################### */

/* ####################### start GetSubCookie ####################### */
function GetSubCookieValue(cookieName, subCookieName)
{
	var cookieValue = GetCookie(cookieName);
	if (cookieValue != null)
	{
		if (cookieValue.length > 0)
		{
			var arrSubCookies = cookieValue.split('&');
			for(var i = 0; i < arrSubCookies.length; i++)
			{
				if (arrSubCookies[i].indexOf(subCookieName) == 0)
				{
					return arrSubCookies[i].substring(subCookieName.length+1,arrSubCookies[i].length);
				}
			}
		}
	}
	return null;	
}
/* ####################### end GetSubCookie ####################### */
//-->

