
var beatlock = 0;
var lockedEmail = '';
var thisMenu = new Object;
var theTimer;
var validEmail = false;
var ePattern = /^[\._'\-\w0-9]+@[_'\-\w0-9]+\.([\._'\-\w0-9]+\.)?([a-z]{2,6})$/i;
var companyMatch = '';

pubcount = 0;
otherpub = 0;

function showMenu(menuName){

if (thisMenu.id != null){
	clearMenu();
}
if (theTimer != null){
clearTimeout(theTimer);
}

theMenu = new Object;
theMenu = eval("document.getElementById('" + menuName + "')");

theMenu.style.visibility = "visible";

}


String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}


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];

}


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,windowW,windowH,wName,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 loadParent(theUrl){

	if (top.opener != null){
		top.opener.location.href = theUrl;
		opener.focus();
	}else{
		
		popWin(theUrl);
	}
	


}


function preloadImages(){

}


function tost(){

	
	return confirm("By clicking \"OK\" and subscribing to The Beat you acknowledge that the title \"The Beat\" and the tagline, \"A Travel Business Newsletter\", are 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 the title \"The Beat\" and the tagline, \"A Travel Business Newsletter\", are 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.")){
	
	
	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 archiveListing(sel)
{
	for (j=0; j<sel.options.length; j++) {
		if (sel.options[j].selected) {
		  window.location.href = "/archives.php?pid=checkuser&index=" + sel.options[j].value;
		  return;
			}
		}
}


function checkOther(sel)
{
		if (sel.options[8].selected) {
		  document.getElementById("jobfunctiontext").style.display = "block";
		}else{
		  document.getElementById("jobfunctiontext").style.display = "none";
		}
		  return;
}


function checkOther2(sel)
{
		if (sel.options[22].selected) {
		  document.getElementById("orgactivitytext").style.display = "block";
		}else{
		  document.getElementById("orgactivitytext").style.display = "none";
		}
		  return;
}




/*
function archiveListing(dir){

location.href= "/archives.php?pid=checkuser&index=" + dir;

}
*/


function validateForm(theForm){

	goodForm = 0;

	if(checkChoices(theForm)){
	goodForm = 1;
	}else{
	goodForm = 0;
	}

	
	if (goodForm){
	
		
		if (theForm.elements['fname'].value.length >= 2 && theForm.elements['lname'].value.length >= 2){
		
		goodForm = 1;
		
		}else{
		alert('The first name or last name you entered appears to be too short to be valid. Please check your entry for errors.');
		goodForm = 0;
		}
		
	}
	
	if (goodForm){
	goodForm = validateEmail(theForm.elements['email'].value);
	}
	
	if (goodForm){
	
		theSelectedIndex = theForm.elements['discover'].selectedIndex;
			
		if (theSelectedIndex == 0){
		alert('Please indicate how you found us by selecting an option from the drop down list');
		goodForm = 0;
		}else{
		goodForm = 1;
		}
	
	}

	if (goodForm){
	return true;
	}else{
	return false;
	}

}


function checkChoices(theForm){
	
	land = 0;
	film = 0;
	
	if (theForm.elements['land'].checked == true){
	
	land = 1;
	
	}
		
	if (theForm.elements['film'].checked == true){
	
	film = 1;
	
	}

	if (!parseInt(film) && !parseInt(land)){
	alert('Please select at least one mailing list option (Film, Land, or both)');
	return false;
	}else{
	return true;
	}
	
	
}
	


function existingAccountCheck(address){

	address.trim();
	
	if (address.length > 80){
	alert("The email address you entered appears to contain too many characters to be valid. Please choose an email address with fewer characters.  Thank You.");
	return false;
	}
		
	result = address.match(ePattern);

	if (result){
		validEmail = true;
		return false;
		//accountXMLquery(address);

	}else{
		validEmail = false;
		
		alert('The email address you entered does not appear to be valid. Please check your entry for errors and try again');
		return false;
	}
	
}


function validateEmail(address){

	if (address.length > 80){
	alert("The email address you entered contains too many characters. Please choose an email address with fewer characters.  Thank You.");
	return false;
	}

	result = address.match(ePattern);

	if (result){

		return true;	
		
	}else{
	
	alert("The email address you entered is NOT valid, please check your entry 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 do not match.  Please reenter the password and password confirm fields and try again.");
			
			return false;
			
			}
			
		}
		
	}

	

}
*/



