
nsdom = (document.layers) ? true:false;
iedom = (document.all) ? true:false;

function getWindowWidth() 
{
    winW = (nsdom) ? window.outerWidth : screen.width;
    return winW;		
}

function getWindowHeight() 
{
    winH = (nsdom) ? window.outerHeight : screen.Availheight;
    return winH;		
}


function popIt(theFile,wName,windowW,windowH,scrolling){

    bWidth = getWindowWidth();
    bHeight = getWindowHeight();

    bTop = (nsdom) ? this.window.screenY : 0;
    bLeft = (nsdom) ? this.window.screenX : 0;

    popLeft = ((bWidth - windowW)/2) + bLeft;
    popTop = ((bHeight - windowH)/2) + bTop;

    if (wName == null)
    {
        wName = 'pop';
    }
    if (scrolling == null){
    scrolling = "auto";
    }
    var popWindow = window.open(theFile,wName,'width='+windowW+',height='+windowH+',top='+popTop+',left='+popLeft+',scrollbars='+scrolling+',statusbar=no,toolbar=no,resizable=yes');
    popWindow.focus();
}



function alertSize() {
  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;
  }
  
  return [myWidth, myHeight];

}




function loadParent(theUrl){

	if (top.opener != null){
		top.opener.location.href = theUrl;
		opener.focus();
	}else{
		
		popWin(theUrl);
	}
	


}


function preloadImages(){

}

fLoaded = false;
function loadF(showbox){
f1off = new Image();
f1on = new Image();
f2off = new Image();
f2on = new Image();
f3off = new Image();
f3on = new Image();

f1off.src = "/images/bttn-email-article-0.gif";
f1on.src = "/images/bttn-email-article-1.gif";
f2off.src = "/images/bttn-print-friendly-0.gif";
f2on.src = "/images/bttn-print-friendly-1.gif";
f3off.src = "/images/bttn-share-article-0.gif";
f3on.src = "/images/bttn-share-article-1.gif";

fLoaded = true;

if (showbox){
emailBox();
fon(1);
}


}

boxOn = false;

function emailBox(linkId){

boxOn = true;

mailboxId = 'mailbox';

if (linkId){
mailboxId = mailboxId + linkId + '';
}

boxleft = document.getElementById(mailboxId).offsetLeft;
boxtop = document.getElementById(mailboxId).offsetTop;
boxtop += 22;

document.getElementById('mailform').style.left =  boxleft + "px";
document.getElementById('mailform').style.top =  boxtop + "px";
}


function emailBoxIssue(mode){

if (mode == 1){
boxleft = document.getElementById('mailbox').offsetLeft;
boxtop = document.getElementById('mailbox').offsetTop;
boxleft += 175;
boxtop += 95;
document.getElementById('mailform').style.left =  boxleft + "px";
document.getElementById('mailform').style.top =  boxtop + "px";
}else if (mode == 2){
boxleft = document.getElementById('issuebutton').offsetLeft;
boxleft += 199;
boxtop = document.getElementById('issuebutton').offsetTop;
boxtop -= 60;
document.getElementById('mailform').style.left =  boxleft + "px";
document.getElementById('mailform').style.top =  boxtop + "px";
}

}

function imail(boxvalue){
	if (boxvalue){
	emailBoxIssue(1);
	}
}


function closemail(theBttn){
boxOn = false;
if (theBttn == 'i'){
ioff(1);
}else{
foff(1);
}
document.getElementById('mailform').style.left =  "0px";
document.getElementById('mailform').style.top =  "-300px";
}



i1off = new Image();
i1on = new Image();
i1off.src = "/images/bttn-email-issue-0.gif";
i1on.src = "/images/bttn-email-issue-1.gif";

function ion(i) {
		imgTag = "i" + i;
		document.getElementById(imgTag).src = eval(imgTag + "on.src");
		return;
}
function ioff(i) {
		imgTag = "i" + i;
		document.getElementById(imgTag).src = eval(imgTag + "off.src");
		return;
}


function fon(i) {
		
		if(fLoaded){
		imgTag = "f" + i;
		document.getElementById(imgTag).src = eval(imgTag + "on.src");
		return;
		}
		
}

function foff(i) {

	if(fLoaded){
		if (i != 1){
		imgTag = "f" + i;
		document.getElementById(imgTag).src = eval(imgTag + "off.src");
		return;	
		}else{
			if (!boxOn){
			imgTag = "f" + i;
			document.getElementById(imgTag).src = eval(imgTag + "off.src");
			return;	
			}
		}
	}
			
}



