window.onload = function()
{
	prepareLinks();
}


function prepareLinks()
{
	var links = document.getElementsByTagName("a");
	for (var i=0; i<links.length; i++)
	{
		if (links[i].getAttribute("className"))
		{
			if (links[i].getAttribute("classname") == "external") 
			{
				if (links[i].getAttribute('title') == '')
					links[i].setAttribute("title","(opens in a new window)");
				links[i].onclick = function()
				{
					OpenNewWindow(this.getAttribute('href'));
					return false;
				}
			}
			else if (links[i].getAttribute('classname').substring(0,6) == 'popup_')
			{
				links[i].setAttribute('title','this is a popup');
				links[i].onclick = function()
				{
					popup(50,50,this.getAttribute('classname').split('_')[1],this.getAttribute('classname').split('_')[2],this.getAttribute('href'));
					return false;
				}
			}
			else
			{
	//			var linkText  = links[i].firstChild.nodeValue;
	//			links[i].setAttribute('title','this is a link to '+linkText);
			}
		}
		else if (links[i].getAttribute("class"))
		{
			if (links[i].getAttribute("class"))
			{
				if (links[i].getAttribute("class") == "external") 
				{
					if (links[i].getAttribute('title') == '')
						links[i].setAttribute("title","(opens in a new window)");
					links[i].onclick = function()
					{
						OpenNewWindow(this.getAttribute('href'));
						return false;
					}
				}
				else if (links[i].getAttribute('class').substring(0,6) == 'popup_')
				{
					links[i].setAttribute('title','this is a popup');
					links[i].onclick = function()
					{
						popup(50,50,this.getAttribute('class').split('_')[1],this.getAttribute('class').split('_')[2],this.getAttribute('href'));
						return false;
					}
				}
			}
		}
  	}
}

function popup(x,y,w,h,fn)
{
	NewWindow = window.open(fn,'descr','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=0,scrollbars=1,resizable=1,copyhistory=no,width='+w+',height='+h+', top='+y+',left='+x)
}


function OpenNewWindow(fn)
{
	NewWindow = window.open(fn)
}


//function toggleT(_w,_h) {
//  if (isDOM)
//  {
//    if (_h=='s') document.getElementById(_w).style.display='block';
//    if (_h=='h') document.getElementById(_w).style.display='none';
//  }
//  else if (isIE) {
//    if (_h=='s') eval("document.all."+_w+".style.display='block';");
//    if (_h=='h') eval("document.all."+_w+".style.display='none';");
//  }
//  else if(isNS4)
//  {
//    if (_h=='s') eval("document.layers['"+_w+"'].display='block';");
//    if (_h=='h') eval("document.layers['"+_w+"'].display='none';");
//  }
//}





//function MM_goToURL() { //v3.0
//  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
//  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
//}



//function showhidemanagedinput(_h) {
//   if (_h=='c') document.profile.pub_company.checked = false;
// }



//function UpdateChecks(which) {
//if(which == 'none')   { uncheck(); }
//}



//function uncheck() {
//	document.profile.pub_company[0].checked = false;
//	document.profile.pub_company[1].checked = false;
//}


//function Managedwarning()
//{if(confirm('Managed outlets cannot enter this promotion\nClick on OK to see the terms and conditions\nIf this is a mistake click on Cancel then amend the form'))
//popUp('cask_terms_pop_up.asp','terms',440,786);return false; ;
//   }
