/*******************/
/*   SEARCHBOX    */
/*******************/

function searchboxes(inp,defaultText,isFocus)
{
	if (isFocus==1)
	{
		if (inp.value==defaultText){inp.value='';}
	}
	else
	{
		if (inp.value==''){inp.value=defaultText;}
	}
}

function toggleElm()
{
	a=toggleElm.arguments;
	for(i=0; i<a.length; i++)
	{
		try
		{
			elm=document.getElementById(a[i]);
			if (elm.style.display=='none'){elm.style.display='';}
			else {elm.style.display='none';}
		}catch(e){}
	}
}



function BreadcrumbCss()
{
	var bc = document.getElementById('breadcrumbs');
	var a = bc.getElementsByTagName('A');
	if (a.length > 0)
	{
		for (var i = 0; i < a.length; i++)
		{
			a[i].className = '';
			a[i].className = 'level' + (i + 1);
		}
		a[a.length - 1].className += 'home';
	}
}

function SubNavCSS()
{
	var sN = document.getElementById('subNav');
	var aLI = sN.getElementsByTagName('LI');
	var a;
	var l1href;

	for (var i = 0; i < aLI.length; i++)
	{
		a = aLI[i].getElementsByTagName('A');
		if (a[0].href.toLowerCase() == location.href.toLowerCase())
		{
			aLI[i].className += ' on';
		}
		else
		{
			if (aLI[i].className == 'level1')
			{
				l1href = new String(a[0].href);
				l1href = l1href.replace('index.htm', '');
				if (location.href.substr(0, l1href.length).toLowerCase() == l1href.toLowerCase())
				{
					aLI[i].className += ' within';
				}
			}
		}
	}
}


function MM_jumpMenu(targ,selObj,restore)
{
  eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");
  if (restore) selObj.selectedIndex=0;
}

function doTower()
{
	var m; m = ge('towerpos_td');
	var t; t = ge('tower');
	if(m && t)
	{
		var d = new dims(m);
		showElm(t);
		posElm(t, (d.left+d.width)+15, d.top );
	}
}

function showSearch(me)
{
	var d = new dims(me);
	var g = ge('searchdiv');
	showElm(g);
	posElm(g,d.left-4,d.top-4);
}

function dims(elm)
{
	var top=0;
	var height=0;
	var width=0;
	var left=0;
	
	if(elm)
	{
		this.height=elm.offsetHeight;
		this.width=elm.offsetWidth;
		
		while(elm)
		{
			left+=elm.offsetLeft;
			top+=elm.offsetTop;
			elm=elm.offsetParent;
		}
		this.left=left;
		this.top=top;
	}
}

function ge(id){return document.getElementById(id);}

function hideElm(elm)
{
	if(elm)
	{
		if(elm.style)
		{
			elm.style.visibility='hidden';
			elm.style.display='none';
		}
	}
}

function showElm(elm)
{
	if(elm)
	{
		if(elm.style)
		{
			elm.style.visibility='visible';
			elm.style.display='';
		}
	}
}

function posElm(elm,x,y)
{
	if(elm)
	{
		if(elm.style)
		{
			elm.style.top=y+'px';
			elm.style.left=x+'px';
		}
	}
}

function js_taf()
{
	var taf = window.open('/tellafriend.htm?qstref=' + escape(location.href.toString()),'','height=600,width=500,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0');
	try{taf.focus();}
	catch(e){}
}

/********************/
/ Newsletter overlay /
/********************/

