/* Tabber Script - Copyright (c) 2006 Patrick Fitzgerald - http://www.barelyfitz.com/projects/tabber/ */
function tabberObj(argsObj){var arg;this.div=null;this.classMain="tabber";this.classMainLive="tabberlive";this.classTab="tabbertab";this.classTabDefault="tabbertabdefault";this.classNav="tabbernav";this.classTabHide="tabbertabhide";this.classNavActive="tabberactive";this.titleElements=['h2','h3','h4','h5','h6'];this.titleElementsStripHTML=true;this.removeTitle=true;this.addLinkId=false;this.linkIdFormat='<tabberid>nav<tabnumberone>';for(arg in argsObj){this[arg]=argsObj[arg]}this.REclassMain=new RegExp('\\b'+this.classMain+'\\b','gi');this.REclassMainLive=new RegExp('\\b'+this.classMainLive+'\\b','gi');this.REclassTab=new RegExp('\\b'+this.classTab+'\\b','gi');this.REclassTabDefault=new RegExp('\\b'+this.classTabDefault+'\\b','gi');this.REclassTabHide=new RegExp('\\b'+this.classTabHide+'\\b','gi');this.tabs=new Array();if(this.div){this.init(this.div);this.div=null}}tabberObj.prototype.init=function(e){var childNodes,i,i2,t,defaultTab=0,DOM_ul,DOM_li,DOM_a,aId,headingElement;if(!document.getElementsByTagName){return false}if(e.id){this.id=e.id}this.tabs.length=0;childNodes=e.childNodes;for(i=0;i<childNodes.length;i++){if(childNodes[i].className&&childNodes[i].className.match(this.REclassTab)){t=new Object();t.div=childNodes[i];this.tabs[this.tabs.length]=t;if(childNodes[i].className.match(this.REclassTabDefault)){defaultTab=this.tabs.length-1}}}DOM_ul=document.createElement("ul");DOM_ul.className=this.classNav;for(i=0;i<this.tabs.length;i++){t=this.tabs[i];t.headingText=t.div.title;if(this.removeTitle){t.div.title=''}if(!t.headingText){for(i2=0;i2<this.titleElements.length;i2++){headingElement=t.div.getElementsByTagName(this.titleElements[i2])[0];if(headingElement){t.headingText=headingElement.innerHTML;if(this.titleElementsStripHTML){t.headingText.replace(/<br>/gi," ");t.headingText=t.headingText.replace(/<[^>]+>/g,"")}break}}}if(!t.headingText){t.headingText=i+1}DOM_li=document.createElement("li");t.li=DOM_li;DOM_a=document.createElement("a");DOM_a.appendChild(document.createTextNode(t.headingText));DOM_a.href="javascript:void(null);";DOM_a.title=t.headingText;DOM_a.onclick=this.navClick;DOM_a.tabber=this;DOM_a.tabberIndex=i;if(this.addLinkId&&this.linkIdFormat){aId=this.linkIdFormat;aId=aId.replace(/<tabberid>/gi,this.id);aId=aId.replace(/<tabnumberzero>/gi,i);aId=aId.replace(/<tabnumberone>/gi,i+1);aId=aId.replace(/<tabtitle>/gi,t.headingText.replace(/[^a-zA-Z0-9\-]/gi,''));DOM_a.id=aId}DOM_li.appendChild(DOM_a);DOM_ul.appendChild(DOM_li)}e.insertBefore(DOM_ul,e.firstChild);e.className=e.className.replace(this.REclassMain,this.classMainLive);this.tabShow(defaultTab);if(typeof this.onLoad=='function'){this.onLoad({tabber:this})}return this};tabberObj.prototype.navClick=function(event){var rVal,a,self,tabberIndex,onClickArgs;a=this;if(!a.tabber){return false}self=a.tabber;tabberIndex=a.tabberIndex;a.blur();if(typeof self.onClick=='function'){onClickArgs={'tabber':self,'index':tabberIndex,'event':event};if(!event){onClickArgs.event=window.event}rVal=self.onClick(onClickArgs);if(rVal===false){return false}}self.tabShow(tabberIndex);return false};tabberObj.prototype.tabHideAll=function(){var i;for(i=0;i<this.tabs.length;i++){this.tabHide(i)}};tabberObj.prototype.tabHide=function(tabberIndex){var div;if(!this.tabs[tabberIndex]){return false}div=this.tabs[tabberIndex].div;if(!div.className.match(this.REclassTabHide)){div.className+=' '+this.classTabHide}this.navClearActive(tabberIndex);return this};tabberObj.prototype.tabShow=function(tabberIndex){var div;if(!this.tabs[tabberIndex]){return false}this.tabHideAll();div=this.tabs[tabberIndex].div;div.className=div.className.replace(this.REclassTabHide,'');this.navSetActive(tabberIndex);if(typeof this.onTabDisplay=='function'){this.onTabDisplay({'tabber':this,'index':tabberIndex})}return this};tabberObj.prototype.navSetActive=function(tabberIndex){this.tabs[tabberIndex].li.className=this.classNavActive;return this};tabberObj.prototype.navClearActive=function(tabberIndex){this.tabs[tabberIndex].li.className='';return this};function tabberAutomatic(tabberArgs){var tempObj,divs,i;if(!tabberArgs){tabberArgs={}}tempObj=new tabberObj(tabberArgs);divs=document.getElementsByTagName("div");for(i=0;i<divs.length;i++){if(divs[i].className&&divs[i].className.match(tempObj.REclassMain)){tabberArgs.div=divs[i];divs[i].tabber=new tabberObj(tabberArgs)}}return this}function tabberAutomaticOnLoad(tabberArgs){var oldOnLoad;if(!tabberArgs){tabberArgs={}}oldOnLoad=window.onload;if(typeof window.onload!='function'){window.onload=function(){tabberAutomatic(tabberArgs)}}else{window.onload=function(){oldOnLoad();tabberAutomatic(tabberArgs)}}}if(typeof tabberOptions=='undefined'){tabberAutomaticOnLoad()}else{if(!tabberOptions['manualStartup']){tabberAutomaticOnLoad(tabberOptions)}}

