function pointycursor () {
	document.body.style.cursor='pointer';
}

function normalcursor () {
	document.body.style.cursor='default';
}

// JScript File
var qTipTag = "a"; //Which tag do you want to qTip-ize? Keep it lowercase!//
var qTipX = -30; //This is qTip's X offset//
var qTipY = 25; //This is qTip's Y offset//

//There's No need to edit anything below this line//
tooltip = {
  name : "qTip",
  offsetX : qTipX,
  offsetY : qTipY,
  tip : null
}

tooltip.init = function () {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = "qTip";}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}

	if (!document.getElementById) return;
	this.tip = document.getElementById (this.name);
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};

	var a, sTitle, sNotip;
	var anchors = document.getElementsByTagName (qTipTag);

	for (var i = 0; i < anchors.length; i ++) {
		a = anchors[i];
		sTitle = a.getAttribute("title");
		sNotip = a.getAttribute("rel");
		if(sTitle && (sNotip != 'notip')) {
			a.setAttribute("tiptitle", sTitle);
			a.removeAttribute("title");
			a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))};
			a.onmouseout = function() {tooltip.hide()};
		}
	}
}

tooltip.move = function (evt) {
	var x=0, y=0;
	if (document.all) {//IE
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
		
	} else {//Good Browsers
		x = evt.pageX;
		y = evt.pageY;
	}
	this.tip.style.left = (x + this.offsetX) + "px";
	this.tip.style.top = (y + this.offsetY) + "px";
}

tooltip.show = function (text) {
	if (!this.tip) return;
	this.tip.innerHTML = text;
	this.tip.style.display = "block";
}

tooltip.hide = function () {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";
}


function toggle_disable(obj)
{
   if(obj.checked == true)
   {
                        toggleBox('disable_upload',0);
   }
   else
   {
                        toggleBox('disable_upload',1);
   }
}

	

function hideBox(szDivID, iState) // 1 visible, 0 hidden

{

	if(document.layers)	   //NN4+
	{
			   document.layers[szDivID].visibility = iState ? "show" : "hide";
	}
	else if(document.getElementById)	  //gecko + IE 5+
	{
		var obj = document.getElementById(szDivID);
		obj.style.visibility = iState ? "visible" : "hidden";
	}
	else if(document.all)	// IE 4
	{
		document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
	}

}

function smartToggleBox(szDivID)
{
	if(document.getElementById)         //gecko + IE 5+
    {
    	var obj = document.getElementById(szDivID);
    	if(obj.style.display == "block")
			toggleBox(szDivID, 0);
		else
			toggleBox(szDivID, 1);
    }   	
}

function displayDescription(description, ignoreLength)
{
	if (ignoreLength == 1)
	{
		var desc_text = description;
		desc_text += "&nbsp;<a href='javascript:displayDescription(desc_fulltext, 0);' class='gen_link'>less</a>";
		document.getElementById("description_content").innerHTML = desc_text;
	}
	else
	{
		if(description.length <= 210)
		{
		    if (document.getElementById("description_content")){
			    document.getElementById("description_content").innerHTML = description;
			}
		}
		else
		{
			var desc_text = description.substring(0, 210);
			desc_text += "&nbsp;<a href='javascript:displayDescription(desc_fulltext, 1);' class='gen_link'>more</a>";
			document.getElementById("description_content").innerHTML = desc_text;
		}
	}
}


//if the combination of  keyword strings is > then 80 chars we cut off the string. 
function truncateKeyWords()
{
	if(sKeywordString != null)
	{
		
		var keyWordArray=sKeywordString.split(',');
		var maxStringLength = 80;
		var result="";
		var i;
		var runningLength=0;
		var keyword = "";
		var keyWordLength;
		
		  for (i=0; i<keyWordArray.length; i++)
		  {
			keyword = keyWordArray[i];
			keyWordLength  = keyword.length;
			
			if((runningLength + keyWordLength)  < maxStringLength)
			{
			  
			  result += "<a href=\"http://break.com/tags/"+keyword+"\" class=\"gen_link\">";
			  //result += "<a href=\"http://my.break.com/Content/Search/Search.aspx?SearchString="+keyword+"&amp;SearchType=TagsOnly\" class=\"gen_link\">";
			  result += keyword;
			  result += "</a> ";
	
			  runningLength = runningLength + keyWordLength;
			}
			
		   }
		   return result;
	}
	else
	{
		return "";
	}
}



//Gets the query variable
//Borrowed from http://www.idealog.us/2006/06/javascript_to_p.html
function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
	return null;
} 

function getLoggedInMemberId () {
			var memberId = document.cookie;
			var index = memberId.search (/MemberId=/gi);
			if (index != -1) {
			memberId = memberId.substr (index+9, memberId.length);
			index = memberId.search (/;/gi);
			if (index != -1)
				memberId = memberId.substr (0, index);
				return memberId;
			}
	return null;
}

