if (domainname != '')
{
	// domain has been set
}
else
{
	domainname = 'megasuccessclub.com';
}

function email(account) {
   document.write('<a href="mailto:' + account + '@' + domainname + '" class="email">');
   document.write(account + '@' + domainname + '</a>');
}

function inputDefault(field) {
   if (!document.getElementById) return false;
   if (!document.getElementById(field)) return false;
   var fieldtochange = document.getElementById(field);

   var holder = fieldtochange.parentNode.firstChild;
   while (holder.nodeType == '3' || holder.nodeName != 'LABEL') {
      holder = holder.nextSibling;
   }

   if (holder == undefined) return false;
   holder = holder.innerHTML;

   if (fieldtochange.value == '') {
      fieldtochange.value = "Insert "+holder;
   }

   fieldtochange.onfocus = function() {
      if (this.value == "Insert " + holder)
         this.value = '';
   }
   fieldtochange.onblur = function() {
      if (this.value == '')
         this.value = "Insert " + holder;
   }
   return true;
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

function copy(inElement)
{
	// copys the value of a passed element to the systems clipboard
	if (inElement.createTextRange)
	{
		var range = inElement.createTextRange();
		if (range && BodyLoaded==1)
		range.execCommand('Copy');
		alert('woah');
	}
	else
	{
		var flashcopier = 'flashcopier';
		if (!document.getElementById(flashcopier))
		{
			var divholder = document.createElement('div');
			divholder.id = flashcopier;
			document.body.appendChild(divholder);
		}
		document.getElementById(flashcopier).innerHTML = '';
		var content;
		if (inElement.innerText)
		{
			content = inElement.innerText;
		}
		else
		{
			content = inElement.textContent;
		}
		var divinfo = '<embed src="/themes/mscCommon1/media/_clipboard.swf" FlashVars="clipboard='
		+ encodeURIComponent(content) + '" width="0" height="0" type="application/x-shockwave-flash"></embed>';
		document.getElementById(flashcopier).innerHTML = divinfo;
	}
}

function yourGiftsForm()
{
	return;
	// ok breaks in IE cause of the id/name issue, stupid work around:
	var divs = document.getElementsByTagName('div');
	var forms = Array();
	
	for (i = 0; i < divs.length; ++i)
	{
		if (divs[i].className.match(/commsubscriptionblock form/))
		{
			forms.push(divs[i]);
		}
	}
	
	var i;
	
	for(i = 0; i < forms.length; ++i)
	{
		if (forms[i].getElementsByTagName('input')[0].name.match(/commsubscription1/)) continue;
		var para = document.createElement('p');
		para.style.padding = '15px 18px 5px';
		para.innerHTML = 'To instantly claim your <strong>FREE GIFTS</strong> today, complete the simple form below (m'
			+ 'aking sure your email address is correct) and then <em><strong>click</strong></em> the \'big red\' button below!';
		forms[i].insertBefore(para, forms[i].firstChild);
	}
}

function setCopyEvent()
{
	var code = document.getElementsByTagName('code');
	for (var i = 0; i < code.length; i++)
	{
		code[i].style.cursor = 'pointer';
		code[i].title = 'Click To Copy Code To Clipboard';
		code[i].onclick = function()
		{
			copy(this);
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

//
// check if a window.onload event exists, and add to it if so, or create one if not
//

loadEvent = window.onload;
if (typeof loadEvent != 'function')
{
	window.onload = function()
	{
		inputDefault('commsubscription1_firstName');
		inputDefault('commsubscription1_email');
		yourGiftsForm()
		setCopyEvent();
	};
}
else
{
	window.onload = function()
	{
		loadEvent();
		inputDefault('commsubscription1_firstName');
		inputDefault('commsubscription1_email');
		yourGiftsForm()
		setCopyEvent();
	};
}
