// JavaScript Document
// JavaScript Document
// JavaScript Document
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function getURL(){
	return document.URL;
}
 
var regVisitor = mag_user.user_name;
var regVisitorname = mag_user.first_name;
function cutString(str,num){
  if(str.length > num){
    var newStr = str.substr(0,num);
    newStr += "...";
    str = newStr;
  }
  return(str);
}
regVisitorname = cutString(regVisitorname,12);
var currPos = getURL();

function headerLogin() {
	if (mag_user.logged_in) {
		document.write('<td align="left"><div class="hello" class="season_bg">Hi ');
		document.write(regVisitorname);
		document.write('!</div></td><td width="8"></td><td class="logout button" align="right">');
		document.write('<a href="/registration/logout?next_url=');
		document.write(currPos);
		document.write('">LOGOUT</a></td>');
	}
	else {
		document.write('<td class="login button" align="left"><a href="/login-page/">LOGIN</a></td><td width="8"></td><td class="register button" align="right"><a href="/registration/">REGISTER</a></td>');
	}
}
function headerLogin2() {
	if (mag_user.logged_in) {
		document.write('<div class="hello season_bg">Hi ');
		document.write(regVisitorname);
		document.write('!</div>');
		document.write('<div class="logout button"><a href="/registration/logout?next_url=');
		document.write(currPos);
		document.write('">LOGOUT</a></div>');
	}
	else {
		document.write('<div class="login button"><a href="/login-page/" target="_parent">LOGIN</a></div><div class="register button"><a href="/registration/" target="_parent">REGISTER</a></div>');
	}
}

function headerLogin3() {
	if (mag_user.logged_in) {
		document.write('<div class="divider" style="color:#fff;font-weight:bold;">Hi ');
		document.write(regVisitorname);
		document.write('</div>');
		document.write('<div class="divider" id="header_user_logged_in" style="color:#fff;font-weight:bold;"><a href="/registration/');
		document.write('">Edit Profile</a></div>');
		document.write('<div class="divider" style="border-right: 0px; padding-right: 0; font-weight: bold;"><a href="/registration/logout?next_url=');
		document.write(currPos);
		document.write('">Log Out</a></div>');
	}
	else {
		document.write('<div class="divider"><a href="/login-page/"><strong>Login</strong></a></div>');
        document.write('<div class="divider" style="border-right: 0px; padding-right: 0;"><a href="/registration/"><strong>Register</strong></a></div>');
	}
}

function commentsLogin() {
	document.write('<input type="hidden" value="')
	document.write(currPos);
	document.write('" name="next_url" />');
}

function commentsLoginUsername() {
	if (regVisitor == null) {
	}
	else {
		document.write(regVisitor);
	}
}

function CommunityMenuTout() {
	if (mag_user.logged_in) {
		document.write('<div id="personal" class="menu_list"><div id="welcome">Welcome Back, ');
		document.write(regVisitorname);
		document.write('!</div><a href="/community/pm/" target="_parent"><img src="/cm/marieclaire/images/v01/blt_comm_menu_');
		document.write(season);
		document.write('.gif" />Messages <span id="profile_new_message_count">');
		document.write('(');
		document.write(mag_user.private_messages_count);
		document.write(')');
		document.write('</span></a>');
		document.write('<a href="/community/profile/#friend_requests_all" target="_parent"><img src="/cm/marieclaire/images/v01/blt_comm_menu_');
		document.write(season);
		document.write('.gif" />Requests ');
		document.write('(');
		document.write(mag_user.friends_requests_count);
		document.write(')');	
		document.write('</a>');
		document.write('<a href="/community/guestbook/" target="_parent"><img src="/cm/marieclaire/images/v01/blt_comm_menu_');
		document.write(season);
		document.write('.gif" />Guestbook <span id="profile_new_message_count">');
		document.write('(');
		document.write(mag_user.guestbook_comments_count);
		document.write(')');
		document.write('</span></a>');
		document.write('<a href="/community/profile/" target="_parent"><img src="/cm/marieclaire/images/v01/blt_comm_menu_');
		document.write(season);
		document.write('.gif" />My Profile</a></div><img class="list_bottom" src="/cm/marieclaire/images/v01/bg_comm_menu_b1.gif" />');
		document.write('<div id="community_navigation" class="menu_list"><a href="/community/forums/" target="_parent"><img src="/cm/marieclaire/images/v01/blt_comm_menu_');
		document.write(season);
		document.write('.gif" />Forums</a>');
		document.write('</div>');
	}
	else {
		document.write('<div id="community_navigation" class="menu_list"><div id="login_buttons"><a href="/login-page/" target="_parent">Login</a><a href="/registration/" target="_parent">Register</a></div><a href="/community/forums/" target="_parent"><img src="/cm/marieclaire/images/v01/blt_comm_menu_');
		document.write(season);
		document.write('.gif" />Forums</a>')
		document.write('</div>');
	}
}		

var loggedInNow = null;

if (regVisitorname && regVisitor) {
	loggedInNow = true;
} else {
	loggedInNow = false;	
}