function writeSessionCookie(cookieName, cookieValue) {
  if (testSessionCookie()) {
    var domain="";
    if(location.hostname.indexOf("ichotelsgroup.com")!=-1){
        domain="domain=ichotelsgroup.com; ";
    }
    document.cookie = escape(cookieName) + "=" + escape(cookieValue) + "; "+domain+" path=/";
    return true;
  }
  else return false;
}
function getCookieValue(cookieName) {
  var exp = new RegExp (escape(cookieName) + "=([^;]+)");
  if (exp.test (document.cookie + ";")) {
    exp.exec (document.cookie + ";");
    return unescape(RegExp.$1);
  }
  else return false;
}
function testSessionCookie() {
  document.cookie ="testSessionCookie=Enabled";
  if (getCookieValue ("testSessionCookie")=="Enabled")
    return true 
  else
    return false;
}

function getFlashSound() {
	var onoff = getCookieValue('soundCookie')
	if (onoff==false) {
		return "on";
	}	
	return onoff;
}
function setFlashSound(onoff) {
	writeSessionCookie('soundCookie',onoff);
}
function checkHaikuFlash() {
	var val = getCookieValue("haikuFlash");
	if (val!=null && val!="hide") {
		var nvdiv = document.getElementById("intro");
		nvdiv.innerHTML = "";
		nvdiv.innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='435' height='285' title='intro'>" +
		"<param name='src' value='intro.swf' />" + 
		"<param name='WMode' value='transparent' />" + 
		"<param name='FlashVars' value='soundCookie="+getFlashSound()+"'/>" + 
		"<embed src='intro.swf' WMode='transparent' pluginspage='http://www.macromedia.com/shockwave/download/' FlashVars='soundCookie="+getFlashSound()+"' width='435' height='285'></embed></object>";
	}
} 
