 /*  ESPN open/close and Breaking news button script start */



 /*Start of Breaking news Cookie detection code*/
 
//create cookie
function createCookie( name, value, expires, path, domain, secure ) {

    var today = new Date();

    today.setTime( today.getTime() );
    if ( expires ) {
        expires = expires * 1000 * 60 * 60 * 24;
     }

     var expires_date = new Date( today.getTime() + (expires) );

     document.cookie = name+'='+escape( value ) +
                       ( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) +
                       ( ( path ) ? ';path=' + path : '' ) +
                       ( ( domain ) ? ';domain=' + domain : '' ) +
                       ( ( secure ) ? ';secure' : '' );
}
//check if cookie defined
function readCookie(name) {

    var start = document.cookie.indexOf( name + "=" );
    var len = start + name.length + 1;

    if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
       return null;
    }

    if ( start == -1 ) return null;
    var end = document.cookie.indexOf( ';', len );
    if ( end == -1 ) end = document.cookie.length;
    return unescape( document.cookie.substring( len, end ) );
}
//Remove cookie
function deleteCookie(  name, path, domain) {
    if ( readCookie( name ) )
        document.cookie = name + '=' + ( ( path ) ? ';path=' + path : '') + ( ( domain ) ? ';domain=' + domain : '' ) + ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}
//Get the domain name
function getDomainName () {
    var hostname = window.location.hostname.split('.');
    if ( hostname.length >= 2 ) {
        var len = hostname.length;
        var domainname = '.' +  hostname[len - 2] + '.' + hostname[len - 1];
    } else {
        var domainname = '.' + window.location.hostname;
    }
    return domainname;
}

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

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;
}

var cqanswer = GetCookie("F1_CQ_country");
if (cqanswer == null){
	cqanswer = GetCookie("Q_espnf1_country");
	if (cqanswer == null){
		cqanswer = '';
	}
	else if (cqanswer == 'unknown'){
		cqanswer = 'unknown';
	}
	else if (cqanswer == 'gb'){
		cqanswer = 'uk';
	}
}


/* End Cookie detection code */

