// JavaScript Document

///////////////////////////////////////
// Toggles visibility via diplay style.
    function toggle_visibility(id,imgEl) {
       var e = document.getElementById(id);
	   var eImage = document.getElementById(imgEl);
	   
       if(e.style.display == 'block')
          {
		  e.style.display = 'none';	  
		  eImage.src = '/resources/images/treeExpand_plus.gif';
		  }
       else
	   	{
          e.style.display = 'block';
		  eImage.src = '/resources/images/treeExpand_minus.gif';
		}
    }

///////////////////////////////////////////////////
// Used in the forms to disable unavailable options
	
	function disable_functionality(elem) {
		var x = document.getElementById(elem);
		if(x.style.display == 'block')
		x.style.display = 'none';
		document.contactform.BulletinAreas.disabled = true;
		
		}
		
	function enable_functionality(elem) {
		var x = document.getElementById(elem);
		if(document.contactform.BulletinAreas.checked == true)
		x.style.display = 'block';
		document.contactform.BulletinAreas.disabled = false;
		}
		
////////////////////////////////////////////////////
// Used in the search to pull the entered field value of search into the form action href

function doSearch( ) {
 form = document.forms.sitesearch;
 if( form.Search.value != "") {
  window.location.href = "/sitesearch/search.action?query=" + form.Search.value;
 }
}
////////////////////////////////////////////////////
// GENERIC ALERT SCRIPT
function alertMe(msg)
{
alert(msg);
}
////////////////////////////////////////////////////
// CHECK FOR A COOKIE Default legacy code
function loggedincheck ( cookie_name1, cookie_name2 )
{

  var results1 = document.cookie.match ( '(^|;) ?' + cookie_name1 + '=([^;]*)(;|$)' );
  var results2 = document.cookie.match ( '(^|;) ?' + cookie_name2 + '=([^;]*)(;|$)' );

  if ( results1 || results2 )
    {
		document.write("<ul><li><a href='/about/index.html' title='About DDS'>About</a></li><li><a href='/contact/index.html' title='Contact DDS'>Contact</a></li><li><a href='/careers/index.html' title='Careers at DDS'>Careers</a></li><li id='select'><select name='country selector' id='countryselector' onchange=\"JumpMenu('parent',this,0)\"><option value='http://www.donovandata.com/' selected='selected'>Choose site - US</option><option value='http://www.ddscanada.com/'>Choose site - CA</option><option value='http://www.mediaocean.com/'>MediaOcean</option><option value='http://www.talentpartners.com/'>Talent Partners</option><option value='http://www.dds.co.uk'>Choose site - UK</option><option value='http://www.dds.de/'>Choose site - DE</option><option value='http://www.dds.ie/'>Choose site - IE</option><option value='http://www.dds.fr'>Choose site - FR</option></select></li></ul><ul id='loggedin'><li id='loggedinleft'><a href='/secure/logout.action'>Log out</a></li><li><a href='/secure/openpage.action?pageType=my-dds&key=My-DDS-5DD0D3'>Return to My DDS</a></li></ul>");
		isHomepage();
		analytics_DDSUS();
	}
  else
  {
   document.write("<ul><li><a href='/about/index.html' title='About DDS'>About</a></li><li><a href='/openaccess/openform.action?pageType=form&formType=contact' title='Contact DDS'>Contact</a></li><li><a href='/careers/index.html' title='Careers at DDS'>Careers</a></li><li id='loginprompt'><a href='/secure/openpage.action?pageType=my-dds&amp;key=My-DDS-5DD0D3'>Log in<span id=\"for-doc\">for documentation,<br />training &amp; more</span></a></li><li><select name='country selector' id='countryselector' onchange=\"JumpMenu('parent',this,0)\"><option value='http://www.donovandata.com/' selected='selected'>Choose site - US</option><option value='http://www.ddscanada.com/'>Choose site - CA</option><option value='http://www.mediaocean.com/'>MediaOcean</option><option value='http://www.talentpartners.com/'>Talent Partners</option><option value='http://www.dds.co.uk'>Choose site - UK</option><option value='http://www.dds.de/'>Choose site - DE</option><option value='http://www.dds.ie/'>Choose site - IE</option><option value='http://www.dds.fr'>Choose site - FR</option></select></li></ul>");
   analytics_DDSUS();
  }
}
////////////////////////////////////////////////////
// CHECK FOR A COOKIE UK
function loggedincheck_DDSUK ( cookie_name1, cookie_name2 )
{

  var results1 = document.cookie.match ( '(^|;) ?' + cookie_name1 + '=([^;]*)(;|$)' );
  var results2 = document.cookie.match ( '(^|;) ?' + cookie_name2 + '=([^;]*)(;|$)' );

  if ( results1 || results2 )
    {
		document.write("<ul><li><a href='/about/index.html' title='About DDS'>About</a></li><li><a href='/contact/index.html' title='Contact DDS'>Contact</a></li><li><a href='/careers/index.html' title='Careers at DDS'>Careers</a></li><li id='select'><select name='country selector' id='countryselector' onchange=\"JumpMenu('parent',this,0)\"><option value='' selected='selected'>Choose site - UK</option><option value='http://www.donovandata.com/'>Choose site - US</option><option value='http://www.ddscanada.com/'>Choose site - CA</option><option value='http://www.dds.de/'>Choose site - DE</option><option value='http://www.dds.ie/'>Choose site - IE</option><option value='http://www.dds.fr'>Choose site - FR</option></select></li></ul><ul id='loggedin'><li id='loggedinleft'><a href='/secure/logout.action'>Log out</a></li><li><a href='/secure/openpage.action?pageType=my-dds&key=My-DDS-5DD0D3'>Return to My DDS</a></li></ul>");
		isHomepage();
		analytics_DDSUK();
	}
  else
  {
   document.write("<ul><li><a href='/about/index.html' title='About DDS'>About</a></li><li><a href='/contact/index.html' title='Contact DDS'>Contact</a></li><li><a href='/careers/index.html' title='Careers at DDS'>Careers</a></li><li id='loginprompt'><a href='/secure/openpage.action?pageType=my-dds&amp;key=My-DDS-5DD0D3'>Log in<span id=\"for-doc\">for documentation,<br />training &amp; more</span></a></li><li><select name='country selector' id='countryselector' onchange=\"JumpMenu('parent',this,0)\"><option value='' selected='selected'>Choose site - UK</option><option value='http://www.donovandata.com/'>Choose site - US</option><option value='http://www.ddscanada.com/'>Choose site - CA</option><option value='http://www.dds.de/'>Choose site - DE</option><option value='http://www.dds.ie/'>Choose site - IE</option><option value='http://www.dds.fr'>Choose site - FR</option></select></li></ul>");
   analytics_DDSUK();
  }   
}
////////////////////////////////////////////////////
// UK analytics code for Google and one pix gif
function analytics_DDSUK(){
document.write( "<img src='http://datum.dds.co.uk/websiteresources/btracker.gif?open&login&sid=" + Math.random() + "' border='0' height='1' width='1' style='display:none;' />" + "<!-- GOOGLE ANALYTICS SCRIPT --><script type=\"text/javascript\">var _gaq = _gaq || [];_gaq.push(['_setAccount', 'UA-16144448-2']);_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();</script><!-- END GOOGLE ANALYTICS SCRIPT -->");
}
////////////////////////////////////////////////////
// CHECK FOR A COOKIE DE
function loggedincheck_DDSDE ( cookie_name1, cookie_name2 )
{

  var results1 = document.cookie.match ( '(^|;) ?' + cookie_name1 + '=([^;]*)(;|$)' );
  var results2 = document.cookie.match ( '(^|;) ?' + cookie_name2 + '=([^;]*)(;|$)' );

  if ( results1 || results2 )
    {
		document.write("<ul><li><a href='/about/index.html' title='About DDS'>About</a></li><li><a href='/contact/index.html' title='Contact DDS'>Contact</a></li><li><a href='/careers/index.html' title='Careers at DDS'>Careers</a></li><li id='select'><select name='country selector' id='countryselector' onchange=\"JumpMenu('parent',this,0)\"><option value='' selected='selected'>Choose site - DE</option><option value='http://www.dds.ie/'>Choose site - IE</option><option value='http://www.dds.fr'>Choose site - FR</option><option value='http://www.dds.co.uk'>Choose site - UK</option><option value='http://www.donovandata.com/'>Choose site - US</option><option value='http://www.ddscanada.com/'>Choose site - CA</option></select></li></ul><ul id='loggedin'><li id='loggedinleft'><a href='/secure/logout.action'>Log out</a></li><li><a href='/secure/openpage.action?pageType=my-dds&key=My-DDS-5DD0D3'>Return to My DDS</a></li></ul>");
		isHomepage();
		//analytics_DDSDE();
	}
  else
  {
   document.write("<ul><li><a href='/about/index.html' title='About DDS'>About</a></li><li><a href='/contact/index.html' title='Contact DDS'>Contact</a></li><li><a href='/careers/index.html' title='Careers at DDS'>Careers</a></li><li id='loginprompt'><a href='/secure/openpage.action?pageType=my-dds&amp;key=My-DDS-5DD0D3'>Log in<span id=\"for-doc\">for documentation,<br />training &amp; more</span></a></li><li><select name='country selector' id='countryselector' onchange=\"JumpMenu('parent',this,0)\"><option value='' selected='selected'>Choose site - DE</option><option value='http://www.dds.ie/'>Choose site - IE</option><option value='http://www.dds.fr'>Choose site - FR</option><option value='http://www.dds.co.uk'>Choose site - UK</option><option value='http://www.donovandata.com/'>Choose site - US</option><option value='http://www.ddscanada.com/'>Choose site - CA</option></select></li></ul>");
   //analytics_DDSDE();
  }
}
////////////////////////////////////////////////////
// DE analytics code for Google and one pix gif
function analytics_DDSDE(){ }
////////////////////////////////////////////////////
// CHECK FOR A COOKIE US
function loggedincheck_DDSUS ( cookie_name1, cookie_name2 )
{

  var results1 = document.cookie.match ( '(^|;) ?' + cookie_name1 + '=([^;]*)(;|$)' );
  var results2 = document.cookie.match ( '(^|;) ?' + cookie_name2 + '=([^;]*)(;|$)' );

  if ( results1 || results2 )
    {
		document.write("<ul><li><a href='/about/index.html' title='About DDS'>About</a></li><li><a href='/contact/index.html' title='Contact DDS'>Contact</a></li><li><a href='/careers/index.html' title='Careers at DDS'>Careers</a></li><li id='select'><select name='country selector' id='countryselector' onchange=\"JumpMenu('parent',this,0)\"><option value='http://www.donovandata.com/' selected='selected'>Choose site - US</option><option value='http://www.ddscanada.com/'>Choose site - CA</option><option value='http://www.mediaocean.com/'>MediaOcean</option><option value='http://www.talentpartners.com/'>Talent Partners</option><option value='http://www.dds.co.uk'>Choose site - UK</option><option value='http://www.dds.de/'>Choose site - DE</option><option value='http://www.dds.ie/'>Choose site - IE</option><option value='http://www.dds.fr'>Choose site - FR</option></select></li></ul><ul id='loggedin'><li id='loggedinleft'><a href='/secure/logout.action'>Log out</a></li><li><a href='/secure/openpage.action?pageType=my-dds&key=My-DDS-5DD0D3'>Return to My DDS</a></li></ul>");
		isHomepage();
		analytics_DDSUS();
	}
  else
  {
   document.write("<ul><li><a href='/about/index.html' title='About DDS'>About</a></li><li><a href='/openaccess/openform.action?pageType=form&formType=contact' title='Contact DDS'>Contact</a></li><li><a href='/careers/index.html' title='Careers at DDS'>Careers</a></li><li id='loginprompt'><a href='/secure/openpage.action?pageType=my-dds&amp;key=My-DDS-5DD0D3'>Log in<span id=\"for-doc\">for documentation,<br />training &amp; more</span></a></li><li><select name='country selector' id='countryselector' onchange=\"JumpMenu('parent',this,0)\"><option value='http://www.donovandata.com/' selected='selected'>Choose site - US</option><option value='http://www.ddscanada.com/'>Choose site - CA</option><option value='http://www.mediaocean.com/'>MediaOcean</option><option value='http://www.talentpartners.com/'>Talent Partners</option><option value='http://www.dds.co.uk'>Choose site - UK</option><option value='http://www.dds.de/'>Choose site - DE</option><option value='http://www.dds.ie/'>Choose site - IE</option><option value='http://www.dds.fr'>Choose site - FR</option></select></li></ul>");
   analytics_DDSUS();
  }
}
////////////////////////////////////////////////////
// US analytics code for Google and one pix gif
function analytics_DDSUS(){
document.write( "<img src='http://datum.donovandata.com/websiteresources/btracker.gif?open&login&sid=" + Math.random() + "' border='0' height='1' width='1' style='display:none;' />" + "<!-- GOOGLE ANALYTICS SCRIPT --><script type=\"text/javascript\">var _gaq = _gaq || [];  _gaq.push(['_setAccount', 'UA-16144448-1']);_gaq.push(['_setDomainName','.donovandata.com']);_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();</script><!-- END GOOGLE ANALYTICS SCRIPT -->");
}

