

/* ------------------------------------------------------------------------------------------------------------------------------- */
function displayPrivacy() {
	var myBars = 'directories=no,location=no,menubar=no,status=yes,titlebar=yes,toolbar=no';
	var myOptions ='scrollbars=yes,width=600,height=220,resizable=yes';
	var myFeatures = myBars + ',' + myOptions;
	var refWindow = open('http://www.dragondoor.com/includes/privacy_policy.html', 'ref_Win', myFeatures);
}

/* ------------------------------------------------------------------------------------------------------------------------------- */
function newletterSubscribe() {
	var myBars = 'directories=no,location=no,menubar=no,status=yes';
	myBars += ',titlebar=yes,toolbar=no';
	var myOptions ='scrollbars=yes,width=545,height=550,resizable=yes';
	var myFeatures = myBars + ',' + myOptions;
	var refWindow = open('http://www.dragondoor.com/includes/newsubpop.html', 'ref_Win', myFeatures);
}



/* ------------------------------------------------------------------------------------------------------------------------------- */
function displayPic(imgsrc,width,height) {
	var myBars		= 'directories=no,location=no,menubar=no,status=yes,titlebar=yes,toolbar=no';
	var myOptions	='scrollbars=yes,width='+width+',height='+height+',resizable=yes';
	var myFeatures	= myBars + ',' + myOptions;
	var refWindow	= open('http://www.dragondoor.com/blank.html', 'ref_Win', myFeatures);
	var content		= '<html><body><img src="'+imgsrc+'"><br><center> ';
	content			+= '<a href="javascript:window.close()">Close this window </a></center></body></html>';
	refWindow.document.write(content);
	refWindow.document.close();
}

/* ------------------------------------------------------------------------------------------------------------------------------- */
function displayPopup(pagesrc,width,height) {
	var myBars		= 'directories=yes,location=yes,menubar=yes,status=yes,titlebar=yes,toolbar=yes';
//	var myBars		= 'directories=no,location=no,menubar=no,status=yes,titlebar=yes,toolbar=no';
	var myOptions	='scrollbars=yes,width='+width+',height='+height+',resizable=yes';
	var myFeatures	= myBars + ',' + myOptions;
//	var refWindow	= window.open('http://www.dragondoor.com/blank.html', 'ref_Win', myFeatures);
	var refWindow	= window.open('', 'ref_Win', myFeatures);
	//var content		= '<html><body><img src="'+imgsrc+'"><br><center> ';
	//content			+= '<a href="javascript:window.close()">Close this window </a></center></body></html>';
	refWindow.document.open();
	refWindow.document.write(pagesrc);	
	refWindow.document.close();
}

/* ------------------------------------------------------------------------------------------------------------------------------- */
function displayBarePopup(pagesrc,width,height) {
	//var myBars		= 'directories=yes,location=yes,menubar=yes,status=yes,titlebar=yes,toolbar=yes';
	var myBars		= 'directories=no,location=no,menubar=no,status=yes,titlebar=yes,toolbar=no';
	var myOptions	='scrollbars=yes,width='+width+',height='+height+',resizable=yes';
	var myFeatures	= myBars + ',' + myOptions;
	var refWindow	= window.open('', 'ref_Win', myFeatures);
	refWindow.document.open();
	refWindow.document.write(pagesrc);	
	refWindow.document.close();
}

/* ------------------------------------------------------------------------------------------------------------------------------- */
function displayInPopup(pagesrc,width,height) {
	//var myBars		= 'directories=yes,location=yes,menubar=yes,status=yes,titlebar=yes,toolbar=yes';
	var myBars		= 'directories=no,location=no,menubar=no,status=yes,titlebar=yes,toolbar=no';
	var myOptions	='scrollbars=yes,width='+width+',height='+height+',resizable=yes';
	var myFeatures	= myBars + ',' + myOptions;
	var refWindow	= window.open(pagesrc, 'ref_Win', myFeatures);
}


/* ------------------------------------------------------------------------------------------------------------------------------- */
/*	Jan 31.2005
	Bad Cookie processing
	- remove the clientId cookie when equal to 184953 or 199822
*/
var name, value;
/* ------------------------------------------------------------------------------------------------------------------------------- */
function fixbadcookie() {
	cookie		= document.cookie;
	start		= cookie.indexOf('clientId',0);
	end			= parseCookie(cookie,start);
	csize		= end - start;

	subcookie	= cookie.substr(start,csize);
	formatCookie(subcookie);

	if (value=='184953' || value=='199822') {
		deletecookie()
	}
}

/* ------------------------------------------------------------------------------------------------------------------------------- */
function parseCookie(cookie,idx) {
	index = cookie.indexOf(';',idx);
	if (index<0) {
		index = cookie.length;
	}
	return index;
}

/* ------------------------------------------------------------------------------------------------------------------------------- */
function formatCookie(cookie) {
	idx	= cookie.indexOf('=',0);
	size	= cookie.length;
	if (idx>1) {
		name	= cookie.substr(0,idx);
		value	= cookie.substr(idx+1,size);
	} else {
		name	= cookie.substr(0,size);
		value	= '';
	}
}

