function createRequestObject() {
	var request_o;
	var browser=navigator.appName;
	if(browser=="Microsoft Internet Explorer"){
		request_o=new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_o=new XMLHttpRequest();
	}
	return request_o;
}

function expand(itemID){
	var curtext=document.getElementById(itemID).innerHTML;
	if(document.getElementById(itemID+'sub').style.display=='list-item'){
		document.getElementById(itemID+'sub').style.display='none';
		document.getElementById(itemID).innerHTML=curtext.replace('minus','plus');
		if(itemID=='myaccount'){
			window.location='\/myaccount\/';
		}
	}else{
		document.getElementById(itemID+'sub').style.display='list-item';
		document.getElementById(itemID).innerHTML=curtext.replace('plus','minus');
	}
}

var popup = {
	popupdiv: '',
	shadowdiv: '',
	content_container:'',
	overflow:'auto',
	title:'Practice4Sale',
		
	create:function(w,h){

		if(document.getElementById('popup_container')) {
			// popup container already exists	
			popup.popupdiv=document.getElementById('popup_container');
			popup.shadowdiv=document.getElementById('popup_container_shadow');
			popup.clearContent();
			return document.getElementById('popup_container');
		}
	
		var newdiv=document.createElement('div');
		newdiv.id='popup_container';
		newdiv.innerHTML = '<!--[if lte IE 6.5]><iframe></iframe><![endif]-->';
		newdiv.className='select-free';
				
		var shadowdiv=document.createElement('div');
		shadowdiv.id='popup_container_shadow';
		shadowdiv.innerHTML = '<!--[if lte IE 6.5]><iframe></iframe><![endif]-->';
		shadowdiv.className='select-free';
					
		// determine window width and height
		if(typeof window.innerWidth  == 'number'){
			// Non-IE
			winW = window.innerWidth;
			winH = window.innerHeight;
		} else if(document.documentElement && (document.documentElement.clientWidth  || document.documentElement.clientHeight)){
			// IE 6+
			winW = document.documentElement.clientWidth;
			winH = document.documentElement.clientHeight;
		} else if(document.body && (document.body.clientWidth  || document.body.clientHeight)){
			// IE 4
			winW = document.body.clientWidth;
			winH = document.body.clientHeight;
		}
				
		// determine scrolling position
		var position = [0,0];
		if(typeof window.pageYOffset != 'undefined')
		{
			// Non-IE
			position = [
				parseInt(winW / 2) - parseInt(w / 2) + window.pageXOffset,
				parseInt(winH / 2) - parseInt(h / 2) + window.pageYOffset
			];
		}
		else if(document.documentElement) 
		{ 
			var tmptop=0;
			if(document.documentElement.scrollTop) {
				tmptop=parseInt(document.documentElement.scrollTop);
			}
			var tmpleft=0;
			if(document.documentElement.scrollLeft) {
				tmpleft=document.documentElement.scrollLeft;
			}
			position = [
				parseInt(winW / 2) - parseInt(w / 2) + tmpleft,
				parseInt(winH / 2) - parseInt(h / 2) + tmptop
			];
		}
		else if(document.body)
		{
			var tmptop=0;
			if(document.body.scrollTop) {
				tmptop=parseInt(document.body.scrollTop);
			}
			var tmpleft=0;
			if(document.body.scrollLeft) {
				tmpleft=document.body.scrollLeft;
			}
			position = [
				parseInt(winW / 2) - parseInt(w / 2) + tmpleft,
				parseInt(winH / 2) - parseInt(h / 2) + tmptop
			];
		}
		else
		{
			return;	
		}
			
		var left=position[0];
		var top=position[1];
		
		newdiv.style.top= top + 'px';
		newdiv.style.left= left + 'px';
				
		shadowdiv.style.top=top + 6 + 'px';
		shadowdiv.style.left=left + 6 +'px';
		
		if(w>0){
			newdiv.style.width=w+'px';
			shadowdiv.style.width=newdiv.style.width;
		}
		if(h>0){
			newdiv.style.height=h+'px';
			shadowdiv.style.height=newdiv.style.height;
		}
		
		document.body.appendChild(newdiv);
		document.body.appendChild(shadowdiv);
		
		popup.popupdiv=newdiv;
		popup.shadowdiv=shadowdiv;
		
		return newdiv;
	},
	
	/* Print content of popup div using the template
 	 */
	useTemplate:function(content){
		if(this.popupdiv && content!=''){
			var text='<table width="100%" class="popup_inner_container">'
						+'<tr class="topbar">'
							+'<td>'+this.title+'</td>'
							+'<td align="right">'
								+'<a href="javascript:void(popup.close());">'
								+'<img src="\/images\/close.gif" alt="Close This Window" style="border:0" \/>'
								+'<\/a>'
							+'<\/td>'
						+'<\/tr>'
						+'<tr>'
							+'<td colspan="2">'
								+'<div id="popup_content" style="overflow:'+this.overflow+'">'
								+ content
								+'<\/div>'
							+'<\/td>'
						+'<\/tr>'
					+'<\/table>';	
			this.popupdiv.innerHTML += text;		
			if(typeof dragNdrop != 'undefined')
				dragNdrop.init();	
		}
	},
	
	/* Clear content of popup div using the template
 	 */
	clearContent:function(content){
		if(this.popupdiv && content!=''){
			this.popupdiv.innerHTML = '<!--[if lte IE 6.5]><iframe></iframe><![endif]-->';		
		}
	},
		
	/* Print content of popup div with no template
 	 */
	printContent:function(content){
		if(this.popupdiv && content!=''){
			this.popupdiv.innerHTML += content;			
		}
	},
	
	/* Close popup container
 	 */
	close:function(){
		if(document.getElementById('popup_container_shadow'))
			document.getElementById('popup_container_shadow').parentNode.removeChild(document.getElementById('popup_container_shadow'));
		if(document.getElementById('popup_container'))
			document.getElementById('popup_container').parentNode.removeChild(document.getElementById('popup_container'));
		if(document.getElementById('hide-select-div'))
			document.getElementById('hide-select-div').parentNode.removeChild(document.getElementById('hide-select-div'));	
	}
};