////////////////////////////////////////////////////
// CHECK FOR A COOKIE US
function loggedincheck_DDSUS_microsite ( cookie_name1, cookie_name2 )
{

  var results1 = document.cookie.match ( '(^|;) ?' + cookie_name1 + '=([^;]*)(;|$)' );
  var results2 = document.cookie.match ( '(^|;) ?' + cookie_name2 + '=([^;]*)(;|$)' );

  if ( results1 || results2 )
    {
		document.write("<ul><li><a href='/about/index.html' title='About DDS'>About</a></li><li><a href='/contact/index.html' title='Contact DDS'>Contact</a></li><li><a href='/careers/index.html' title='Careers at DDS'>Careers</a></li></ul>");
		isHomepage();
		analytics_DDSUS();
	}
  else
  {
   document.write("<ul><li><a href='/about/index.html' title='About DDS'>About</a></li><li><a href='/openaccess/openform.action?pageType=form&formType=contact' title='Contact DDS'>Contact</a></li><li><a href='/careers/index.html' title='Careers at DDS'>Careers</a></li></ul>");
   analytics_DDSUS();
  }
}

////////////////////////////////////////////////////
// CHECK FOR A COOKIE US
function loggedincheck_DDSUS_microsite_idesklab ( cookie_name1, cookie_name2 )
{

  var results1 = document.cookie.match ( '(^|;) ?' + cookie_name1 + '=([^;]*)(;|$)' );
  var results2 = document.cookie.match ( '(^|;) ?' + cookie_name2 + '=([^;]*)(;|$)' );

  if ( results1 || results2 )
    {
		document.write("<ul><li><a href='http://lo-app-29.eu.rtdom.net/idesk/visaal_tools/fusion_charts/lab_reports/request.php' title='home'>Back to home</a></li></ul>");
		isHomepage();
		analytics_DDSUS();
	}
  else
  {
   document.write("<ul><li><a href='http://lo-app-29.eu.rtdom.net/idesk/visaal_tools/fusion_charts/lab_reports/request.php' title='home'>Back to home</a></li></ul>");
   analytics_DDSUS();
  }
}
////////////////////////////////////////////////////
// CHECK FOR A COOKIE CA
function loggedincheck_DDSCA( cookie_name1, cookie_name2 )
{

  var results1 = document.cookie.match ( '(^|;) ?' + cookie_name1 + '=([^;]*)(;|$)' );
  var results2 = document.cookie.match ( '(^|;) ?' + cookie_name2 + '=([^;]*)(;|$)' );

  if ( results1 || results2 )
    {
		document.write("<ul><li><a href='/about/index.html' title='About DDS'>About</a></li><li><a href='/contact/index.html' title='Contact DDS'>Contact</a></li><li><a href='/careers/index.html' title='Careers at DDS'>Careers</a></li><li id='select'><select name='country selector' id='countryselector' onchange=\"JumpMenu('parent',this,0)\"><option value='http://www.ddscanada.com/' selected='selected'>Choose site - CA</option><option value='http://www.donovandata.com/'>Choose site - US</option><option value='http://www.mediaocean.com/'>MediaOcean</option><option value='http://www.talentpartners.com/'>Talent Partners</option><option value='http://www.dds.co.uk'>Choose site - UK</option><option value='http://www.dds.de/'>Choose site - DE</option><option value='http://www.dds.ie/'>Choose site - IE</option><option value='http://www.dds.fr'>Choose site - FR</option></select></li></ul><ul id='loggedin'><li id='loggedinleft'><a href='/secure/logout.action'>Log out</a></li><li><a href='/secure/openpage.action?pageType=my-dds&key=My-DDS-5DD0D3'>Return to My DDS</a></li></ul>");
		isHomepage();
		//analytics_DDSCA();
	}
  else
  {
   document.write("<ul><li><a href='/about/index.html' title='About DDS'>About</a></li><li><a href='/openaccess/openform.action?pageType=form&formType=contact' title='Contact DDS'>Contact</a></li><li><a href='/careers/index.html' title='Careers at DDS'>Careers</a></li><li id='loginprompt'><a href='/secure/openpage.action?pageType=my-dds&amp;key=My-DDS-5DD0D3'>Log in<span id=\"for-doc\">for documentation,<br />training &amp; more</span></a></li><li><select name='country selector' id='countryselector' onchange=\"JumpMenu('parent',this,0)\"><option value='http://www.ddscanada.com/' selected='selected'>Choose site - CA</option><option value='http://www.donovandata.com/'>Choose site - US</option><option value='http://www.mediaocean.com/'>MediaOcean</option><option value='http://www.talentpartners.com/'>Talent Partners</option><option value='http://www.dds.co.uk'>Choose site - UK</option><option value='http://www.dds.de/'>Choose site - DE</option><option value='http://www.dds.ie/'>Choose site - IE</option><option value='http://www.dds.fr'>Choose site - FR</option></select></li></ul>");
   //analytics_DDSCA();
  }
}
////////////////////////////////////////////////////
// CA analytics code for Google and one pix gif
function analytics_DDSCA(){ }
////////////////////////////////////////////////////
// JUMP MENU
function JumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
}

////////////////////////////////////////////////////
// GENERIC FIELD VALIDATION AND ERROR MESSAGE
function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}
////////////////////////////////////////////////////
// SEARCH FIELD VALIDATION

function validate_searchfield(thisform)
{
with (thisform)
  {
  if (validate_required(sitesearch,"Please enter a term to search for.")==false)
  {query.focus();return false;}
//  else
 //  { doSearch(); }
  }
}
////////////////////////////////////////////////////
// Format date acording to browser locale settings

function formatDate( datetime_str ) { 
date_str = datetime_str.substring(0, 10);
d = dojo.date.stamp.fromISOString(date_str);
document.write( dojo.date.locale.format(d, {selector: "date", formatLength: "short"} ) );
}
////////////////////////////////////////////////////
// Get url path, compare to index.html, if matched redirect to mydds, else nothing
function isHomepage() {
	var thisDomain = (window.location.protocol + "//" + window.location.host );
	if(window.location.href == thisDomain + '/index.html' || window.location.href == thisDomain + '/')
	  { 
	  window.location = thisDomain + "/mydds"
	  }
}
