function URLencode(sStr) {
    return escape(sStr).replace(/\+/g, '%2C').replace(/\"/g, '%22').replace(/\'/g, '%27');
}

function DisplayCityLink(sFormField, sFieldDestination, sStateField, sURL, sDMA) {
	DisplayCityListPopupHREF(sFormField, sFieldDestination, sStateField, sURL, sDMA);
	document.write ('<font face=arial,helvetica size=1><b>View&nbsp;List</b></font></a>');
}

function DisplayCityListPopupHREF(sFormField, sFieldDestination, sStateField, sURL, sDMA) {
	document.write ('<a href="#" onClick="ListCities(\'' + sFormField + '\',\'' + sFieldDestination + '\',\'' + sStateField + '\',\'' + sURL + '\',\'' + sDMA + '\'); return false">');
}

function ListCities(sFormField, sFieldDestination, sStateField, sURL, sDMA) {
	var sStateField = eval('document.' + sStateField)
	var state = sStateField.options[sStateField.selectedIndex].value
	var url= sURL + '?formname=' + sFormField + '&destination=' + sFieldDestination + '&s=' + state

	if (sDMA == "") {
		if ((state == "ALL, US") || (state == "") || (state == "---")) {
			alert("Please choose a state first.")
			sStateField.options.focus()
		}
		else {
			//self.open(url,'wndGeoPicker','width=430,height=350,scrollbars=yes,resizable=yes,toolbar=0,menubar=0,status=0,location=0')
			openWindow(url, 430, 350)			
		}
	}
	else {
		//self.open(url,'wndGeoPicker','width=430,height=350,scrollbars=yes,resizable=yes,toolbar=0,menubar=0,status=0,location=0')	
		openWindow(url, 430, 350)	
	}
}

function openWindow(page, w, h) {
    //var w = 430, h = 350; // default sizes
    
    if (window.screen) {
        var winl = ((window.screen.availWidth - w) / 2) - 50;
        var wint = (window.screen.availHeight - h) / 2;
    }

    self.open(page,'windowName','scrollbars=yes,resizable=yes,toolbar=0,menubar=0,status=0,location=0,top='+wint+',left='+winl+',width='+w+',height='+h);
}