// JavaScript Document

// start navigation js

function myNav()
{
	var list = document.getElementsByTagName('li');
	for (i = 0; i < list.length; i++)
	{
		if ((list[i].className == 'nav1') && (location.pathname.length <= 1))
		{
			list[i].className = 'redBG';
		}
		if ((list[i].className == 'nav2') && (location.href.indexOf("the-digital-difference") != -1))
		{
			list[i].className = 'redBG';
		}
		if ((list[i].className == 'nav3') && (location.href.indexOf("our-portfolio") != -1))
		{
			list[i].className = 'redBG';
		}
		if ((list[i].className == 'nav4') && (location.href.indexOf("advertising-packages") != -1))
		{
			list[i].className = 'redBG';
		}
		if ((list[i].className == 'nav5') && (location.href.indexOf("ad-types") != -1))
		{
			list[i].className = 'redBG';
		}
		
		if ((list[i].className == 'nav6') && (location.href.indexOf("campaign-planner") != -1))
		{
			list[i].className = 'redBG';
		}

		if ((list[i].className == 'nav7') && (location.href.indexOf("e-newsletter") != -1))
		{
			list[i].className = 'redBG';
		}

		if ((list[i].className == 'nav8') && (location.href.indexOf("our-clients") != -1))
		{
			list[i].className = 'redBG';
		}

		if ((list[i].className == 'nav9') && (location.href.indexOf("case-studies") != -1))
		{
			list[i].className = 'redBG';
		}
		if ((list[i].className == 'nav10') && (location.href.indexOf("testimonials") != -1))
		{
			list[i].className = 'redBG';
		}
		if ((list[i].className == 'nav11') && (location.href.indexOf("news-centre") != -1))
		{
			list[i].className = 'redBG';
		}

		if ((list[i].className == 'nav12') && (location.href.indexOf("useful-links") != -1))
		{
			list[i].className = 'redBG';
		}
		if ((list[i].className == 'nav13') && (location.href.indexOf("contact-us") != -1))
		{
			list[i].className = 'redBG';
		}
		
		if ((list[i].className == 'nav14') && (location.href.indexOf("rate-card") != -1))
		{
			list[i].className = 'redBG';
		}
		
	}
}

// end navigation js


// start popup/overlay code

function showScraperWarning(friendlyName) {
  var mySW = document.getElementById("scraper_warning");
  var mySWi = document.getElementById(friendlyName);

  mySW.style.display = "block";
  mySWi.style.display = "block";

  
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  

  var docHeight = (document.height !== undefined) ? document.height + 50 : document.body.offsetHeight + 50;
  var docWidth = (document.width !== undefined) ? document.width : document.body.offsetWidth;
  mySW.style.width = "100%";
 
  
  if ((myHeight) > (docHeight))
  {
	  mySW.style.height = myHeight + 'px';
  }
  else
  {
	  mySW.style.height = docHeight + 'px';
  }
  
  
  
  mySWi.style.left = ( (docWidth/2) - (mySWi.clientWidth/2) ) + 'px';
  mySWi.style.top = document.documentElement.scrollTop + 100 + "px";
}

function closeSW(friendlyName) {
  var mySW = document.getElementById("scraper_warning");
  var mySWi = document.getElementById(friendlyName);

  mySW.style.display = "none";
  mySWi.style.display = "none";
}

// end popup/overlay code


// contact us verification code

function checkDetails()
{
	var themessage = "Please supply...\n";
		
	if (document.form1.name.value=="")
	{
		themessage = themessage + " - Your name\n";
	}
	
	if (document.form1.company.value=="")
	{
		themessage = themessage + " - Your company\n";
	}
	
	if (document.form1.telephone.value=="")
	{
		themessage = themessage + " - Your telephone number\n";
	}

	//alert if fields are empty and cancel form submit
	
	if (themessage == "Please supply...\n")
	{
		return true;
	}
	else
	{
		alert(themessage);
		return false;
	}
}

// end contact us verification code








// e-newsletter verification code

function checkRegister()
{

	var themessage = "Error:\n";
		
	if (document.form2.name1.value=="")
	{
		themessage = themessage + " - Please enter your name\n";
	}
	
	if ((document.form2.email.value.indexOf('@') < 1) || (document.form2.email.value.length < (document.form2.email.value.indexOf('@') + 5)) )
	{
		themessage = themessage + " - Please enter your email address\n";
	}
	
	if ( (document.form2.check1.checked != 1) && (document.form2.check2.checked != 1) && (document.form2.check3.checked != 1))
	{
		themessage = themessage + " - Please tick at least one option\n";
	}

	if (document.form2.company.value=="")
	{
		themessage = themessage + " - Please enter your company name\n";
	}

	//alert if fields are empty and cancel form submit
	
	if (themessage == "Error:\n")
	{
		return true;
	}
	else
	{
		alert(themessage);
		return false;
	}
}



function checkForgotten()
{

	var themessage = "Error:\n";
		
	if (document.form2.name1.value=="")
	{
		themessage = themessage + " - Please enter your name\n";
	}
	
	if ((document.form2.email.value.indexOf('@') < 1) || (document.form2.email.value.length < (document.form2.email.value.indexOf('@') + 5)) )
	{
		themessage = themessage + " - Please enter your email address\n";
	}

	//alert if fields are empty and cancel form submit
	
	if (themessage == "Error:\n")
	{
		return true;
	}
	else
	{
		alert(themessage);
		return false;
	}
}

// end e-newsletter verification code



