/* Version 0.4 - Simon Willison, March 25th 2003 - http://simonwillison.net/2003/Mar/25/getElementsBySelector/ */
function getAllChildren(e){return e.all?e.all:e.getElementsByTagName('*')}document.getElementsBySelector=function(selector){if(!document.getElementsByTagName){return new Array()}var tokens=selector.split(' ');var currentContext=new Array(document);for(var i=0;i<tokens.length;i++){token=tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');if(token.indexOf('#')>-1){var bits=token.split('#');var tagName=bits[0];var id=bits[1];var element=document.getElementById(id);if(tagName&&element.nodeName.toLowerCase()!=tagName){return new Array()}currentContext=new Array(element);continue}if(token.indexOf('.')>-1){var bits=token.split('.');var tagName=bits[0];var className=bits[1];if(!tagName){tagName='*'}var found=new Array;var foundCount=0;for(var h=0;h<currentContext.length;h++){var elements;if(tagName=='*'){elements=getAllChildren(currentContext[h])}else{elements=currentContext[h].getElementsByTagName(tagName)}for(var j=0;j<elements.length;j++){found[foundCount++]=elements[j]}}currentContext=new Array;var currentContextIndex=0;for(var k=0;k<found.length;k++){if(found[k].className&&found[k].className.match(new RegExp('\\b'+className+'\\b'))){currentContext[currentContextIndex++]=found[k]}}continue}if(token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)){var tagName=RegExp.$1;var attrName=RegExp.$2;var attrOperator=RegExp.$3;var attrValue=RegExp.$4;if(!tagName){tagName='*'}var found=new Array;var foundCount=0;for(var h=0;h<currentContext.length;h++){var elements;if(tagName=='*'){elements=getAllChildren(currentContext[h])}else{elements=currentContext[h].getElementsByTagName(tagName)}for(var j=0;j<elements.length;j++){found[foundCount++]=elements[j]}}currentContext=new Array;var currentContextIndex=0;var checkFunction;switch(attrOperator){case'=':checkFunction=function(e){return(e.getAttribute(attrName)==attrValue)};break;case'~':checkFunction=function(e){return(e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b')))};break;case'|':checkFunction=function(e){return(e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?')))};break;case'^':checkFunction=function(e){return(e.getAttribute(attrName).indexOf(attrValue)==0)};break;case'$':checkFunction=function(e){return(e.getAttribute(attrName).lastIndexOf(attrValue)==e.getAttribute(attrName).length-attrValue.length)};break;case'*':checkFunction=function(e){return(e.getAttribute(attrName).indexOf(attrValue)>-1)};break;default:checkFunction=function(e){return e.getAttribute(attrName)}}currentContext=new Array;var currentContextIndex=0;for(var k=0;k<found.length;k++){if(checkFunction(found[k])){currentContext[currentContextIndex++]=found[k]}}continue}tagName=token;var found=new Array;var foundCount=0;for(var h=0;h<currentContext.length;h++){var elements=currentContext[h].getElementsByTagName(tagName);for(var j=0;j<elements.length;j++){found[foundCount++]=elements[j]}}currentContext=found}return currentContext}

/* Copyright MyspaceGens.com 2008-2009 - Profile Editor JS */
function $(element)
{
	element = document.getElementById(element);
	return element;
}

function $$(element)
{
	element = frames['preview'].document.getElementsBySelector(element);
	return element;
}

function checkVar(pTarget, sTarget, sValue, sValue2)
{
	if ($(pTarget).value != '')
	{
		if (sValue == "bg")
		{
			return ""+ sTarget +": url('"+ $(pTarget).value +"'); ";
		}
		else if (sValue == "px")
		{
			if (sValue2 == "im")
			{
				return ""+ sTarget +": "+ $(pTarget).value +"px !important; ";
			}
			else
			{
				return ""+ sTarget +": "+ $(pTarget).value +"px; ";
			}
		}
		else if (sValue == "im")
		{
			return ""+ sTarget +": "+ $(pTarget).value +" !important; ";
		}
		else
		{
			return ""+ sTarget +": "+ $(pTarget).value +"; ";
		}
	}
	else
	{
		return "";
	}
}

function setAction()
{
	/* Set events for all fields (excluding below) - Some seperated for performance */
	var changes = new Array("bodyBackgroundColor", "bodyBorderColor", "bodyBorderWidth", "bodyBorderStyle", "tableBackgroundColor", "tableBorderColor", "tableBorderWidth", "tableBorderStyle",
	"bodyBackgroundImage", "bodyBackgroundRepeat", "bodyBackgroundPosition", "bodyBackgroundAttachment", "tableBackgroundImage", "tableBackgroundRepeat", "tableBackgroundPosition", "tableBackgroundAttachment",
	"tableBackgroundOpacity", "contactTableURL", "extendedNetworkURL", "extendedNetworkHeight", "mainTextColor", "mainTextSize", "mainTextStyle", "mainTextDecoration", "lbefTextColor", "lbefTextSize", 
	"lbefTextStyle", "lbefTextDecoration", "dtcTextColor", "dtcTextSize", "dtcTextStyle", "dtcTextDecoration", "enTextColor", "enTextSize", "enTextStyle", "enTextDecoration", "gmeTextColor", "gmeTextSize", 
	"gmeTextStyle", "gmeTextDecoration", "baeTextColor", "baeTextSize", "baeTextStyle", "baeTextDecoration", "tfnTextColor", "tfnTextSize", "tfnTextStyle", "tfnTextDecoration", "tcnTextColor", "tcnTextSize", 
	"tcnTextStyle", "tcnTextDecoration", "asleTextColor", "asleTextSize", "asleTextStyle", "asleTextDecoration", "cideTextColor", "cideTextSize", "cideTextStyle", "cideTextDecoration", "ynTextColor", 
	"ynTextSize", "ynTextStyle", "ynTextDecoration", "rLinkColor", "rLinkSize", "rLinkStyle", "rLinkDecoration", "rLinkHoverColor", "rLinkHoverSize", "rLinkHoverStyle", "rLinkHoverDecoration", "vfLinkColor", 
	"vfLinkSize", "vfLinkStyle", "vfLinkDecoration", "vfLinkHoverColor", "vfLinkHoverSize", "vfLinkHoverStyle", "vfLinkHoverDecoration");
	
	for (var element = 0; element < changes.length; ++element)
	{
		$(''+ changes[element] +'').onchange = update;
		$(''+ changes[element] +'').onkeyup = update;
	}
	
	/* Set events for hide fields */
	var clicks = new Array("hideContactTable", "hideMusicPlayer", "hideMyspaceURL", "hideInterests", "hideDetails", "hideExtendedNetwork", "hideBlogs", "hideAboutWho", "hideFriends", "hideComments", 
	"hideAddComment", "hideViewFriends", "hideViewComments", "hideNumFriends");
	
	for (var element = 0; element < clicks.length; ++element)
	{
		$(''+ clicks[element] +'').onclick = applyHide;
	}
	
	/* Set events for navigation bar fields */
	var links = new Array("navLinkBackgroundColor", "navLinkTextColor", "navLinkTextSize", "navLinkTextStyle", "navLinkTextDecoration", "navHoverBackgroundColor", "navHoverTextColor", "navHoverTextSize", 
	"navHoverTextStyle", "navHoverTextDecoration", "navRailColor", "navArrowColor", "navArrowSize");
	
	for (var element = 0; element < links.length; ++element)
	{
		$(''+ links[element] +'').onchange = NavStyle.General;
		$(''+ links[element] +'').onkeyup = NavStyle.General;
	}
	
	$('type').onchange = setLayoutType;
	
	Display.Body(); //Run once (captures refresh) - This is for the body background image show/hide
	Display.Table(); //Run once (captures refresh) - This is for the table background image show/hide
}

function update()
{
	/* Update Body Background Properties */
	var bodyStyle = frames['preview'].document.getElementById('bodyStyle');
	bodyStyle.innerHTML = '&nbsp; <style type="text/css">.bodyContent { '+ checkVar("bodyBackgroundColor", "background-color") + checkVar("bodyBackgroundImage", "background-image", "bg") + checkVar("bodyBackgroundRepeat", "background-repeat") + checkVar("bodyBackgroundPosition", "background-position") + checkVar("bodyBackgroundAttachment", "background-attachment") + checkVar("bodyBorderColor", "border-color") + checkVar("bodyBorderStyle", "border-style") + checkVar("bodyBorderWidth", "border-width") +' } </style>';
	
	/* Update Table Background Properties */
	var tableStyle = frames['preview'].document.getElementById('tableStyle');
	var tableBackground = ($('tableBackgroundColor').value == '') ? ($('type').value == 'regular' || $('type').value == 'skinny') ? 'white !important' : '' : $('tableBackgroundColor').value + '!important';
	tableStyle.innerHTML = '&nbsp; <style type="text/css">table table table, table table table td { background-color: '+ tableBackground +'; '+ checkVar("tableBackgroundImage", "background-image", "bg") + checkVar("tableBackgroundRepeat", "background-repeat") + checkVar("tableBackgroundPosition", "background-position") + checkVar("tableBackgroundAttachment", "background-attachment") +' opacity: '+ $('tableBackgroundOpacity').value/10 +'; filter:alpha(opacity='+ $('tableBackgroundOpacity').value*10 +'); } table table table { '+ checkVar("tableBorderColor", "border-color") + checkVar("tableBorderStyle", "border-style") + checkVar("tableBorderWidth", "border-width") +' } </style>';
	
	/* Update Text & Link Properties */
	var textStyle = frames['preview'].document.getElementById('textStyle');
	textStyle.innerHTML = '&nbsp; <style type="text/css">td, span, div, input, table td div div font, body div table tbody tr td font { '+ checkVar("mainTextColor", "color") + checkVar("mainTextSize", "font-size") + checkVar("mainTextStyle", "font-family") + checkVar("mainTextDecoration", "text-decoration") +' } .btext { '+ checkVar("lbefTextColor", "color") + checkVar("lbefTextSize", "font-size") + checkVar("lbefTextStyle", "font-family") + checkVar("lbefTextDecoration", "text-decoration") +' } .blacktext10 { '+ checkVar("dtcTextColor", "color") + checkVar("dtcTextSize", "font-size") + checkVar("dtcTextStyle", "font-family") + checkVar("dtcTextDecoration", "text-decoration") +' } .blacktext12 { '+ checkVar("enTextColor", "color") + checkVar("enTextSize", "font-size") + checkVar("enTextStyle", "font-family") + checkVar("enTextDecoration", "text-decoration") +' } .lightbluetext8 { '+ checkVar("gmeTextColor", "color") + checkVar("gmeTextSize", "font-size") + checkVar("gmeTextStyle", "font-family") + checkVar("gmeTextDecoration", "text-decoration") +' } .orangetext15 { '+ checkVar("baeTextColor", "color") + checkVar("baeTextSize", "font-size") + checkVar("baeTextStyle", "font-family") + checkVar("baeTextDecoration", "text-decoration") +' } .redbtext { '+ checkVar("tfnTextColor", "color") + checkVar("tfnTextSize", "font-size") + checkVar("tfnTextStyle", "font-family") + checkVar("tfnTextDecoration", "text-decoration") +' } .redtext { '+ checkVar("tcnTextColor", "color") + checkVar("tcnTextSize", "font-size") + checkVar("tcnTextStyle", "font-family") + checkVar("tcnTextDecoration", "text-decoration") +' } .text { '+ checkVar("asleTextColor", "color") + checkVar("asleTextSize", "font-size") + checkVar("asleTextStyle", "font-family") + checkVar("asleTextDecoration", "text-decoration") +' } .whitetext12 { '+ checkVar("cideTextColor", "color") + checkVar("cideTextSize", "font-size") + checkVar("cideTextStyle", "font-family") + checkVar("cideTextDecoration", "text-decoration") +' } .nametext { '+ checkVar("ynTextColor", "color") + checkVar("ynTextSize", "font-size") + checkVar("ynTextStyle", "font-family") + checkVar("ynTextDecoration", "text-decoration") +' } a:active, a:visited, a:link { '+ checkVar("rLinkColor", "color") + checkVar("rLinkSize", "font-size") + checkVar("rLinkStyle", "font-family") + checkVar("rLinkDecoration", "text-decoration") +' } a:hover { '+ checkVar("rLinkHoverColor", "color") + checkVar("rLinkHoverSize", "font-size") + checkVar("rLinkHoverStyle", "font-family") + checkVar("rLinkHoverDecoration", "text-decoration") +' } a.redlink:active, a.redlink:visited, a.redlink:link { '+ checkVar("vfLinkColor", "color") + checkVar("vfLinkSize", "font-size") + checkVar("vfLinkStyle", "font-family") + checkVar("vfLinkDecoration", "text-decoration") +' } a.redlink:hover { '+ checkVar("vfLinkHoverColor", "color") + checkVar("vfLinkHoverSize", "font-size") + checkVar("vfLinkHoverStyle", "font-family") + checkVar("vfLinkHoverDecoration", "text-decoration") +' }</style>';
	
	/* Update Contact Table Properties */
	if ($('contactTableURL').value != '')
	{
		var contactTable = frames['preview'].document.getElementById('contactTable');
		contactTable.innerHTML = '&nbsp; <style type="text/css">.contactTable { width: 300px; height: 145px; padding: 0px; } .contactTable table, table.contactTable td { padding:0px; border:0px; background-color:transparent; background-image:none;} .contactTable a img {visibility:hidden; border:0px;} .contactTable a {display:block; height:29px; width:118px;} .contactTable .text { font-size:1px; } .contactTable .text, .contactTable a, .contactTable img {filter:none;}</style>';
		
		var contactTableDirect = $$(".contactTable");
		var i = 0;
		while (current = contactTableDirect[i++])
		{
			current.style.background = "transparent url("+ $('contactTableURL').value +") no-repeat scroll center center";
		}
	}
	else
	{
		var contactTable = frames['preview'].document.getElementById('contactTable');
		contactTable.innerHTML = '';
	}
	
	/* Update Extended Network Properties */
	if ($('extendedNetworkURL').value != '')
	{
		var extendedNetwork = frames['preview'].document.getElementById('extendedNetwork');
		extendedNetwork.innerHTML = '&nbsp; <style type="text/css">table table table td {vertical-align:top ! important;} span.blacktext12 { visibility:visible !important; background-color:transparent; background-image:url(\''+ $('extendedNetworkURL').value +'\'); background-repeat:no-repeat; background-position:center center; font-size:0px; letter-spacing:-0.5px; width:435px; height:'+ $('extendedNetworkHeight').value +'px; display:block !important; } span.blacktext12 img {display:none;} </style>';
	}
}

NavStyle =
{
	/*  General is for links in the drop down (Edit Profile, My Comments, Etc) Over and Out are for the direct hover (Home, Profile, Etc) */
	General: function()
	{
		var navStyle = frames['preview'].document.getElementById('navStyle');
		navStyle.innerHTML = '&nbsp; <style type="text/css">div.profileWidth table td { '+ checkVar("navLinkBackgroundColor", "background-color", "im") +' background-image: none !important; } div.profileWidth div td.rail { '+ checkVar("navRailColor", "background-color", "im") +' } div.profileWidth table td ul small { '+ checkVar("navArrowColor", "color", "im") + checkVar("navArrowSize", "font-size", "px", "im") +' } #subnav ul li a:hover { '+ checkVar("navHoverBackgroundColor", "background-color", "im") + checkVar("navHoverTextSize", "font-size", "px", "im") + checkVar("navHoverTextStyle", "font-family", "im") + checkVar("navHoverTextDecoration", "text-decoration", "im") +' } .open { '+ checkVar("navHoverBackgroundColor", "background-color", "im") + checkVar("navHoverTextColor", "color", "im") + checkVar("navHoverTextSize", "font-size", "px", "im") + checkVar("navHoverTextStyle", "font-family", "im") + checkVar("navHoverTextDecoration", "text-decoration", "im") +' } ul#leftNav li a:hover, ul#rightNav li a:hover { '+ checkVar("navHoverBackgroundColor", "background-color", "im") + checkVar("navHoverTextColor", "color", "im") + checkVar("navHoverTextSize", "font-size", "px", "im") + checkVar("navHoverTextStyle", "font-family", "im") + checkVar("navHoverTextDecoration", "text-decoration", "im") +' }</style>';
		
		/* Seperated from the innerHTML as direct change does not require the !important (which overrides hover properties) */
		var navLinks = $$("ul#leftNav li a").concat($$("ul#rightNav li a"));
		var i = 0;
		while (current = navLinks[i++])
		{
			current.style.color = $('navLinkTextColor').value;
			current.style.fontSize = $('navLinkTextSize').value + 'px';
			current.style.fontFamily = $('navLinkTextStyle').value;
			current.style.textDecoration = $('navLinkTextDecoration').value;
		}
		
		/* When hovering over a subnav LI myspace has the top element stay active - we use the ID of the parent to identify the submenu's # */
		var navLinks = $$("#subnav ul li");
		var i = 0;
		while (current = navLinks[i++])
		{
			current.onmouseover = function()
			{
				if (this.parentNode.id != "undefined")
				{
					numOnly = this.parentNode.id.replace(/[^0-3]+/g,'');
					newTarget = frames['preview'].document.getElementById('nav'+ numOnly +'');
					
					newTarget.style.background = '';
					newTarget.style.color = ($('navHoverTextColor').value == '') ? $('navLinkTextColor').value : $('navHoverTextColor').value;
					newTarget.style.fontSize = ($('navHoverTextSize').value == '') ? $('navLinkTextSize').value + 'px' : $('navHoverTextSize').value + 'px';
					newTarget.style.fontFamily = ($('navHoverTextStyle').value == '') ? $('navLinkTextStyle').value : $('navHoverTextStyle').value;
					newTarget.style.textDecoration = ($('navHoverTextDecoration').value == '') ? $('navLinkTextDecoration').value : $('navHoverTextDecoration').value;
					newTarget.style.backgroundColor = $('navHoverBackgroundColor').value;
				}
			}
			current.onmouseout = function()
			{
				if (this.parentNode.id != "undefined")
				{
					numOnly = this.parentNode.id.replace(/[^0-3]+/g,'');
					newTarget = frames['preview'].document.getElementById('nav'+ numOnly +'');
					
					newTarget.style.color = $('navLinkTextColor').value;
					newTarget.style.fontSize = $('navLinkTextSize').value + 'px';
					newTarget.style.fontFamily = $('navLinkTextStyle').value;
					newTarget.style.textDecoration = $('navLinkTextDecoration').value;
					newTarget.style.backgroundColor = $('navLinkBackgroundColor').value;
					
					if (newTarget.style.backgroundColor != '')
					{
						newTarget.style.background = ''+ $('navLinkBackgroundColor').value +' url(\'/files/navigation_bar/menu_bg.png\') 0 0 repeat-x';
					}
					else
					{
						newTarget.style.background = '#2358b8 url(\'/files/navigation_bar/menu_bg.png\') 0 0 repeat-x';
					}
				}
			}
		}
	}
}

function applyHide()
{
	/* Hide Checked Options - Seperated for speed/efficiency */
	var hideItems = '';
	
	if ($('hideContactTable').checked == true)
	{
		hideItems += '.contactTable { display: none; }';
	}
	if ($('hideMusicPlayer').checked == true)
	{
		hideItems += 'table tr td div object {width: 1px; height: 1px; filter:alpha(opacity=0.2); opacity:0.02;} table tr td table tr td div {height: 1px !important;} tr.userProfileURL div {height: auto !important;} table.interestsAndDetails {margin-top: -28px;}';
	}
	if ($('hideMyspaceURL').checked == true)
	{
		hideItems += '.userProfileURL { display:none; }';
	}
	if ($('hideInterests').checked == true)
	{
		hideItems += '.interestsAndDetails { display:none; }';
	}
	if ($('hideDetails').checked == true)
	{
		hideItems += '.userProfileDetail { display:none; }';
	}
	if ($('hideExtendedNetwork').checked == true)
	{
		hideItems += '.extendedNetwork { display:none; }';
	}
	if ($('hideBlogs').checked == true)
	{
		hideItems += '.latestBlogEntry { display:none; }';
	}
	if ($('hideAboutWho').checked == true)
	{
		hideItems += '.blurbs { display:none; }';
	}
	if ($('hideFriends').checked == true)
	{
		hideItems += '.friendSpace { display:none; }';
	}
	if ($('hideComments').checked == true)
	{
		hideItems += '.friendsComments { display:none; }';
	}
	if ($('hideAddComment').checked == true)
	{
		hideItems += 'td.text td.text td td a, .redlink, td.text td.text td b a {visibility:visible!important;}td.text td.text td a {visibility:hidden;}';
	}
	if ($('hideViewFriends').checked == true)
	{
		hideItems += '.redlink { display:none; }';
	}
	if ($('hideViewComments').checked == true)
	{
		hideItems += 'table b { display:none; }';
	}
	if ($('hideNumFriends').checked == true)
	{
		hideItems += 'td.text td.text .btext { display:none; }';
	}
	
	var hiddenTarget = frames['preview'].document.getElementById('hideItems');
	hiddenTarget.innerHTML = '&nbsp; <style type="text/css">'+ hideItems +'<style>';
}

function setLayoutType()
{
	if (confirm("Changing the layout resets any changes. Are you sure you want to continue?"))
	{
		/* The "type" selector is reset with all the rest of the fields, so we re-reset it */
		var previousType = $('type').selectedIndex;
		document.forms[1].reset();
		$('type').selectedIndex = previousType;
		
		applyLayoutType();
		update();
		parent.applyHide();
		parent.NavStyle.General();
	}
}

function applyLayoutType()
{
	var type = $('type').value;
	
	if (type == 'default')
	{
		var target = frames['preview'].document.getElementById('styleType');
		target.innerHTML = '&nbsp; <style type="text/css"></style>';
	}
	
	if (type == 'regular')
	{
		var target = frames['preview'].document.getElementById('styleType');
		target.innerHTML = '&nbsp; <style type="text/css">table, tr, td { background-color:transparent; border:none; border-width:0; }</style>';
	}
	
	if (type == 'skinny')
	{
		var target = frames['preview'].document.getElementById('styleType');
		target.innerHTML = '&nbsp; <style type="text/css">table, tr, td { background-color:transparent; border:none; border-width:0; } table table table { width:100%; padding:0; } td td td td { width: .01%; } table, td { padding: 0px; width:350px; }</style>';
	}
}

Display =
{
	Body: function()
	{
		var trTarget = document.getElementsBySelector('.bodyBackgroundData');
		var i = 0;
		while (current = trTarget[i++])
		{
			if ($('bodyBackgroundStatus').value == 'false')
			{
				current.style.display = 'none';
			}
			else {
				current.style.display = '';
			}
		}
	},
	Table: function()
	{
		var trTarget = document.getElementsBySelector('.tableBackgroundData');
		var i = 0;
		while (current = trTarget[i++])
		{
			if ($('tableBackgroundStatus').value == 'false')
			{
				current.style.display = 'none';
			}
			else {
				current.style.display = '';
			}
		}
	},
	Help: function()
	{
		if ($('help').style.display == 'none')
		{
			$('help').style.display = '';
		}
		else
		{
			$('help').style.display = 'none';
		}
	}
}

function postForm()
{
	var xmlHttp;
	
	$('switchTab').tabber.tabShow(8);
	$('codeText').innerHTML = 'Generating Codes...<br /><br /><img src="/files/profile_editor/old/images/ajax-loader.gif" />';
	
	var parameters = '&ajax=true';
	
	for (i=0; i < document.forms[1].elements.length; i++)
	{
		if ((document.forms[1].elements[i].id) && (document.forms[1].elements[i].name))
		{
			if (document.forms[1].elements[i].type == "checkbox")
			{
				if (document.forms[1].elements[i].checked == true)
				{
					parameters += "&"+ document.forms[1].elements[i].id +"="+ document.forms[1].elements[i].value +"";
				}
			}
			else
			{
				parameters += "&"+ document.forms[1].elements[i].id +"="+ document.forms[1].elements[i].value +"";
			}
		}
	}
	
	try
	{
		xmlHttp = new XMLHttpRequest();
		
		if (xmlHttp.overrideMimeType)
		{
			xmlHttp.overrideMimeType('text/html');
		}
	}
	catch (e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				document.forms[1].submit();
			}
		}
	}
	
	xmlHttp.onreadystatechange = function()
	{
		if (xmlHttp.readyState == 4)
		{
			if (xmlHttp.status == 200)
			{
				$('codeText').innerHTML = '<textarea onclick="this.select();" class="textarea large">'+ xmlHttp.responseText +'</textarea>';
				//alert(parameters);
			}
		}
	}
	
	xmlHttp.open('POST', '/handler.php?gen=profile&ajax=true', true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", parameters.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(parameters);
	
	return false;
}