function checkSubForm(theForm){

if (!theForm){
theForm = new Object();
theForm = document.forms["subscriptions"];
}

statesel = new Object();
statesel = theForm.elements["state"];

countrysel = new Object();
countrysel =theForm.elements["country"];

fnamevalue = new Object();
fnamevalue = theForm.elements["fname"].value;

lnamevalue = new Object();
lnamevalue = theForm.elements["lname"].value;

address1value = new Object();
address1value = theForm.elements["address1"].value;

address2value = new Object();
address2value = theForm.elements["address2"].value;


zipvalue = new Object();
zipvalue = theForm.elements["zip"].value;

cityvalue = new Object();
cityvalue = theForm.elements["city"].value;


if (!fnamevalue){
alert("Please provide a first name for your Procurement.travel subscription.");
return false;
}

if (!lnamevalue){
alert("Please provide a last name for your Procurement.travel subscription.");
return false;
}

if (!address2value){
alert("In the first address field, please enter a street address or PO Box for your Procurement.travel subscription.");
return false;
}

//if (!address2value){
//alert("In the first address field, please enter a street address or PO Box for your Procurement.travel subscription.");
//return false;
//}


if (statesel.options[0].selected){
alert("Please select a state or province for your Procurement.travel subscription.");
return false;
}

if (!zipvalue){
alert("Please enter your zip or postal code for your Procurement.travel subscription." );
return false;
}

if (!cityvalue){
alert("Please enter the name of the city or town for your Procurement.travel subscription.");
return false;
}


if (countrysel.options[0].selected){
alert("Please select a country in the drop down menu for your Procurement.travel subscription.");
return false;
}

return true;

}



function getRadioValue(theRadioField) {
	for (index=0; index < theRadioField.length; index++) {
		if (theRadioField[index].checked) {
			return theRadioField[index].value;
			break;
		}
	}
}

function setRadioValue(theRadioField,theValue) {
	for (index=0; index < theRadioField.length; index++) {
		if (theRadioField[index].value == theValue) {
			theRadioField[index].checked = true;
			return theRadioField[index].value;
		}else{
			theRadioField[index].checked = false;
		}
	}
}


function winSize() {
  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];

}


accountCheck = 0;

function accountXMLquery(email){

			
		var xmlhttp =  new XMLHttpRequest();
		xmlhttp.open('GET', 'http://www.promedia.travel/php/existingAccountCheck.php?email=' + email);

		xmlhttp.onreadystatechange = function() {
					
			if (xmlhttp.readyState == 4) {
				
				if (xmlhttp.status == 200){
								  
				  resultcode = xmlhttp.responseXML.getElementsByTagName('result')[0].firstChild.data;
				  
				  if (resultcode == 1){
				  
					accountCheck = 1;
					
					setDlogCopy('<span style="color: #cc5818; font-size: 13px;">It appears you already have an account with us.<br/>Please log in below to make changes to your account</span>','dlogcopy');
					
					currentEmail = document.forms['subscriptions'].elements['email'].value;
					
					document.forms['subserviceslogin'].elements['email'].value = currentEmail;
					//document.forms['subserviceslogin'].elements['password'].value = '';
					
					//alert(currentEmail);
					
					$('img.loginBttn').trigger('click');
					$('img.overlayBttn_login').trigger('click');
					
					accountCheck = 0;
				
				  }
				  
				
				}
			
			}
			
		}
		

		xmlhttp.send(null);			
				
}

/*
$(function() {
    checkCookie();
});
*/


function setDlogCopy(theString,theDlogId){

if (theDlogId){
$('#' + theDlogId).html(theString);
}

}

buttonSets = new Array('buttonSet_found','buttonSet_notfound','buttonSet_existing','buttonSet_ok','buttonSet_oklock');

function setDlogButtons(buttonSet){


	for (b = 0; b < buttonSets.length; b++){
	
		$('#' + buttonSets[b]).hide();
	
	}
	
	
	$('#dlogbuttons').show();
	
	for (b = 0; b < buttonSets.length; b++){
	
		if (buttonSets[b] == buttonSet){
		$('#' + buttonSet).show();
		}
	
	}

}

