var debugDomainName = "";

function debugDomain() {
	var currentDomain = "" + document.location;
	if (currentDomain.indexOf("cbsstatic.dev.drt.cbsig.net") != -1) {
		currentDomain = "cbsstatic.dev.drt.cbsig.net";
	} else if (currentDomain.indexOf("stage.drt.cbsig.net") != -1) {
		currentDomain = "stage.drt.cbsig.net";
	} else if (currentDomain.indexOf("cbs.drt.cbsig.net") != -1) {
		currentDomain = "cbs.drt.cbsig.net";
	} else {
		currentDomain = ".cbs.com";	
	}
	debugDomainName = currentDomain; 
}

debugDomain(); 

function writePersistentC(cookieName, cookieValue, periodType, offset)    { 
    document.cookie = cookieName+"="+cookieValue+";expires=Fri, 21 Dec 1976 04:31:24 GMT;domain="+debugDomainName+";path=/;";
}      

function deleteC(cookieName) {
    writePersistentC(cookieName,"removeCookie","years", -1);  
    return true;     
}

function rewriteCookie(cookieName, cookieValue) {
	document.cookie = cookieName+"="+cookieValue+";domain="+debugDomainName+";path=/";
}

function getCookieV(cookieName) {
    var exp = new RegExp(escape(cookieName) + "=([^;]+)");
    
	if( exp.test(document.cookie + ";") )    {
        exp.exec(document.cookie + ";");
        return unescape(RegExp.$1);
    }
  	else    {
		return false;
	}
}

function DelCookie(cookie_name)	{
	if( getCookieV(cookie_name) )    {
	    document.cookie = cookie_name + "=; expires=Fri, 21 Dec 1976 04:31:24 GMT;path=/";
		//document.cookie = cookie_name + "=; expires=Fri, 21 Dec 1976 04:31:24 GMT;domain="+debugDomainName+";path=/;";
	}
}

function DelCookie2(cookie_name)	{
	document.cookie = cookie_name + "=; expires=Fri, 21 Dec 1976 04:31:24 GMT;domain="+debugDomainName+";path=/;";
}