//For random video dice
function ranover(divid,imgid)
{
    toggleBox(divid,1);
    document.getElementById(imgid).src = "http://media1.break.com/static/live/v1/img/header/dice.gif"; 
}

function ranout(divid,imgid)
{
    toggleBox(divid,0);
    document.getElementById(imgid).src = "http://media1.break.com/static/live/v1/img/header/dice_single.gif"; 
}

/*
 * Clear Default Text: functions for clearing and replacing default text in
 * <input> elements.
 */
 
var defaultSearchText = "Videos and More"; 
 
function initSearchBox() {
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];
        
        if (theInput.className.match(/\bsearch\b/)) {  
            theInput.style.color = '#9a9a9a';
            if (theInput.value == "")
			{
				theInput.value = defaultSearchText
			}
			else
				defaultSearchText = theInput.value
            /* Add event handlers */          
            addEvent2(theInput, 'focus', clearDefaultText, false);
            addEvent2(theInput, 'blur', replaceDefaultText, false);
            
            /* Save the current value, make sure to keep search text if text already exists */
            if (theInput.value == "") {  
                theInput.defaultText = defaultSearchText;
            }
        }
    }
}

function clearDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == defaultSearchText) {
	  target.style.color = '#000000';
        target.value = '';
    }
}

function replaceDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
	
    if (!target) return;
    
    if (target.value == '' && defaultSearchText) {
        target.style.color = '#9a9a9a';
        target.value = defaultSearchText;
    }
}

function addEvent2(element, eventType, lamdaFunction, useCapture) {
    if (element.addEventListener) {
        element.addEventListener(eventType, lamdaFunction, useCapture);
        return true;
    } else if (element.attachEvent) {
        var r = element.attachEvent('on' + eventType, lamdaFunction);
        return r;
    } else {
        return false;
    }
}

//addEvent2(window, 'load', initSearchBox, false);

/**
 * @author tlee
 ajaxbase.js is required
 This js is for the login status control
 */

function StatusBreakJSON(){
    counter = 1;
    this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
    this.head = document.getElementsByTagName("head").item(0);
    this.scriptId = 'JscriptId' + counter++;    

    StatusBreakJSON.prototype.sendBegin = function(url, callback){      
        url += (url.indexOf("?") == -1) ? "?callback=" : "&callback=";
        url += callback;
        url += this.noCacheIE;
        this.script = document.createElement("script");
        this.script.setAttribute("type", "text/javascript");
        this.script.setAttribute("charset", "utf-8");
        this.script.setAttribute("src", url);
        this.script.setAttribute("id", this.scriptId);
        this.head.appendChild(this.script);
    }
}

var	loginstatus_ckMemberAuthentication;
var	loginstatus_ckNewMessageCount;
var	loginstatus_ckNickname;
var	loginstatus_etLoginStatus; 
var	loginstatus_etStatusMessage;
var	loginstatus_personalUrl;
var	loginstatus_loginUrl;
var	loginstatus_logoutUrl;
var	loginstatus_registerUrl;
var	loginstatus_myMessageUrl;
var	loginstatus_cookieSecExpire;
var loginstatus_isBreakLinux;

function VarsInit()
{
	loginstatus_ckMemberAuthentication = "MemberAuthentication";
	loginstatus_ckNewMessageCount = "NewMessageCount";
	loginstatus_ckNickname  = "Nickname";
	loginstatus_etLoginStatus = "login_status"; 
	loginstatus_etStatusMessage = "status_message";
	loginstatus_personalUrl = "http://my.break.com/Member/Profile/mypage.aspx?MemberNickName=";
	loginstatus_loginUrl = "http://my.break.com/Member/Authentication/login.aspx";
	loginstatus_logoutUrl = "http://my.break.com/Member/Authentication/Logout.aspx";
	loginstatus_registerUrl = "http://my.break.com/Member/Authentication/Registration.aspx";
	loginstatus_myMessageUrl = "http://my.break.com/Member/Profile/MyMessage.aspx";
	loginstatus_cookieSecExpire = 300;
	loginstatus_isBreakLinux = false;
}

function MemberSummaryInit()
{
    VarsInit();	
    if(GetCookie(loginstatus_ckMemberAuthentication) != "")
    {
        var DataVal = GetCookie("MemberData");
        if(DataVal == "")
        {
            AuthRedirect();   
        }
        else
        {
           //PopulateData();
        }
    }
    else
    {
	   // document.getElementById(loginstatus_etLoginStatus).innerHTML = RenderGuestLoginStatus();
    }
}