function toggleDiv(theDiv){
	
if (!currentTab){
currentTab = theDiv;
}

	//document.getElementById('messagebox').style.display = 'none';
	
	if (theDiv.id != currentTab.id){
	theDiv.className = 'pubtab';
	currentTab.className = 'pubtaboff';


	theDivPaneId = theDiv.id + '_pane';
	theDivPane = new Object();
	theDivPane = document.getElementById(theDivPaneId);
	theDivPane.style.display = 'block';
	
		
	currentTabPaneId = currentTab.id + '_pane';
	currentTabPane = new Object();
	currentTabPane = document.getElementById(currentTabPaneId);
	currentTabPane.style.display = 'none';
	
	currentTab = theDiv;
	}

}

function toggleTab(theDiv){
		
	if (theDiv.id != currentTab.id){
	location.href = "http://www.promedia.travel/subscriber-services_beat_admin.php?s=" + theDiv.id;
	}

}


function radioChangeCheck(radioObject,radioMatchValue){

	if (getRadioValue(radioObject) == radioMatchValue){
	alert('Your selection has not changed');
	return false;
	}else{
	return true;
	}

}

function hilite(divObj,active){

	if (active){
	divObj.className = 'movieblockactive';
	}else{
	divObj.className = 'movieblock';
	}

}


function castVote(){

		document.forms['postervote'].elements['votebutton'].value = 'One Moment...';
		document.forms['postervote'].elements['votebutton'].disabled = true;
				
		ipValue = document.forms['postervote'].elements['ip'].value;
		
		
		theVoteObject = document.forms['postervote'].elements['poster'];
		theVoteValue = getRadioValue(theVoteObject);
	
		
		if (theVoteValue != 'undefined'){
		
		var xmlhttp =  new XMLHttpRequest();
		xmlhttp.open('GET', 'http://www.taoslandandfilm.com/php/poster_vote.php?vote=' + theVoteValue + '&ip=' + ipValue + '');
				
		xmlhttp.onreadystatechange = function() {
				
			
			if (xmlhttp.readyState == 4) {
				
				if (xmlhttp.status == 200){
								  
				  resultcode = xmlhttp.responseXML.getElementsByTagName('result')[0].firstChild.data;
				   
				  if (resultcode == 1){
				  
				    document.forms['postervote'].elements['votebutton'].value = 'Thank You!';					
				
				  }else{
				  
				  	document.forms['postervote'].elements['votebutton'].value = 'Already Voted!';
				  
				  }
				  
				
				}
			
			}
			
		}
		

		xmlhttp.send(null);	
		}else{
		alert("Please choose your favorite poster");
		}
		
				
				
}


function add_product(productInfo){

//productInfo.buynowsubmit.value = 'Wait...';
//productInfo.buynowsubmit.disabled = true;

product_id = productInfo.product_id.value;

//alert(product_id);

		var xmlhttp =  new XMLHttpRequest();
		xmlhttp.open('GET', 'http://www.taoslandandfilm.com/php/cart/add_item.php?pid=' + product_id);
				
		xmlhttp.onreadystatechange = function() {
				
			
			if (xmlhttp.readyState == 4) {
				
				if (xmlhttp.status == 200){
								  
				  	resultcode = xmlhttp.responseXML.getElementsByTagName('result')[0].firstChild.data;
				    sessionID = xmlhttp.responseXML.getElementsByTagName('session_id')[0].firstChild.data;
				    productTitle = xmlhttp.responseXML.getElementsByTagName('product_title')[0].firstChild.data;
				    productCount = xmlhttp.responseXML.getElementsByTagName('product_count')[0].firstChild.data;
					ferror = xmlhttp.responseXML.getElementsByTagName('ferror')[0].firstChild.data;
					
				   
				  if (resultcode == 1){
				  			
				  	//alert(productTitle);	    
					//showCartMessage(productTitle);
					//updateCart(productCount);
					return true;
							
				  }else{
				  
				  	alert('There was an error that prevented this product from being added to your shopping cart');
				  	return false;
				  	
				  }
				  
				
				}else{
				
			
				return true;
				}
			
			}else{
			
			return true;
			}
			
		}
		

		xmlhttp.send(null);			


}


function showCartMessage(productTitle){

buynowbox = document.getElementById('buynowbox');
buynowbox.innerHTML = '<i>' + productTitle + '</i> has been added to your cart. You will be able to change the quantity during checkout';
document.getElementById('hidecheckout').style.display = 'block';

}

function updateCart(productCount){

//alert(productCount);


}