// allows the assignment of any number of LOAD event handlers
function addLoadListener(fn)
{		
	//alert(fn);
	if(typeof window.addEventListener != 'undefined')
	{
		window.addEventListener('load', fn, false);
	}
	else if(typeof document.addEventListener != 'undefined')
	{
		document.addEventListener('load', fn, false);
	}
	else if(typeof window.attachEvent != 'undefined')
	{
		window.attachEvent('onload', fn);
	}
	else
	{
		var oldfn = window.onload;
		if(typeof window.onload != 'function')
		{
			window.onload = fn;
		}
		else
		{
			window.onload = function()
			{
				oldfn();
				fn();
			};
		}
	}		
}

// retrieve all values from inputs of a form
function getFormValues(formID){
	var frm = document.getElementById(formID);
	var frmvalues='';
			
	// grab values of text fields
	var inputs = frm.getElementsByTagName('input');
	for(var i=0; i<inputs.length; i++) {
		if(inputs[i].type == "text"){
			frmvalues += inputs[i].name + "=" + escape(inputs[i].value) + "&";
		} else if(inputs[i].type == "hidden" && inputs[i].className == "submit") {
			frmvalues += inputs[i].name + "=" + escape(inputs[i].value) + "&";
		} else if(inputs[i].type == "radio" && inputs[i].checked) {
			frmvalues += inputs[i].name + "=" + escape(inputs[i].value) + "&";
		}
	}
	
	// grab selected dropdown option
	var selects = frm.getElementsByTagName('select');
	for(var i=0; i<selects.length; i++) {
		frmvalues += selects[i].name + "=" + selects[i].options[selects[i].selectedIndex].value + "&";
	}

	// grab values of textarea
	var txtareas = frm.getElementsByTagName('textarea');
	for(var i=0; i<txtareas.length; i++) {
		frmvalues += txtareas[i].name + "=" + escape((txtareas[i].value.replace("\n","<br />"))) + "&";
	}
		
	if(frmvalues.substring(frmvalues.length-1) == '&') {
		frmvalues = frmvalues.substring(0, frmvalues.length-1);
	}
	return frmvalues;
}