//Get the message count directly from ws
function SetMessageCount(msgCount)
{
    VarsInit();
    if(GetCookie(loginstatus_ckMemberAuthentication) != "")
    {
        var DataVal = GetCookie("MemberData");
        if(DataVal != "")
        {
            var memberId = getMemberId();
            if(memberId.length > 0) // cookie existed
            {
                var nickname = GetNicknameFromCookie();
                if(loginstatus_isBreakLinux == true)
                {
	                //document.getElementById(loginstatus_etLoginStatus).innerHTML = RenderLoggedInUserStatus(nickname, -1);
                }
                else
                {
                   // document.getElementById(loginstatus_etLoginStatus).innerHTML = RenderLoggedInUserStatus(nickname, msgCount);
                    SetCookie(loginstatus_ckNewMessageCount, msgCount, SecondsFromNow(loginstatus_cookieSecExpire));
                }
            }
            else					// cookie not existed
            {
                // use just see guest login
                //document.getElementById(loginstatus_etLoginStatus).innerHTML = RenderGuestLoginStatus();
            }
        }
    }
    else
    {
	   // document.getElementById(loginstatus_etLoginStatus).innerHTML = RenderGuestLoginStatus();
    }
}


function getMemberId()
{
    var result = "";
    var cookie = document.cookie;
    var index = cookie.search(/MemberID=/gi);
    if(index >= 0)
    {
        mid = cookie.substr(index+9, cookie.length);
	    index = mid.indexOf(";");
	    if(index >= 0)
	        result = mid.substr(0, index);
	    else
	        result = mid;	
	}
	return result;    
}

function GetMessageCountWS(mid)
{ 
    if(mid.length > 0 )
    {   
        var loginstatus_MessageJSON = new StatusBreakJSON(); 
        loginstatus_MessageJSON.sendBegin("http://profile-websvc.break.com/Membership/Handlers/Messages/MessageHandler.ashx?invoke=getmembermessagecount&siteId=1&mid="+mid, "HandleMessageCount");
    }    
}

function HandleMessageCount(jsonData)
{
    if(jsonData && jsonData.Response.Code == 0)
    {
       var content = jsonData.Response.Content;
       if (content)
       {
            document.getElementById(loginstatus_etLoginStatus).innerHTML = RenderLoggedInUserStatus(GetNicknameFromCookie(), content.MessageCount.NewMessageCount);
            SetCookie(loginstatus_ckNewMessageCount, content.MessageCount.NewMessageCount, SecondsFromNow(loginstatus_cookieSecExpire));
       }         
	}
}

function SecondsFromNow(sec)
{
   var dt1 = new Date();
   var dt2 = new Date(dt1.valueOf() + (sec * 1000));
   return dt2.toUTCString();
}

function SetCookie(pCookieName, pCookieValue, pCookieDate)
{
	var theCookie = escape(pCookieName) + "=" + escape(pCookieValue);
	
	if(pCookieDate != null && pCookieDate != "")
	{
		theCookie += ";expires=" + pCookieDate;
	}
	
	// add domain information
	theCookie += ";path=/;domain=" + ".break.com"; 
	
	document.cookie = theCookie; 
}

function getCookie(pCookieName)
{
	var oCookies = document.cookie.split(";");
	
	for(var i = 0; i < oCookies.length; i++)
	{
		var oCookiePair = oCookies[i].split("=");
		var sCookieName = unescape(oCookiePair[0]).replace(" ","");
		var sCookieValue = unescape(oCookiePair[1]);

		if(sCookieName == pCookieName)
		{
			return sCookieValue;
		}
	}
	return "";
}

function GetCookie(pCookieName)
{
	var oCookies = document.cookie.split(";");
	
	for(var i = 0; i < oCookies.length; i++)
	{
		var oCookiePair = oCookies[i].split("=");
		var sCookieName = unescape(oCookiePair[0]).replace(" ","");
		var sCookieValue = unescape(oCookiePair[1]);

		if(sCookieName == pCookieName)
		{
			return sCookieValue;
		}
	}
	return "";
}

function GetNicknameFromCookie()
{
    var oCookies = document.cookie.split(";");
	
	for(var i = 0; i < oCookies.length; i++)
	{
		var oCookiePair = oCookies[i].split("=");
		var sCookieName = unescape(oCookiePair[0]).replace(" ","");
		var sCookieValue = oCookiePair[1];

		if(sCookieName == "MemberData")
		{
		    var d2 = unescape(sCookieValue);
		
			var data = eval('('+d2+')'); 
			return data.Nickname;
		}
	}
	return "";
}

function DeleteCookie(pCookieName)
{
	SetCookie(pCookieName, "", new Date("January 1, 2000"));
}

function AuthRedirect()
{
    window.location = "http://my.break.com/auth.aspx?AppRedirect="+escape(document.location);
}

//-------------IE FIX start-------------//

if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	window.attachEvent("onload", alphaBackgrounds);
}

