  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();


function GetXmlHttpObject() {
         if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            return new XMLHttpRequest();
         }
         if (window.ActiveXObject) {
            // code for IE6, IE5
            return new ActiveXObject("Microsoft.XMLHTTP");
         }
         return null;
}


function getCheckedValueRADIO(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}



function getCheckedValuesCHECKBOX(checkboxObj) {
  var checkboxvalues = '';
	if(!checkboxObj)
		return "";
	var checkboxLength = checkboxObj.length;
	if(checkboxLength == undefined)
		if(checkboxObj.checked)
			return checkboxObj.value;
		else
			return "";
	for(var i = 0; i < checkboxLength; i++) {
		if(checkboxObj[i].checked) {
                  if(i!=0 && checkboxvalues != '') {
                    checkboxvalues = checkboxvalues+',';
                  }
			checkboxvalues = checkboxvalues+""+checkboxObj[i].value;
		}
	}
	return checkboxvalues;
}





function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}




// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}





// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}





function pad2(number) {
  return (number < 10) ? '0' + number : number;
}





function switch_tabs(tab_id,tab_group,off_color,on_color) {
 var alltabsid = document.getElementsByName(tab_group);

 for(var i=0; i<alltabsid.length; i++) {
   alltabsid[i].style.backgroundColor = "#"+off_color;
 }
 document.getElementById(tab_id).style.backgroundColor = "#"+on_color;
}





function IsNumeric(sText) {
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   return IsNumber;

}



function rand ( n )
{
  return ( Math.floor ( Math.random ( ) * n + 1 ) );
}



function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

		   return false
		}
}



function header_opencountry(iscountryselected,country) {
  if(iscountryselected == false) {
    if(document.getElementById('header_countrymenu_open').innerHTML == 'false') {
      document.getElementById('header_countrymenu').style.display = 'block';
      document.getElementById('header_countrymenu_open').innerHTML = 'true';
    }else{
      document.getElementById('header_countrymenu').style.display = 'none';
      document.getElementById('header_countrymenu_open').innerHTML = 'false';
    }
  }else{
    if(country != 'World') {
      Set_Cookie("visitor_country",country,"365","/","","");
      window.location.href='/';
    }else{
      Delete_Cookie("visitor_country","/","");
      window.location.href='/';
    }
  }

}


function createTable(RowBgColor,headersbgColor,colWidths,colHeaders,colValues,insertDIV,RowID) {
  //RowID is not neccessary and will be substituted by this script if not present. However, if 1 is present, all row ID's must be present.
  //All RowID's will be preceded by the ID of "'insertDIV'_RowID_'RowID'" for clarification & to help ensure no clashes between DIV id's are present.
  //Providing RowID's allows for future functionality if you wish to hide a row without reloading the table from the server again.
  colWidths = colWidths.split("-");
  colHeaders = colHeaders.split("-");
  RowBgColor = RowBgColor.split("|"); // Enter 6 char colors,NONE or '' for complete none
    if(RowID != undefined) { RowID = RowID.split("|"); }else{ RowID = ''; }
  if(colValues != '') { colValues = colValues.split("|"); }
  var headers_ready = "<DIV class='TR bd1SA'>"; var values_ready = '';
  if(colValues.length == 0) {
    for(i2=0;i2<colHeaders.length;i2++) {
      headers_ready+="<DIV class='TD bd1SA pad5 alC fwB arl12 col85' style='width:"+colWidths[i2]+"; background-color:#"+headersbgColor+"'>"+colHeaders[i2]+"</DIV>"; if(i2==(colHeaders.length - 1)) { headers_ready+="</DIV>"; }
    }
    values_ready = "<DIV class='TR'><DIV class='TD pad10 alC arl11 col5 bd1SA' colspan='"+colHeaders.length+"'>No Values Found</DIV></DIV>";
  }else{
    for(i=0;i<colValues.length;i++) {
      enterValues = colValues[i].split("-");
      values_ready+="<DIV class='TR bd1SA' style='"; if(RowBgColor[i] != 'NONE' && RowBgColor[i] != undefined && RowBgColor[i] != '') { values_ready+="background-color:#"+RowBgColor[i]; } values_ready+="' id='"; if(RowID[i] != 'NONE' && RowID[i] != undefined && RowID[i] != '') { values_ready+=insertDIV+"_RowID_"+RowID[i]; }else{ values_ready+=insertDIV+"_RowID_"+i; } values_ready+="'>";
      for(i2=0;i2<colHeaders.length;i2++) {
        if(i==0) {
          headers_ready+="<DIV class='TD bd1SA pad5 alC fwB arl12 col85' style='width:"+colWidths[i2]+"; background-color:#"+headersbgColor+"'>"+colHeaders[i2]+"</DIV>"; if(i2==(colHeaders.length - 1)) { headers_ready+="</DIV>"; }
        }
        values_ready+="<DIV class='TD bd1SA pad5 alC arl11 col5' style='width:"+colWidths[i2]+"'>"+enterValues[i2]+"</DIV>"; if(i2==(colHeaders.length - 1)) { values_ready+="</DIV>"; }
      }
    }
  }
  document.getElementById(insertDIV).innerHTML = "<DIV class='TBL bdCOLL'>"+headers_ready+values_ready+"</DIV>";
}