function tost(){

	
	return confirm("By clicking 'OK' and subscribing to The Beat, you acknowledge that content contained in The Beat ~ a travel business newsletter, is protected by copyright, and that it is illegal under U.S. federal law to copy, fax or electronically distribute copyrighted material. This includes email forwarding.","I Agree","I Disagree");
	

}

function tos(){
	
	 
	if (confirm("By clicking 'OK' and subscribing to The Beat, you acknowledge that content contained in The Beat ~ a travel business newsletter, is protected by copyright, and that it is illegal under U.S. federal law to copy, fax or electronically distribute copyrighted material. This includes email forwarding.","I Agree","I Disagree")){
	
	
	return true;
		/*
		emailCatch();	
		*/
		
		
		
	}else{
	
	return false;
	
	}

}


function emailCatch(){

response = 	prompt("Please enter an administrative email address to subscribe under. You will be able to add a total of 10 recipient addresses once you subscribe.");
		
		if (response){
		
		return true;
			
		}else{
			if (response == ""){
				if (confirm("You must enter a recipient email address in order to subscribe to The Beat")){
					
					emailCatch();
				
				}else{
				
				return false;
				
				}
			}

		}


}

function jump2issue(sel)
{
	for (j=0; j<sel.options.length; j++) {
		if (sel.options[j].selected) {
		  window.location.href = "/show-issue.php?isid=" + sel.options[j].value;
		  return;
			}
		}
}

/*
function archiveListing(dir){

location.href= "/archives.php?pid=checkuser&index=" + dir;

}
*/