function alphaBackgrounds(){
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var versionNumber = Number(rslt[1]);
	var itsAllGood = (rslt != null && (versionNumber >= 5.5 && versionNumber < 7));
	
	if (itsAllGood) {
		for (i=0; i<document.all.length; i++){
			var bg = document.all[i].currentStyle.backgroundImage;
			if (bg){
				if (bg.match(/\.png/i) != null){
					var mypng = bg.substring(5,bg.length-2);
					document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='scale')";
					document.all[i].style.backgroundImage = "url('http://media1.break.com/static/live/v1/img/mybreak/shim.gif')";
				}
			}
		}
	}
}

function toggle_disable(obj)
{
   if(obj.checked == true)
   {
                        toggleBox('comment_bot',0);
                        toggleBox('disable_comment_box',1);
   }
   else
   {
                        toggleBox('comment_bot',1);
                        toggleBox('disable_comment_box',0);
   }
}

function toggle_disable2(obj)
{
	if(obj.checked == true)
   {
		toggleBox('comment_bot',1);
		toggleBox('disable_comment_box',0);
   }
   else
   {
		toggleBox('comment_bot',0);
		toggleBox('disable_comment_box',1);
   }
}

function ShowShareBox(){
	var shareBox = document.getElementById("share_box");

	if(shareBox.style.display == "none"){ 
		shareBox.style.display = "block";
	}
	else{
		shareBox.style.display = "none";
	}
}

function ShowBreakAnywhere(){
	var shareBox = document.getElementById("break-anywhere");

	if(shareBox.style.display == "none"){
		shareBox.style.display = "block";
	}
	else{
		shareBox.style.display = "none";
	}
}

var memberCookie = getCookie("MemberActive");
var memberRememberCookie = getCookie("MemberAuthentication");

//alert("session" + memberCookie);
//alert("remember ME" + memberRememberCookie);

function checkingCookies(){
if(document.cookie)
{

}
else{
//window.location="http://info.break.com/static/live/v1/pages/ageverification_gotd.html";
}
}

function checkingCookiesMovies(){
if(document.cookie)
{

}
else{
//window.location="http://info.break.com/static/live/v1/pages/ageverification_movies_nsfw.html";
}
}

function checkingCookiesPictures(){
if(document.cookie)
{

}
else{
//window.location="http://info.break.com/static/live/v1/pages/ageverification_pictures_nsfw.html";
}
}


function logInOut(){
//if((memberCookie || memberRememberCookie) != null) 
//{
//document.getElementById('logInLayer').style.display="none";
//document.getElementById('logOutLayer').style.display="block";
//}
//else{
//document.getElementById('logInLayer').style.display="block";
//document.getElementById('logOutLayer').style.display="none";
//}
}

function memberEnterIn(){
if((memberCookie || memberRememberCookie || cookieOver) != null) 
{

}
else{
window.location="http://info.break.com/static/live/v1/pages/ageverification_gotd.html";
}
}

function memberEnter(){
if((memberCookie || memberRememberCookie) != null) 
{
window.location="http://girls.break.com/";
}
else{
window.location="http://info.break.com/static/live/v1/pages/ageverification_gotd.html";
}
}

function memberEnterBreakingNews(){
if((memberCookie || memberRememberCookie) != null) 
{
window.open("http://girls.break.com/")
}
else{
window.open("http://info.break.com/static/live/v1/pages/ageverification_gotd.html")
}
}


function memberMoviesEnter(){
//if((memberCookie || memberRememberCookie) != null) 
//{
//window.location="http://www.break.com/movies_nsfw/movies_nsfw.html";
//}
//else{
//window.location="http://info.break.com/static/live/v1/pages/ageverification_movies_nsfw.html";
//}
}

function memberMoviesEnterIn(){
//if((memberCookie || memberRememberCookie) == null) 
//{
//window.location="http://info.break.com/static/live/v1/pages/ageverification_movies_nsfw.html";
//}
}


function memberPicturesEnter(){
//if((memberCookie || memberRememberCookie) != null)  
//{
//window.location="http://www.break.com/pictures_nsfw/pictures_nsfw.html";
//}
//else{
//window.location="http://info.break.com/static/live/v1/pages/ageverification_pictures_nsfw.html";
//}
}

function memberPicturesEnterIn(){
//if((memberCookie || memberRememberCookie) == null)  
//{
//window.location="http://info.break.com/static/live/v1/pages/ageverification_pictures_nsfw.html";
//}
}


function memberEnterGotm(){
if((memberCookie || memberRememberCookie) != null) 
{
window.location="http://www.break.com/gotm/gotm.html";
}
else{
window.location="http://info.break.com/static/live/v1/pages/ageverification_gotm.html";
}
}