function fieldstoPHParray(field,keepIfEmpty,phparrayname) {
  if(!phparrayname || phparrayname == '') {
    phparrayname = 'fields';
  }
  var addparams = '';
  field = document.getElementsByName(field);
  for(i=0;i<field.length;i++) {
    if(field[i].type == 'select-one') {
      if(field[i].options[field[i].selectedIndex].value != '' || keepIfEmpty == true) { addparams += "&"+phparrayname+"["+field[i].id+"]="+field[i].options[field[i].selectedIndex].value; }
    }else if((field[i].type == 'checkbox' || field[i].type == 'radio') && field[i].checked == true) {
      addparams += "&"+phparrayname+"["+field[i].id+"]="+field[i].value;
    }else if(field[i].type == 'text' || field[i].type == 'textarea' || field[i].type == 'hidden') {
       if(field[i].value != '' || keepIfEmpty == true) { addparams += "&"+phparrayname+"["+field[i].id+"]="+field[i].value.replace(/&/g,"AND").replace(/%/g,"pc"); }
    }
  }
  return addparams;
}

function page_request(waitDIV, waitICON, pageid, pageAction, params) {
  /*
  --> WaitDIV, WaitICON may be left empty if nothing will be returned
  --> params may be left empty.
  */
  if(waitDIV != '') {
    document.getElementById(waitDIV).innerHTML = "<DIV class='alC arl11 col85'>"+
                                                    "<img src='/Sources/images/waiting/wait"+waitICON+".gif' alt='Please Wait...' style='height:30px; width:30px'>"+
                                                    "</DIV>";
  }
    xmlhttp=GetXmlHttpObject();
         if (xmlhttp==null) {
            alert ("Browser does not support HTTP Request");
            return;
         }
         xmlhttp.onreadystatechange= function() {
           if(xmlhttp.readyState==4) {
             document.getElementById('AJAX_report').innerHTML = xmlhttp.responseText;
             if(document.getElementById('Jeval') != null) {
               eval(document.getElementById('Jeval').innerHTML);
               document.getElementById('AJAX_report').innerHTML = '';
             }else{
               document.getElementById('AJAX_report').innerHTML = '';
             }
           }
         }
         xmlhttp.open("POST",pageid+"?pageAction="+pageAction+"&sid="+Math.random(),true);
         xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
         xmlhttp.setRequestHeader("Content-length", params.length);
         xmlhttp.setRequestHeader("Connection", "close");
         xmlhttp.send(params);
}


function giveToDiv(givDIV,recDIV) {
  document.getElementById(recDIV).innerHTML = document.getElementById(givDIV).innerHTML;
}