/* ------------------------------------------------------------------------------------------------------------------------------- */
function deletecookie() {
	expireDate=new Date;
	expireDate.setYear(expireDate.getYear()-1);
	document.cookie = "clientId='';" + ";expires=" + expireDate.toGMTString() +";path=/; domain=.dragondoor.com";
	//alert('deleted bad cookie');

}

/* ------------------------------------------------------------------------------------------------------------------------------- */
function isDeveloper() {
	// look for  validadmin cookie
	cookie		= document.cookie;
	start		= cookie.indexOf('validadmin',0);
	end			= parseCookie(cookie,start);
	csize		= end - start;
	subcookie	= cookie.substr(start,csize);

	if (subcookie=='validadmin=admin') {
		return true;
	}
	return false;

}

/* ------------------------------------------------------------------------------------------------------------------------------- */

/* ------------------------------------------------------------------------------------------------------------------------------- */
function showhide(id) {
	items	= document.getElementById(id);
	if (items) {
		if (items.style.display == 'none'){
			items.style.display		= '';
			//items.style.position	= 'relative';
		} else {
			items.style.display		= "none";
			//items.style.position	= 'absolute';
		}
	}
}

/* ------------------------------------------------------------------------------------------------------------------------------- */
function showElement(id) {
	items	= document.getElementById(id);
	if (items) {	items.style.display		= '' }
}

function hideElement(id) {
	items	= document.getElementById(id);
	if (items) {	items.style.display		= 'none'; }
}

/* ------------------------------------------------------------------------------------------------------------------------------- */
function scrollToElement(id){
	var element = document.getElementById(id);
	var selectedPosX = 0;
	var selectedPosY = 0;

	while(element != null){
		selectedPosX    += element.offsetLeft;
		selectedPosY    += element.offsetTop;
		element       	= element.offsetParent;
	}
	window.scrollTo(selectedPosX,selectedPosY);
}
/* ------------------------------------------------------------------------------------------------------------------------------- */

/* ------------------------------------------------------------------------------------------------------------------------------- */
function splitText(){
	// processes a text string and split it into 2 columns
	// - called by /qigong/news/qigongtip_landing.html

	msg	= '';

	//reference the page elements
	src				= document.getElementById('c0');
	col1			= document.getElementById('c1');
	col2			= document.getElementById('c2');

	content			= src.innerHTML;

	col1_buffer	= '';
	col2_buffer = '';
	contentlength	= content.length;
	load2			= false;
	for (i=0;i<contentlength;i++) {
		if ( i > ((contentlength-15)/2) && !load2) {
			load2	= (content.charAt(i)==' ' ? true : false);
			msg		= 'Load2<br>';
		}
		msg	+= i+', ';
		if (load2) {
			col2_buffer	+= content.charAt(i);
		} else {
			col1_buffer	+= content.charAt(i);
		}
	}

	col1.innerHTML	= col1_buffer;
	col2.innerHTML	= col2_buffer;
	//col2.innerHTML		= msg;

}

/* ------------------------------------------------------------------------------------------------------------------------------- */
function printdiv(id) {
	width	= 800;
	height	= 600;

	printdiv	= document.getElementById(id);
	plinks	= '<table width=540><tr><td><a href="javascript:window.print()">Print</a></td><td align=right><a href="javascript:window.close()">Close</a></td></tr></table></center>'

	content	 = '<html><body>';
	content	+= plinks;
	content += printdiv.innerHTML;
	content	+= '</body></html>';
	displayPopup(content,width,height);

}



/* ------------------------------------------------------------------------------------------------------------------------------- */
function getCookieValue(name) {
	cookie		= document.cookie;
	start		= cookie.indexOf(name,0);
	end			= parseCookie(cookie,start);
	csize		= end - start;

	subcookie	= cookie.substr(start,csize);
	regex		= /=(.+)/;
	value		= regex.exec(subcookie);

	if (value) {
		return value[1] 
	} else {
		return 0
	}
}

/* ------------------------------------------------------------------------------------------------------------------------------- */
function getLandingId() {
	// parse the landing id from the url
	url	= document.URL;
	regex	= /\?l=(\d+)/;
	id		= regex.exec(url);
	if (id) {	return id[1];
	} else {	return 0;}
}


/* ------------------------------------------------------------------------------------------------------------------------------- */
function isDev() {
	var devcookie	= getCookieValue('devmode');
	if (devcookie == 'true') {
		return true;
	};
}
/* ------------------------------------------------------------------------------------------------------------------------------- */
function init_testing() {
	var devmode	= isDev();
	if (devmode) {
		var devdiv	= document.getElementById('devdiv');
		if (devdiv) {	
				showElement('devdiv');
				}
	}
}
/* ------------------------------------------------------------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------------------------------------------------------------- */