// Hack for Mac/FF3 css bugs
function cssFix()
{
	BrowserDetect.init();
	if(BrowserDetect.OS == "Mac" && BrowserDetect.browser == "Firefox" && BrowserDetect.version >= 3) {
	  document.write('<style type="text/css">@import "http://media1.break.com/static/app/v1/global/css/ff3mac.css";</style>');
	}
	else if(BrowserDetect.OS == "Mac" && BrowserDetect.browser == "Safari") {
		document.write('<style type="text/css">@import "http://media1.break.com/static/app/v1/global/css/safari.css";</style>');
	}
}

function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );
  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }
  if ( path )
        cookie_string += "; path=" + escape ( path );
  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  if ( secure )
        cookie_string += "; secure";
  document.cookie = cookie_string;
}

function showhotshot (evt) {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = "hotshotcontainer";}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
		
	  tipContainer.innerHTML = "Break Hotshots have, at some point, gotten 100k+ views in 7 days without reaching the home page.";
	  tipContainer.innerHTML += "<br /><br /><div style='text-align:center;'><img src='http://media1.break.com/static/live/v1/img/mybreak/breakpro_logo_med.gif' /><br /><a href='javascript:hidehotshot();'>Close</a></div>";

	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}

	var x=0, y=0;
	if (document.all) {//IE
		//x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		//y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		//x += window.event.clientX;
		//y += window.event.clientY;
		
		x = getRealLeft(window.event.srcElement);
		y = getRealTop(window.event.srcElement);
		
	} else {//Good Browsers
		//x = evt.pageX;
		//y = evt.pageY;
		x = evt.target.x;
		y = evt.target.y;
	}

	//if (window.location == "http://www.break.com/" ||
	    
	//)
	//{
        //	tipContainer.style.left = (x - 200) + "px";
        //}
        //else
        //{
        //	tipContainer.style.left = (x + 200) + "px";
        //}
        tipContainer.style.left = (x + 200) + "px";
        tipContainer.style.top = y + "px";
	tipContainer.style.display = "block";
}

function hidehotshot () {
	document.getElementById("hotshotcontainer").style.display = "none";
}

function pointycursor () {
	document.body.style.cursor='pointer';
}

function normalcursor () {
	document.body.style.cursor='default';
}

function hotshotinit () {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
	if(!tipContainerID){ var tipContainerID = "hotshotcontainer";}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
		
	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}

	tipContainer.innerHTML = "Break Hotshots have, at some point, gotten 100k+ views in 7 days without reaching the home page.";
	tipContainer.innerHTML += "<br /><br /><div style='text-align:center;'><img src='http://media1.break.com/static/live/v1/img/mybreak/breakpro_logo_med.gif' /><br /><a href='javascript:hidehotshot();'>Close</a></div>";
	tipContainer.style.display = "none";

}

function getRealLeft(elem) {
	xPos = eval(elem).offsetLeft;
	tempEl = eval(elem).offsetParent;
  	while (tempEl != null) {
  		xPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
  	}
	return xPos;
}

function getRealTop(elem) {
	yPos = eval(elem).offsetTop;
	tempEl = eval(elem).offsetParent;
	while (tempEl != null) {
  		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
  	}
	return yPos;
}

var currentState;

function SetState(state){
    currentState = escape(state);
}

function GetState(ordinal){
    var returnState = window.location.hash;
	returnState = strip(unescape(returnState));
	var params = returnState.split(",");
	return params[ordinal];
}

function HasState(){
    var testState = window.location.hash;
    if (testState != null){
        if (testState != ""){
                return true;
        }
    }
    else
        return false;
}

function strip(data){
    var result = "";
    var i = 0;
    for(i=0; i<=data.length; i++)
        if(data.charAt(i) != "#")
            result += data.charAt(i);   
    return result
}

function GoTo(url){
    window.location.hash = currentState;
    window.location.href = url;
}

/*
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;
}
 
alert(readCookie("MemberGUID"));
*/


function getCookie( 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 ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = 365 * expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+"="+escape( value ) +
		( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) +
		( ( domain ) ? ";domain=" + domain : ".break.com" ) +
		( ( secure ) ? ";secure" : "" );
}

function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}




var memberCookie = getCookie("MemberActive");
var memberRememberCookie = getCookie("MemberAuthentication");

//alert("session" + memberCookie);
//alert("remember ME" + memberRememberCookie);

function checkingCookies(){
if(document.cookie)
{

}
else{
window.location="http://info.break.com/static/live/v1/pages/ageverification_gotd.html";
}
}

function checkingCookiesMovies(){
if(document.cookie)
{

}
else{
window.location="http://info.break.com/static/live/v1/pages/ageverification_movies_nsfw.html";
}
}

function checkingCookiesPictures(){
if(document.cookie)
{

}
else{
window.location="http://info.break.com/static/live/v1/pages/ageverification_pictures_nsfw.html";
}
}