function FunctionsWindow(titleFavicon, Title,Open,sourceTable,pageRequested,pageAction,params,manual_width,manual_height) {
  /*
  titleFavicon MUST be 30px by 30px and consists of ONLY a url
  Always start params with an ampersand.
  All Serverside functions to display need to be returned to DIV id: FunctionsWindow_DIV.
  All Results MUST MUST MUST be echoed to "FunctionsWindow_DIV" for this to work.
  */

  var DIV = document.getElementById('MainResultMoreInfoDiv');
  var infoDIV = document.getElementById('autoResultMoreInfo');
  if(Open == true) {

    DIV.style.display = 'block'; DIV.style.width = ScreenWidth(); DIV.style.height = ScreenHeight();
    infoDIV.style.display = 'block'; if(manual_width == '') { infoDIV.style.width = ((ScreenWidth()/4)*3); }else{ infoDIV.style.width = manual_width+'px'; } if(manual_height == '') { infoDIV.style.height = ((ScreenHeight()/4)*3); }else{ infoDIV.style.height = manual_height+'px'; } infoDIV.style.left = ScreenWidth()/8;  infoDIV.style.top = ScreenHeight()/8;
    var insertintoDIV = "<DIV class='disNONE' id='sourceTable'>"+sourceTable+"</DIV><DIV class='flL pad5 colA fwB arl16 bl2SA bt2SA br2SA bgF bdtlrad10' style='margin-top:-32px; margin-left:-2px'>"; if(titleFavicon != '') { insertintoDIV+="<IMG src='"+titleFavicon+"' alt='' align='top' border='0' width='20' height='20'> &nbsp; - &nbsp; "; } insertintoDIV+=Title+"</DIV><DIV class='flR pad5 arl15 bl2SA bt2SA br2SA bgE bdtrrad10' style='margin-top:-35px; margin-right:-2px'><A href='javascript:;' class='style1 pad5' onclick=\"FunctionsWindow('',false)\"><SPAN class='col5 fwB'>&#10007</SPAN> <SPAN class='colRED'>Close</SPAN></A></DIV><DIV class='clB'></DIV>"+
                    "<DIV class='ofyS' style='height:"+infoDIV.style.height+"'><DIV class='pad10 arl12 col5 alL mrgt40 mrgl40'><DIV id='FunctionsWindow_DIV'><DIV class='alC arl11 col85' style='padding-top:80px'><img src='/Sources/images/waiting/wait1.gif' alt='Please Wait...' style='height:30px; width:30px'></DIV></DIV>";


    infoDIV.innerHTML=insertintoDIV+"</DIV></DIV>";
    timeout[DIV.getAttribute('Name')] = setTimeout("fadingsequence('in','"+DIV.getAttribute('Name')+"',0,6,50,'"+DIV.getAttribute('Name')+"','')",50);
    page_request('', '', pageRequested, pageAction, params+'&InfoDivWidth='+(parseInt(infoDIV.style.width)-81));
  }else{
    infoDIV.style.display = 'none';
    infoDIV.innerHTML = '';
    timeout[DIV.getAttribute('Name')] = setTimeout("fadingsequence('out','"+DIV.getAttribute('Name')+"',6,0,50,'"+DIV.getAttribute('Name')+"','')",50);
  }
}



var timeout = new Array();




function fadingsequence(inorout,DIV,opacitynext,opacityend,speed,timeoutID,endFunctionDIV) {
  //endFunctionDIV is optional, specifiy a div with javascript in it to perform at end of fade
  var DIV = document.getElementsByName(DIV);
  for(i=0;i<DIV.length;i++) {
    if(opacitynext == 0 && inorout == 'out') { DIV[i].style.display = "none"; }else if(opacitynext > 0 && inorout == 'in') { DIV[i].style.display = "block"; }
    DIV[i].style.opacity = opacitynext/10;
    DIV[i].style.filter = '"progid:DXImageTransform.Microsoft.Alpha(Opacity=' + opacitynext*10 + ')"; alpha(opacity=' + opacitynext*10 + ')';

  }
  if(opacitynext != opacityend) {
    if(inorout == 'in') {
      timeout[timeoutID] = setTimeout("fadingsequence('in','"+DIV[0].getAttribute('Name')+"',"+(opacitynext+1)+","+opacityend+","+speed+",'"+timeoutID+"','"+endFunctionDIV+"')",speed);
    }else{
      timeout[timeoutID] = setTimeout("fadingsequence('out','"+DIV[0].getAttribute('Name')+"',"+(opacitynext-1)+","+opacityend+","+speed+",'"+timeoutID+"','"+endFunctionDIV+"')",speed);
    }
  }else if(typeof(endFunctionDIV) != 'undefined' && endFunctionDIV != ''){
    eval(document.getElementById(endFunctionDIV).innerHTML);
  }
}


function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		document.getElementById(limitCount).innerHTML = limitNum - limitField.value.length;
	}
}


function ScreenWidth()
{
        var x = 0;
        if (self.innerHeight)
        {
                x = self.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                x = document.documentElement.clientWidth;
        }
        else if (document.body)
        {
                x = document.body.clientWidth;
        }
        return x;
}

function ScreenHeight()
{
        var y = 0;
        if (self.innerHeight)
        {
                y = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                y = document.documentElement.clientHeight;
        }
        else if (document.body)
        {
                y = document.body.clientHeight;
        }
        return y;
}


