function goCyworldMain() {
	
	var redirectUrl;
	
	try {
		var name = self.name;
		if(name == "cybody") {
			redirectUrl = "http://cyworld.com/main2/index.asp";
		}
		else {
			var cookieVal = getSubCookie("MAIN", "login%5Fdirection");
			if(!(cookieVal == null || cookieVal == "")) {
				delSubCookie("MAIN", "login%5Fdirection"); 
			}
			redirectUrl = "http://cyworld.com/common/main.asp";
			document.location.target = "_top";
			// sean9304, 2008.7.11
			window.top.location.href = redirectUrl;
			return;
		}
	}
	catch(e) {
		redirectUrl = "http://cyworld.com/main2/index.asp";
	}
	document.location.href = redirectUrl;
}

function getSubCookie(name, subName) {
	var cookieVal = _getCookie(document.cookie, name, ";");
	return _getCookie(cookieVal, subName, "&"); }

function delSubCookie(name, subName) {
	var value = _getCookie(document.cookie, name, ";");
	var cookieVal = getSubCookie(name, subName);
	value = value.replace(subName + "=" + cookieVal, subName + "=");
	_setCookie(name, value, 0, "/", "cyworld.com", ""); }
	
function _getCookie(cookieVal, name, delimiter) {
	if(cookieVal == null || cookieVal.length == 0) {
		return null;
	}
	var start = cookieVal.indexOf(name + "=" );
	var len = start + name.length + 1;
	if((!start ) && (name != cookieVal.substring(0, name.length))) {
		return null;
	}
	if(start == -1) return null;
	var end = cookieVal.indexOf(delimiter, len);
	if(end == -1) end = cookieVal.length;
	
	return cookieVal.substring(len, end);
}		

function _setCookie( 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 + "=" + value +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