function logInOut(){
//if((memberCookie || memberRememberCookie) != null) 
//{
//document.getElementById('logInLayer').style.display="none";
//document.getElementById('logOutLayer').style.display="block";
//}
//else{
//document.getElementById('logInLayer').style.display="block";
//document.getElementById('logOutLayer').style.display="none";
//}
}

function isValidReferrer(){             
        var ref = document.referrer;         
        if (jQuery.cookie(safeNsf)){
            return (jQuery.cookie(safeNsf) === "y");
        }             
        if (ref == '') { return false; }
        var searchArr = ["google.com", "adon.com", "yahoo.com", "bing.com", "search.com", "aol.com", "ask.com", "msn.com", "altavista.com", "live.com", "lycos.com", "virgilio.com", "seznam.com", "cnn.com", "alltheweb.com"];
        var len = searchArr.length;
        for (var i=0; i<len; i++){                         
            if (ref.toLowerCase().indexOf(searchArr[i]) !== -1){               
                setNsf("y");
                return true;
            }            
        }        
        setNsf("n"); 
        return false;   
        
    }

function isValidAge(){        
    var d = jQuery.cookie("dob");
    if (!d || d == 'undefined'){ return false; }
    
    var dSplit = d.split(" ")[0].split("/");        
    var uDate = new Date(parseInt(dSplit[2]),(parseInt(dSplit[0])-1),parseInt(dSplit[1]));
    var aDate = new Date().setFullYear(parseInt(new Date().getFullYear()) - 18);             
    return (aDate > uDate);        
}


function verifyNSFW(spicyType, verifiedUrl){
    if (isValidReferrer()) { 
        if (!verifiedUrl) { return; }
        window.location.href = verifiedUrl;
    } /* this user is exempt and can proceed */    
    if (IsLoggedIn()){
        if (isValidAge()){
             if (!verifiedUrl) { return; }
            window.location.href = verifiedUrl;
        }else{ /* Not a valid age */
            if (thirdPartyIsLoggedIntoBreak()){
                /* Go to new age-gate page for 3rd parties */
		        switch (spicyType){
			        case 'spics-link':
			        case 'smovies-link':
			            window.location.href = 'http://info.break.com/static/live/v1/pages/agegateway_nsfw_thirdparty.html';					
				        break;
			        case 'gotd-link':
	                    window.location.href = 'http://info.break.com/static/live/v1/pages/ageverification_cookie_gotd.html';
	                    break;
                    case 'gotm-link':
	                    window.location.href = 'http://info.break.com/static/live/v1/pages/ageverification_cookie_gotm.html';
	                    break; 
	            }           
            }else{  /* Not a valid age, but, they are logged in */
                switch (spicyType){
                    case 'spics-link':
	                    window.location.href = 'http://info.break.com/static/live/v1/pages/agegateway_nsfw.html';					
	                    break;
                    case 'smovies-link':
	                    window.location.href = 'http://info.break.com/static/live/v1/pages/agegateway_nsfw.html';
	                    break;
                    case 'gotd-link':
	                    window.location.href = 'http://info.break.com/static/live/v1/pages/ageverification_cookie_gotd.html';
	                    break;
                    case 'gotm-link':
	                    window.location.href = 'http://info.break.com/static/live/v1/pages/ageverification_cookie_gotm.html';
	                    break;
                }
            } 
        }    
    }else{  /* Not logged in */    
        switch(spicyType) {				
		    case 'spics-link':
            case 'smovies-link':
            case 'gotd-link':
            case 'gotm-link': 	                	               
                showSpicyReg(false);                    			
			    break;
	    }					  
    }
}


function memberEnterIn(){
    verifyNSFW("gotd-link");   
}

function memberEnter(){
    verifyNSFW("gotd-link", "http://girls.break.com/");
}

function memberEnterBreakingNews(){
    verifyNSFW("gotd-link", "http://girls.break.com/");
}

function memberMoviesEnter(){   
    verifyNSFW("smovies-link", "http://www.break.com/movies_nsfw/movies_nsfw.html");
}

function memberMoviesEnterIn(){
    verifyNSFW("smovies-link");
}

function memberPicturesEnter(){
    verifyNSFW("spics-link", "http://www.break.com/pictures_nsfw/pictures_nsfw.html");
}

function memberPicturesEnterIn(){
    verifyNSFW("spics-link");
}

function ReformatImg(id) 
{
	 
        if(document.images["imageResize"].width > 435)
        {
          document.images["imageResize"].width = '435';
        }
		/*		
	    if((document.getElementById("imageResize").style.width = document.images["imageResize"].width) > 435)
	    {
	      document.getElementById('imageResize').style.width = '435';
	    }
	   */
}