function validateSubEmail(address){

	if (address.length > 50){
		alert("The email address you entered contains too many characters. Please choose a sending email address with fewer characters.  Thank You.");
		return false;
	}

pattern = /^[\._'\-\w]+@[_'\-\w]+\.([\._'\-\w]+\.)?([a-z]{2,6})$/i;

result = address.match(pattern);

	if (result){
		procMssg();
		return true;
	}else{
		alert("The email address you entered appears to be INVALID. Please check your entry for errors and try again.");
		return false;
	}
	
}


function validateEmail(address,whomail){

	if (address.length > 50){
		if (!whomail){
		alert("The sender's email address contains too many characters. Please choose a sending email address with fewer characters.  Thank You.");
		}else{
		alert("One of the email addresses you are sending to contains too many characters. Please choose a recipient email address with fewer characters.  Thank You.");
		}
		return false;
	}


pattern = /^[\._'\-\w]+@[_'\-\w]+\.([\._'\-\w]+\.)?([a-z]{2,6})$/i;

result = address.match(pattern);

	if (result){

		return true;

	}else{
	
		if (!whomail){
		alert("The sender's email address appears to be INVALID. Please check your entry for errors and try again.");
		}else{
		alert("One or more of the recipient email addresses appears to be INVALID. Please check your entries for errors and try again.");	
		}
	
		return false;
	
	}
}

function checkPasswd(pwd1,pwd2){

	if (pwd1.length < 6){
		alert("Please choose a password that is at least 6 characters long");
		return false;
	}else{
	
		pattern = /^([a-zA-Z0-9_]+)$/i;

		result = pwd1.match(pattern);

		if (!result){
		
			alert("Please use only alphanumeric characters in your password");
			return false;
			
		}else{
		
			if (pwd1 == pwd2){
			
			return true;
			
			}else{
			
			alert("Your password entries did not match.  Please reenter the password and password confirm fields and try again.");
			
			return false;
			
			}
			
		}
		
	}

	

}

lastSlog = 1;

function sloggle(slogId){

newSlog = new Object;
oldSlog = new Object;

newSlog = eval("document.getElementById('slog"+slogId+"')");
oldSlog = eval("document.getElementById('slog"+lastSlog+"')");

oldSlog.style.display = "none";
newSlog.style.display = "block";

lastSlog = slogId;

}


function setResultsString(theResultString){

	if(theResultString){
		document.getElementById('resultstringdiv').innerHTML = theResultString;
	}
	
}

function mssg(message,destinationUrl){

alert(message);

location.href = destinationUrl;

}

badcharsArray1 = new Array('!','@','`','~','#','$','%','^','&','*','(',')','+','=',':',';','"','?','/','\\','{','}','[',']',',','<','>');
badcharsArray2 = new Array('@','`','~','#','$','%','^','&','*','(',')','+','=',';','/','\\','{','}','[',']','<','>');

ok = true;

function validateForm(theForm){

	
	if (validateEmail(theForm.frommail.value,0)){
	
		emailArray = new Array();
		emailArray = theForm.tomail.value.split(',');
				
		
		if (emailArray.length > 5){
			alert("You have specified more than 5 recipients for this issue.  Please enter a maximum of 5 recipients.  Thank you.");
			ok = false;
		}else{
		
			for (e = 0; e < emailArray.length; e++){
				
				if (!validateEmail(emailArray[e],1)){				
					ok = false;
				}
			}

			
		}
		
	}else{
	
	ok = false;
	}
	
	if (ok){
	
		if (noBadChars(theForm.comments.value,badcharsArray2)){
		
			return true;
			
		}else{
		
			alert("The comments you entered contain characters that are not permitted in this form. Please use alphanumeric characters and basic punctuation only.");
			return false;
			
		}
	
	}else{
	
		ok = true;
	
		return false;

	}


}


function noBadChars(theString,theArray){
	
	if (theString != ''){
		
		for (s = 0; s < theArray.length; s++){
			
			if(theString.indexOf(theArray[s]) != -1){				
	
				return false;
			}
			
		}
		
		return true;
		
	}else{
		return true;
	}

}


function procMssg(){

alert('Note: Complimentary subscriptions to the printed version of Procurement.travel are limited to the U.S., Canada, and U.S. possessions. The publisher reserves the right to limit the number of free subscriptions, and will only accept applications which meet the qualification criteria for the publication.');

}


var ie = (document.all) ? true : false;

function txtsize(pixels,mod){

if (!mod){
mod = '';
}

divArray = new Array("newscopy","newsdate","content");
classArray = new Array("contentlink");
elementArray = new Array("h1");


var min=11;
var max=18;
var defaultfont = 12;
var defaultlineheight = 19;
var defaulttitle = 23;
var currentfontsize;

	/*
   var p = document.getElementsByTagName('h1');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = defaulttitle;
      }
      if(s!=max) {
         s += pixels;
      }
      p[i].style.fontSize = s+"px";
   }
   */
   

   divs = '';
   
    theDiv = new Object();

   for(i=0;i<divArray.length;i++){
    theDivName = divArray[i];
  
   	theDiv = document.getElementById(theDivName);
   	
   	if (theDiv){
      
      if(theDiv.style.fontSize) {
         var s = parseInt(theDiv.style.fontSize.replace("px",""));
      } else {
         var s = defaultfont;
      }
     
      

      currentsize = s;
      if(pixels > 0) {
      	document.getElementById('textminus').src = "/images/bttn-txtminus" + mod + "-1.gif";
      	if (s!=max){
         s += pixels;
         }
		  if(s!=max){
			 document.getElementById('textplus').src = "/images/bttn-txtplus" + mod + "-1.gif";	
		  }else{
			 document.getElementById('textplus').src = "/images/bttn-txtplus" + mod + "-0.gif";
		  }
      }else{
      	document.getElementById('textplus').src = "/images/bttn-txtplus" + mod + "-1.gif";
      	if (s!=min){
         s += pixels;
		}
		  if(s!=min){
			 document.getElementById('textminus').src = "/images/bttn-txtminus" + mod + "-1.gif";	
		  }else{
			 document.getElementById('textminus').src = "/images/bttn-txtminus" + mod + "-0.gif";
		  }

      }
     
      
      
      theDiv.style.fontSize = s+"px";
      theDiv.style.lineHeight = (s+7)+"px";
      
      }
     

   }
  
      for(i=0;i<classArray.length;i++){
      
      className = classArray[i];
      setStyleByClass('A', className, 'fontSize', document.getElementById('newscopy').style.fontSize);
      setStyleByClass('A', className, 'lineHeight', document.getElementById('newscopy').style.lineHeight);
      
      }

	
}



// setStyleByClass: given an element type and a class selector,
// style property and value, apply the style.
// args:
//  t - type of tag to check for (e.g., SPAN)
//  c - class name
//  p - CSS property
//  v - value


function setStyleByClass(t,c,p,v){
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					eval('node.style.' + p + " = '" +v + "'");
				}
			}
		}
	}
}


