function ashpPopup(url) {
		  helpWindow = window.open (url, 'helpWin', 'scrollbars=yes,width=362,height=350')
}
function ashpDW(url) {
		  helpWindow = window.open (url, 'Daughter', 'toolbar=no,scrollbars=no,width=430,height=450')
}
function ashpDWT(url) {
		  helpWindow = window.open (url, 'Daughter', 'toolbar=no,scrollbars=yes,width=430,height=450')
}
function ashpOpenLink(url) {
	window.opener.location = url;
	window.close();
}

function upDateShipCountry(frm) {
	if ((frm.ADD_SHIP_COUNTRY) && (frm.ADD_SHIP_COUNTRY_CODE)) {
		frm.ADD_SHIP_COUNTRY.value = frm.ADD_SHIP_COUNTRY_CODE[frm.ADD_SHIP_COUNTRY_CODE.selectedIndex].text
	}
}
function upDateBillCountry(frm) {
	if ((frm.ADD_BILL_COUNTRY) && (frm.ADD_BILL_COUNTRY_CODE)) {
		frm.ADD_BILL_COUNTRY.value = frm.ADD_BILL_COUNTRY_CODE[frm.ADD_BILL_COUNTRY_CODE.selectedIndex].text
	}
}

function capitalizeMe(obj) {
		val = obj.value.toLowerCase();
		newVal = '';
		val = val.split(' ');
        for(var c=0; c < val.length; c++) {
			newVal += val[c].substring(0,1).toUpperCase() + val[c].substring(1,val[c].length) + ' ';
        }
		obj.value = newVal;
		//Begin Trim function
		obj.value = obj.value.replace(/^\s+|\s+$/g,"");
		//End Trim function
}
	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;
			}
			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 function gets the cookie, if it exists
		function Get_Cookie( name ) {
		
			var start = document.cookie.indexOf( name + "=" );
			var len = start + name.length + 1;
			if ( ( !start ) &&
				( name != document.cookie.substring( 0, name.length ) ) )
			{
				return null;
			}
			if ( start == -1 ) return null;
			var end = document.cookie.indexOf( ";", len );
			if ( end == -1 ) end = document.cookie.length;
			return unescape( document.cookie.substring( len, end ) );
		}
function hpFormGo(obj) {
	if ((obj.selectedIndex) != 0) {
		document.location = obj[obj.selectedIndex].value;
	}
}
function ashp_search(cid, txt) {
	var collection;
	var q;
	if (cid == undefined) {
		collection = "1";
	}
	else {
		collection = cid;
	}
	if (txt == undefined) {
		q = document.forms[0].q.value;
	} else {
		q = txt;
	}
	var searchurl = "http://www.ashp.org/searchresults.aspx?q=" + q; //Create redirect url for search
	searchurl = searchurl + "&cid=" + collection; //Add collection information. Collections: 1=default_collection, 2=Products, 3=BestPractices
	location.href = searchurl;
}

//need these next 2 functions for confirm sections web control
function onlyradio(obj) {
	for(i=0; i<document.forms[0].elements.length; i++) {
		if ((document.forms[0].elements[i].type != obj.type) && (document.forms[0].elements[i].value == obj.value)) {
			//type doesnt match but value does, therefore disable. ie, disable the checkbox
			document.forms[0].elements[i].disabled = true;
			document.forms[0].elements[i].checked = false;
		}
		if ((document.forms[0].elements[i].type != obj.type) && (document.forms[0].elements[i].value != obj.value)){
			document.forms[0].elements[i].disabled = false;
		}
	}
}
function checkradiobuttons(){
    var found = false;
    for(i=0; i<document.forms[0].elements.length; i++) {
        
        if ((document.forms[0].elements[i].type == 'radio') && (document.forms[0].elements[i].checked)) {
            found = true;
        }
    }
    if (!found) {
        alert('Please select a primary section.');
        return false;
    } else {
        return true;
    }		    
}