/////////////////////////////////////
//Read feedback cookie
/////////////////////////////////////
function readFeedbackCookie(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 "";
}
////////////////////////////////////
// Is Logged In
////////////////////////////////////
function IsLoggedIn()
{       
  var memberCookie = getCookie("MemberActive");
  var memberRememberCookie = getCookie("MemberAuthentication");   
  var memberIdCookie = getCookie("MemberID");
  return (((memberCookie || memberRememberCookie) != null)&&(memberIdCookie != null))? true:false;               
}

// JScript File
function addEvent(obj, evType, fn){
			 if (obj.addEventListener){
				 obj.addEventListener(evType, fn, true);
				 return true;
			 } else if (obj.attachEvent){
				 var r = obj.attachEvent("on"+evType, fn);
				return r;
			 } else {
				return false;
			 }
		}

function emailCheck (emailStr) {
	//alert("inside method: " + emailStr)
	emailStr = emailStr.replace(" ","");
	/* The following pattern is used to check if the entered e-mail address
	   fits the user@domain format.  It also is used to separate the username
	   from the domain. */
	var emailPat=/^(.+)@(.+)$/
	/* The following string represents the pattern for matching all special
	   characters.  We don't want to allow special characters in the address. 
	   These characters include ( ) < > @ , ; : \ " . [ ]    */
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	/* The following string represents the range of characters allowed in a 
	   username or domainname.  It really states which chars aren't allowed. */
	var validChars="\[^\\s" + specialChars + "\]"
	/* The following pattern applies if the "user" is a quoted string (in
	   which case, there are no rules about which characters are allowed
	   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	   is a legal e-mail address. */
	var quotedUser="(\"[^\"]*\")"
	/* The following pattern applies for domains that are IP addresses,
	   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	   e-mail address. NOTE: The square brackets are required. */
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	/* The following string represents an atom (basically a series of
	   non-special characters.) */
	var atom=validChars + '+'
	/* The following string represents one word in the typical username.
	   For example, in john.doe@somewhere.com, john and doe are words.
	   Basically, a word is either an atom or quoted string. */
	var word="(" + atom + "|" + quotedUser + ")"
	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	/* The following pattern describes the structure of a normal symbolic
	   domain, as opposed to ipDomainPat, shown above. */
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


	/* Finally, let's start trying to figure out if the supplied address is
	   valid. */

	/* Begin with the coarse pattern to simply break up user@domain into
	   different pieces that are easy to analyze. */
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
	  /* Too many/few @'s or something; basically, this address doesn't
	     even fit the general mould of a valid e-mail address. */
		//alert("Email address seems incorrect (check @ and .'s)")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	
	//alert("User: " + user)
	//alert("UserPat: " + userPat)
	// See if "user" is valid 
	if (user.match(userPat)==null) {
	    // user is not valid
	    //alert("The username doesn't seem to be valid.")
	    return false
	}

	/* if the e-mail address is at an IP address (as opposed to a symbolic
	   host name) make sure the IP address is valid. */
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
	    // this is an IP address
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
			//alert("Destination IP address is invalid!")
			return false
		    }
	    }
	    return true
	}

	// Domain is symbolic name
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		//alert("The domain name doesn't seem to be valid.")
	    return false
	}

	/* domain name seems valid, but now make sure that it ends in a
	   three-letter word (like com, edu, gov) or a two-letter word,
	   representing country (uk, nl), and that there's a hostname preceding 
	   the domain or country. */

	/* Now we need to break up the domain to get a count of how many atoms
	   it consists of. */
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
	    domArr[domArr.length-1].length>3) {
	   // the address must end in a two letter or three letter word.
	   //alert("The address must end in a three-letter domain, or two letter country.")
	   return false
	}

	// Make sure there's a host name preceding the domain.
	if (len<2) {
	   var errStr="This address is missing a hostname!"
	   alert(errStr)
	   return false
	}

	// If we've gotten this far, everything's valid!
	return true;
}

function UpdateButtonState(strValue,bIsEnabled, sId)
{
	var objBtn = document.getElementById(sId)
	objBtn.value = strValue;
	objBtn.disabled = (bIsEnabled)?false:true;
}
function ClearTextFields(strFieldsArray)
{
	if(strFieldsArray==null ||
		strFieldsArray=="")
		return;
		
	var listOfFields = strFieldsArray.split(",")
	
	if(listOfFields.length==0)
		return;
		
	for(i=0;i<listOfFields.length;i++)
	{
		var frmField = document.getElementById(listOfFields[i]);
		frmField.value = "";		
	} 	
}

function SwapImage(objImg, src)
{
  objImg.src=src;
}
function SwapImage2(objImg, src, objLink, href)
{
  alert(objImg.src)
  alert(objLink);
  objImg.src=src;
  objLink.href= href;
}
   // stop browsers from crashing on errors
   function stopError() {
           return true;
   }
   window.onerror=stopError;
   
//   function(msg, url, linenumber){
//     alert('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber);
//     return true;
//    }
   