function ovrly_Init()
		{
			var posFromTop = 210;
			var posFromLeft = 200;
			var useCookie = true;
			var cookieExpiryDays = 21;

			var divContentHTML = '<div style="padding:5px;background:#fff;color:#666;border:1px solid #adadad;">'
			+ '<div style="text-align:center;padding-bottom:5px;"><a href="#" onclick="document.getElementById(\'__divovrly\').style.display=\'none\';return false" style="color:#FF0000;font-size:12px;">[ close ]</a></div>'
			+ '<table border="0" width="500" cellpadding="0">'
			+ '<tr><td valign=middle style="padding-bottom:5px;" colspan="2"><h1 class="brightgreen">Sign up to our FREE newsletter!</h1></td><td valign=bottom align=right><a href="/newsletter.htm"><img src="http://www.slimming.co.uk/img/icon-arrownewsright.jpg" border="0" /></a></td></tr>'
			+ '<tr><td style="padding-left:15px;" colspan="3"><H3>Want to lose weight?</H3><ul><li class="n dkgrey padL" style="line-height:1.5em;list-style-type:none;">Sound advice, articles & tips to help you lose weight,<br />wherever you need to start from.</li></ul></td></tr>'
			+ '<tr><td style="padding-left:15px;" colspan="3"><H3>FREE tips & special offers interest you?</H3><ul><li class="n dkgrey padL" style="line-height:1.5em;list-style-type:none;">Each month we&rsquo;ll send you a selection of slimming, dieting and fitness articles and tips for ideas or to save money<br />&nbsp;</li></ul></td></tr>'
			+ '<tr><td valign=center align=left width="1%"><img src="http://www.slimming.co.uk/img/img_slimminggirl.jpg"></td><td colspan="2" width="99%" align=right><H1 class="red">Sign Up now & get a FREE ebook</H1></td></tr>'
			+ '</table>'
			+ '</div>';

			var showOverlay = false;
			if (useCookie == true)
			{
				var ck = ovrly_GetCookie('ovrly_Cookie');
				if (ck != null && ck != '') { showOverlay = false; }
				else {showOverlay = true;}
			}
			else { showOverlay = true; }

			if (showOverlay == true)
			{
				var ovrly = document.createElement('DIV');
				ovrly.id = '__divovrly';
				ovrly.style.position = 'absolute';
				ovrly.style.top = posFromTop + 'px';
				ovrly.style.left = posFromLeft + 'px';
				ovrly.style.zIndex = 99;
				ovrly.innerHTML = divContentHTML;

				document.body.appendChild(ovrly);

				ovrly_SetCookie('ovrly_Cookie', 'ovrly_shown', cookieExpiryDays);
			} 
		}

		function ovrly_GetCookie(c_name)
		{
			if (document.cookie.length > 0)
			{
				c_start = document.cookie.indexOf(c_name + '=');
				if (c_start != -1)
				{
					c_start = c_start + c_name.length + 1;
					c_end = document.cookie.indexOf(';', c_start);
					if (c_end == -1) { c_end = document.cookie.length; }
					return unescape(document.cookie.substring(c_start, c_end));
				}
			}
			return '';
		}

		function ovrly_SetCookie(c_name, value, expiredays)
		{
			var exdate = new Date();
			exdate.setDate(exdate.getDate() + expiredays);
			//exdate.setTime(exdate.getTime() + (expiredays * 1000 * 60));//MINUTES * 60 * 24));
			document.cookie = c_name + '=' + escape(value) + ((expiredays == null) ? '' : '; expires=' + exdate.toGMTString());
		}


/************************/
/ Corners - diet profile /
/************************/

function DomCheck(){
return(document.createElement && document.getElementById)
}

function DomCorners(id,bk,h,tries){
var el=document.getElementById(id);
if(el==null){                              // if the element isn't ready in the DOM...
    if(tries==null) tries=200;
    if(tries>0)                            // and there are still tries...
        setTimeout("DomCorners('"+id+"','"+bk+"',"+h+","+(--tries)+")",50);  // back in 50ms
    return;
    }
var c=new Array(4);
for(var i=0;i<4;i++){                      // create the four elements for rounded corners
    c[i]=document.createElement("b");
    c[i].style.display="block";            // with necessary style declarations
    c[i].style.height=h+"px";
    c[i].style.fontSize="1px";
    if(i%2==0)
        c[i].style.background="url("+bk+") no-repeat 0 -"+ i*h + "px";
    else
        c[i].style.background="url("+bk+") no-repeat 100% -"+ i*h + "px";
    }
c[0].appendChild(c[1]);
c[2].appendChild(c[3]);
el.style.padding="0";
el.insertBefore(c[0],el.firstChild);       // add top corners
el.appendChild(c[2]);                      // and bottom ones
}
if(DomCheck()){
DomCorners("header","transparent.gif",5);
DomCorners("content","transparent.gif",5);
DomCorners("menu","transparent.gif",5);
DomCorners("links","transparent.gif",5);
DomCorners("footer","small.gif",2);
} 