function addLoadEvent(func){
   var oldOnload = window.onload;
   
   if(typeof(window.onload) != "function")
      window.onload = func;
   else{
      window.onload = function(){
         if(oldOnload)
            oldOnload();
         func();
      }
   }
}

/**
 * @author ieling
 */

function SetUrlParam(pParamName, pParamValue)
{
	var sQuery = this.window.location.search;
	var sNewQuery= "";
	
	if(sQuery.length > 0)
	{
		sQuery = sQuery.substring(1);
		
		var sParams = sQuery.split("&");
		
		alert("sparam.length: " + sParams.length);
		for(var i = 0; i < sParams.length; i++)
		{
			var sParamPair = sParams[i].split("=");
			sParamName = unescape(sParamPair[0]);
			sParamValue = unescape(sParamPair[1]);
			
			if(sParamName != pParamName)
			{
				sNewQuery += escape(sParamName) + "=" + escape(sParamValue) + "&";
			}
		}
	}
	
	sNewQuery += escape(pParamName) + "=" + escape(pParamValue);
	this.window.location.search  = "?" + sNewQuery;
}

function GetUrlParam(pParamName)
{
	var sParamValue = "";
	var sQuery = this.window.location.search.substring(1);
	if(sQuery.length > 0)
	{
		var sParams = sQuery.split("&");
		for(var i = 0; i < sParams.length; i++)
		{
			var sParamPair = sParams[i].split("=");
			sParamName = unescape(sParamPair[0]);
			sParamValue = unescape(sParamPair[1]);
			
			if(sParamName == pParamName)
			{
				return sParamValue;
			}
		} 
	}
	
	return "";
}

function BuildUrlParam(pName, pValue)
{
	return escape(pName) + "=" + escape(pValue);
}

//////////////////////////////////
//Hide div
//////////////////////////////////
function HideDiv(divId)
{
	var oDiv = document.getElementById(divId);
	oDiv.style.display = "none";          
}
//////////////////////////////////
//Show div
//////////////////////////////////
function ShowDiv(divId)
{
	var oDiv = document.getElementById(divId);
	oDiv.style.display = "inline";
}  
//////////////////////////////////
//Toggle box  
//////////////////////////////////
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
	if(document.layers)         //NN4+
	{
	  document.layers[szDivID].display = iState ? "block" : "none";
	}
	else if(document.getElementById)         //gecko + IE 5+
	{
		var obj = document.getElementById(szDivID);
		obj.style.display = iState ? "block" : "none";
	}
	else if(document.all)    // IE 4
	{
	   document.all[szDivID].style.display = iState ? "block" : "none";
	}
	try
	{
		togglePlayAll("off");	
	}
	catch(err)
	{
		
	}
}
//////////////////////////////////
//Hide box
//////////////////////////////////
function hideBox(szDivID, iState) // 1 visible, 0 hidden
{
	if(document.layers)	   //NN4+
	{
		document.layers[szDivID].visibility = iState ? "show" : "hide";
	}
	else if(document.getElementById)	  //gecko + IE 5+
	{
		var obj = document.getElementById(szDivID);
		obj.style.visibility = iState ? "visible" : "hidden";
	}
	else if(document.all)	// IE 4
	{
		document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
	}
}


///////////////////////////////////
// FCOmma : Adds commas to a given large integer.
//////////////////////////////////
   function FComma(SS) {
    var T = "", S = String(SS), L = S.length - 1, C, j, P = S.indexOf(".") - 1;
    if (P < 0) {
        P = L;
    }
    for (j = 0; j <= L; j++) {
        T += C = S.charAt(j);
        if (j < P && (P - j) % 3 == 0 && C != "-") {
            T += ",";
        }
    }
    return T;
	}
	
/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/

var Base64 = {

	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;

		input = Base64._utf8_encode(input);

		while (i < input.length) {

			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}

			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

		}

		return output;
	},

	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;

		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

		while (i < input.length) {

			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));

			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;

			output = output + String.fromCharCode(chr1);

			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}

		}

		output = Base64._utf8_decode(output);

		return output;

	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}

//Gets the age from the dob cookie if set. If not returns -1
function getAge ()
{
  var strDOB = getCookie('dob');
  var age = -1;
  if (strDOB != null)
  {
      var today = new Date();
      //date is expected in this format   mm/dd/yyyy hh:mm:ss
      var pattern = /\W+/;
      var tempArray = strDOB.split (pattern);

      var dob = new Date(tempArray[0] + '/' + tempArray[1] + '/' + tempArray[2]);
      var minDiff =	1000 * 60 * 60 * 24 * 365.242199;
      var diff = (today.getTime() - (dob.getTime()+1000*60*60*24))/minDiff; 
      return diff;
  }
  else
  {
      return age;
  }
}