/**************** file loading ***********************/

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//cookie helper functions //////////////////////////////////
function GetCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg){return getCookieVal (j);}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) {break;}
	}
	return "";
}

function SetCookie (name,value,expires,path,domain,secure) 
{	
	if (value != "" && value != null) {	
		document.cookie = name + "=" + value +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	}
}

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1){endstr = document.cookie.length;}
	return unescape(document.cookie.substring(offset, endstr));
}

// Subcookies look like: name1=value1&name2=value2...
function getSubCookie (cookie, name){
	var subCookies = cookie.split('&');
	for (var i=0; i < subCookies.length; i++) {
		//need to split key value pair
		var subCookieSplit = subCookies[i].split('=');
		if (subCookieSplit[0] == name){
			return unescape(subCookieSplit[1]);
		}
	}
	return "";	
}




/********************* state_country_province ***************************/

function setSPC(area,location){

	//first must nullify all but 1st blank option
	//then will add each new option to be selected from
	var optionCounter; 
	for (optionCounter = 0; optionCounter < document.pageform.spc.length; optionCounter=0) { 
		document.pageform.spc.options[optionCounter] = null;
	}


	if(area == "usa" || area == ""){		
		//set new options for usa states
		document.pageform.spc.options[0] = new Option("(Choose State)","");
		document.pageform.spc.options[1] = new Option("Alabama","AL");
                document.pageform.spc.options[2] = new Option("Alaska","AK");
                document.pageform.spc.options[3] = new Option("Arizona","AZ");
                document.pageform.spc.options[4] = new Option("Arkansas","AR");
                document.pageform.spc.options[5] = new Option("California","CA");
                document.pageform.spc.options[6] = new Option("Colorado","CO");
                document.pageform.spc.options[7] = new Option("Connecticut","CT");
                document.pageform.spc.options[8] = new Option("Delaware","DE");
                document.pageform.spc.options[9] = new Option("District of Columbia","DC");
                document.pageform.spc.options[10] = new Option("Federated States of Micronesia","FM");
                document.pageform.spc.options[11] = new Option("Florida","FL");
                document.pageform.spc.options[12] = new Option("Georgia","GA");
                document.pageform.spc.options[13] = new Option("Guam","GU");
                document.pageform.spc.options[14] = new Option("Hawaii","HI");
                document.pageform.spc.options[15] = new Option("Idaho","ID");
                document.pageform.spc.options[16] = new Option("Illinois","IL");
                document.pageform.spc.options[17] = new Option("Indiana","IN");
                document.pageform.spc.options[18] = new Option("Iowa","IA");
                document.pageform.spc.options[19] = new Option("Kansas","KS");
                document.pageform.spc.options[20] = new Option("Kentucky","KY");
                document.pageform.spc.options[21] = new Option("Louisiana","LA");
                document.pageform.spc.options[22] = new Option("Maine","ME");
                document.pageform.spc.options[23] = new Option("Mariana Islands","MP");
                document.pageform.spc.options[24] = new Option("Marshall Islands","MH");
                document.pageform.spc.options[25] = new Option("Maryland","MD");
                document.pageform.spc.options[26] = new Option("Massachusetts","MA");
                document.pageform.spc.options[27] = new Option("Michigan","MI");
                document.pageform.spc.options[28] = new Option("Minnesota","MN");
                document.pageform.spc.options[29] = new Option("Mississippi","MS");
                document.pageform.spc.options[30] = new Option("Missouri","MO");
                document.pageform.spc.options[31] = new Option("Montana","MT");
                document.pageform.spc.options[32] = new Option("Nebraska","NE");
                document.pageform.spc.options[33] = new Option("Nevada","NV");
                document.pageform.spc.options[34] = new Option("New Hampshire","NH");
                document.pageform.spc.options[35] = new Option("New Jersey","NJ");
                document.pageform.spc.options[36] = new Option("New Mexico","NM");
                document.pageform.spc.options[37] = new Option("New York","NY");
                document.pageform.spc.options[38] = new Option("North Carolina","NC");
                document.pageform.spc.options[39] = new Option("North Dakota","ND");
                document.pageform.spc.options[40] = new Option("Northern Mariana Islands","MP");
                document.pageform.spc.options[41] = new Option("Ohio","OH");
                document.pageform.spc.options[42] = new Option("Oklahoma","OK");
                document.pageform.spc.options[43] = new Option("Oregon","OR");
                document.pageform.spc.options[44] = new Option("Pennsylvania","PA");
                document.pageform.spc.options[45] = new Option("Puerto Rico","PR");
                document.pageform.spc.options[46] = new Option("Rhode Island","RI");
                document.pageform.spc.options[47] = new Option("South Carolina","SC");
                document.pageform.spc.options[48] = new Option("South Dakota","SD");
                document.pageform.spc.options[49] = new Option("Swan Islands","Swan Islands");
                document.pageform.spc.options[50] = new Option("Tennessee","TN");
                document.pageform.spc.options[51] = new Option("Texas","TX");
                document.pageform.spc.options[52] = new Option("Trust Territory of Palau","PW");
                document.pageform.spc.options[53] = new Option("Trust Territory of the Pacific Islands","Trust Territory of the Pacific Islands");
                document.pageform.spc.options[54] = new Option("US Miscellaneous Pacific Islands","US Miscellaneous Pacific Islands");
                document.pageform.spc.options[55] = new Option("Utah","UT");
                document.pageform.spc.options[56] = new Option("Vermont","VT");
                document.pageform.spc.options[57] = new Option("Virgin Islands","VI");
                document.pageform.spc.options[58] = new Option("Virginia","VA");
                document.pageform.spc.options[59] = new Option("Washington","WA");
                document.pageform.spc.options[60] = new Option("West Virginia","WV");
                document.pageform.spc.options[61] = new Option("Wisconsin","WI");
                document.pageform.spc.options[62] = new Option("Wyoming","WY");
        }
	else if(area == "canada"){
		//set new options for canada provinces
		document.pageform.spc.options[0] = new Option("(Choose Province)","");
		document.pageform.spc.options[1] = new Option("Alberta","AB");
		document.pageform.spc.options[2] = new Option("British Columbia","BC");
		document.pageform.spc.options[3] = new Option("Manitoba","MB");
		document.pageform.spc.options[4] = new Option("New Brunswick","NB");
		document.pageform.spc.options[5] = new Option("Newfoundland","NL");
		document.pageform.spc.options[6] = new Option("Northwest Territories","NT");
		document.pageform.spc.options[7] = new Option("Nova Scotia","NS");
		document.pageform.spc.options[8] = new Option("Ontario","ON");
		document.pageform.spc.options[9] = new Option("Prince Edward Island","PE");
		document.pageform.spc.options[10] = new Option("Quebec","QC");
		document.pageform.spc.options[11] = new Option("Saskatchewan","SK");
		document.pageform.spc.options[12] = new Option("Yukon","YT");
	}
	else if(area == "other"){
		//must be other
		//set new options for other
		document.pageform.spc.options[0] = new Option("(Choose Country)","");
		document.pageform.spc.options[1] = new Option("Andorra","Andorra");
		document.pageform.spc.options[2] = new Option("Afghanistan","Afghanistan");
		document.pageform.spc.options[3] = new Option("Antigua and Barbuda","Antigua and Barbuda");
		document.pageform.spc.options[4] = new Option("Anguilla","Anguilla");
		document.pageform.spc.options[5] = new Option("Albania","Albania");
		document.pageform.spc.options[6] = new Option("Algeria","Algeria");
		document.pageform.spc.options[7] = new Option("American Samoa","American Samoa");
		document.pageform.spc.options[8] = new Option("Netherland Antilles","Netherland Antilles");
		document.pageform.spc.options[9] = new Option("Angola","Angola");
		document.pageform.spc.options[10] = new Option("Antarctica","Antarctica");
		document.pageform.spc.options[11] = new Option("Argentina","Argentina");
		document.pageform.spc.options[12] = new Option("Armenia","Armenia");
		document.pageform.spc.options[13] = new Option("Austria","Austria");
		document.pageform.spc.options[14] = new Option("Australia","Australia");
		document.pageform.spc.options[15] = new Option("Aruba","Aruba");
		document.pageform.spc.options[16] = new Option("Azerbaidjan","Azerbaidjan");
		document.pageform.spc.options[17] = new Option("Bosnia-Herzegovina","Bosnia-Herzegovina");
		document.pageform.spc.options[18] = new Option("Barbados","Barbados");
		document.pageform.spc.options[19] = new Option("Banglades","Banglades");
		document.pageform.spc.options[20] = new Option("Belgium","Belgium");
		document.pageform.spc.options[21] = new Option("Burkina Faso","Burkina Faso");
		document.pageform.spc.options[22] = new Option("Bulgaria","Bulgaria");
		document.pageform.spc.options[23] = new Option("Bahrain","Bahrain");
		document.pageform.spc.options[24] = new Option("Burundi","Burundi");
		document.pageform.spc.options[25] = new Option("Benin","Benin");
		document.pageform.spc.options[26] = new Option("Bermuda","Bermuda");
		document.pageform.spc.options[27] = new Option("Brunei Darussalam","Brunei Darussalam");
		document.pageform.spc.options[28] = new Option("Bolivia","Bolivia");
		document.pageform.spc.options[29] = new Option("Brazil","Brazil");
		document.pageform.spc.options[30] = new Option("Bahamas","Bahamas");
		document.pageform.spc.options[31] = new Option("Buthan","Buthan");
		document.pageform.spc.options[32] = new Option("Bouvet Island","Bouvet Island");
		document.pageform.spc.options[33] = new Option("Botswana","Botswana");
		document.pageform.spc.options[34] = new Option("Belarus","Belarus");
		document.pageform.spc.options[35] = new Option("Belize","Belize");
		document.pageform.spc.options[36] = new Option("Cambodia","Cambodia");
		document.pageform.spc.options[37] = new Option("Cayman Islands","Cayman Islands");
		document.pageform.spc.options[38] = new Option("Cocos Islands","Cocos Islands");
		document.pageform.spc.options[39] = new Option("Central African Republic","Central African Republic");
		document.pageform.spc.options[40] = new Option("Chad","Chad");
		document.pageform.spc.options[41] = new Option("Comoros","Comoros");
		document.pageform.spc.options[42] = new Option("Congo","Congo");
		document.pageform.spc.options[43] = new Option("Cook Islands","Cook Islands");
		document.pageform.spc.options[44] = new Option("Chile","Chile");
		document.pageform.spc.options[45] = new Option("Cameroon","Cameroon");
		document.pageform.spc.options[46] = new Option("China","China");
		document.pageform.spc.options[47] = new Option("Colombia","Colombia");
		document.pageform.spc.options[48] = new Option("Costa Rica","Costa Rica");
		document.pageform.spc.options[49] = new Option("Croatia","Croatia");
		document.pageform.spc.options[50] = new Option("Czechoslovakia","Czechoslovakia");
		document.pageform.spc.options[51] = new Option("Cuba","Cuba");
		document.pageform.spc.options[52] = new Option("Cape Verde","Cape Verde");
		document.pageform.spc.options[53] = new Option("Christmas Island","Christmas Island");
		document.pageform.spc.options[54] = new Option("Cyprus","Cyprus");
		document.pageform.spc.options[55] = new Option("Czech Republic","Czech Republic");
		document.pageform.spc.options[56] = new Option("Djibouti","Djibouti");
		document.pageform.spc.options[57] = new Option("Denmark","Denmark");
		document.pageform.spc.options[58] = new Option("Dominica","Dominica");
		document.pageform.spc.options[59] = new Option("Dominican Republic","Dominican Republic");
		document.pageform.spc.options[60] = new Option("Ecuador","Ecuador");
		document.pageform.spc.options[61] = new Option("Estonia","Estonia");
		document.pageform.spc.options[62] = new Option("Egypt","Egypt");
		document.pageform.spc.options[63] = new Option("Western Sahara","Western Sahara");
		document.pageform.spc.options[64] = new Option("Spain","Spain");
		document.pageform.spc.options[65] = new Option("East Timor","East Timor");
		document.pageform.spc.options[66] = new Option("Ethiopia","Ethiopia");
		document.pageform.spc.options[67] = new Option("Finland","Finland");
		document.pageform.spc.options[68] = new Option("Fiji","Fiji");
		document.pageform.spc.options[69] = new Option("Falkland Islands (Malvinas)","Falkland Islands (Malvinas)");
		document.pageform.spc.options[70] = new Option("Faroe Islands","Faroe Islands");
		document.pageform.spc.options[71] = new Option("France","France");
		document.pageform.spc.options[72] = new Option("France (European Territory)","France (European Territory)");
		document.pageform.spc.options[73] = new Option("Gabon","Gabon");
		document.pageform.spc.options[74] = new Option("Germany","Germany");
		document.pageform.spc.options[75] = new Option("Great Britain","Great Britain");
		document.pageform.spc.options[76] = new Option("Grenada","Grenada");
		document.pageform.spc.options[77] = new Option("Georgia","Georgia");
		document.pageform.spc.options[78] = new Option("Ghana","Ghana");
		document.pageform.spc.options[79] = new Option("Gibraltar","Gibraltar");
		document.pageform.spc.options[80] = new Option("Greenland","Greenland");
		document.pageform.spc.options[81] = new Option("Guadeloupe (French)","Guadeloupe (French)");
		document.pageform.spc.options[82] = new Option("Equatorial Guinea","Equatorial Guinea");
		document.pageform.spc.options[83] = new Option("Guyana (French)","Guyana (French)");
		document.pageform.spc.options[84] = new Option("Gambia","Gambia");
		document.pageform.spc.options[85] = new Option("Guinea","Guinea");
		document.pageform.spc.options[86] = new Option("Greece","Greece");
		document.pageform.spc.options[87] = new Option("Guatemala","Guatemala");
		document.pageform.spc.options[88] = new Option("Guinea Bissau","Guinea Bissau");
		document.pageform.spc.options[89] = new Option("Guyana","Guyana");
		document.pageform.spc.options[90] = new Option("Hong Kong","Hong Kong");
		document.pageform.spc.options[91] = new Option("Heard and McDonald Islands","Heard and McDonald Islands");
		document.pageform.spc.options[92] = new Option("Honduras","Honduras");
		document.pageform.spc.options[93] = new Option("Haiti","Haiti");
		document.pageform.spc.options[94] = new Option("Hungary","Hungary");
		document.pageform.spc.options[95] = new Option("British Indian Ocean Territory","British Indian Ocean Territory");
		document.pageform.spc.options[96] = new Option("Iceland","Iceland");
		document.pageform.spc.options[97] = new Option("India","India");
		document.pageform.spc.options[98] = new Option("Indonesia","Indonesia");
		document.pageform.spc.options[99] = new Option("Iran","Iran");
		document.pageform.spc.options[100] = new Option("Iraq","Iraq");
		document.pageform.spc.options[101] = new Option("Ireland","Ireland");
		document.pageform.spc.options[102] = new Option("Israel","Israel");
		document.pageform.spc.options[103] = new Option("Italy","Italy");
		document.pageform.spc.options[104] = new Option("Ivory Coast","Ivory Coast");
		document.pageform.spc.options[105] = new Option("Jamaica","Jamaica");
		document.pageform.spc.options[106] = new Option("Jordan","Jordan");
		document.pageform.spc.options[107] = new Option("Japan","Japan");
		document.pageform.spc.options[108] = new Option("Kenya","Kenya");
		document.pageform.spc.options[109] = new Option("Kirgistan","Kirgistan");
		document.pageform.spc.options[110] = new Option("Kiribati","Kiribati");
		document.pageform.spc.options[111] = new Option("Saint Kitts Nevis Anguilla","Saint Kitts Nevis Anguilla");
		document.pageform.spc.options[112] = new Option("North Korea","North Korea");
		document.pageform.spc.options[113] = new Option("South Korea","South Korea");
		document.pageform.spc.options[114] = new Option("Kuwait","Kuwait");
		document.pageform.spc.options[115] = new Option("Kazachstan","Kazachstan");
		document.pageform.spc.options[116] = new Option("Laos","Laos");
		document.pageform.spc.options[117] = new Option("Lebanon","Lebanon");
		document.pageform.spc.options[118] = new Option("Liechtenstein","Liechtenstein");
		document.pageform.spc.options[119] = new Option("Liberia","Liberia");
		document.pageform.spc.options[120] = new Option("Lesotho","Lesotho");
		document.pageform.spc.options[121] = new Option("Lithuania","Lithuania");
		document.pageform.spc.options[122] = new Option("Luxembourg","Luxembourg");
		document.pageform.spc.options[123] = new Option("Latvia","Latvia");
		document.pageform.spc.options[124] = new Option("Libya","Libya");
		document.pageform.spc.options[125] = new Option("Macau","Macau");
		document.pageform.spc.options[126] = new Option("Madagascar","Madagascar");
		document.pageform.spc.options[127] = new Option("Malawi","Malawi");
		document.pageform.spc.options[128] = new Option("Malaysia","Malaysia");
		document.pageform.spc.options[129] = new Option("Maldives","Maldives");
		document.pageform.spc.options[130] = new Option("Mali","Mali");
		document.pageform.spc.options[131] = new Option("Malta","Malta");
		document.pageform.spc.options[132] = new Option("Mauritania","Mauritania");
		document.pageform.spc.options[133] = new Option("Mauritius","Mauritius");
		document.pageform.spc.options[134] = new Option("Northern Mariana Islands","Northern Mariana Islands");
		document.pageform.spc.options[135] = new Option("Marshall Islands","Marshall Islands");
		document.pageform.spc.options[136] = new Option("Martinique (French)","Martinique (French)");
		document.pageform.spc.options[137] = new Option("Mexico","Mexico");
		document.pageform.spc.options[138] = new Option("Micronesia","Micronesia");
		document.pageform.spc.options[139] = new Option("Moldavia","Moldavia");
		document.pageform.spc.options[140] = new Option("Monaco","Monaco");
		document.pageform.spc.options[141] = new Option("Morocco","Morocco");
		document.pageform.spc.options[142] = new Option("Mongolia","Mongolia");
		document.pageform.spc.options[143] = new Option("Montserrat","Montserrat");
		document.pageform.spc.options[144] = new Option("Mozambique","Mozambique");
		document.pageform.spc.options[145] = new Option("Myanmar","Myanmar");
		document.pageform.spc.options[146] = new Option("Namibia","Namibia");
		document.pageform.spc.options[147] = new Option("Nauru","Nauru");
		document.pageform.spc.options[148] = new Option("Nepal","Nepal");
		document.pageform.spc.options[149] = new Option("Netherlands","Netherlands");
		document.pageform.spc.options[150] = new Option("Netherland Antilles","Netherland Antilles");
		document.pageform.spc.options[151] = new Option("Neutral Zone","Neutral Zone");
		document.pageform.spc.options[152] = new Option("New Caledonia (French)","New Caledonia (French)");
		document.pageform.spc.options[153] = new Option("New Zealand","New Zealand");
		document.pageform.spc.options[154] = new Option("Nicaragua","Nicaragua");
		document.pageform.spc.options[155] = new Option("Niger","Niger");
		document.pageform.spc.options[156] = new Option("Nigeria","Nigeria");
		document.pageform.spc.options[157] = new Option("Niue","Niue");
		document.pageform.spc.options[158] = new Option("Norfolk Island","Norfolk Island");
		document.pageform.spc.options[159] = new Option("Norway","Norway");
		document.pageform.spc.options[160] = new Option("Oman","Oman");
		document.pageform.spc.options[161] = new Option("Pakistan","Pakistan");
		document.pageform.spc.options[162] = new Option("Palau","Palau");
		document.pageform.spc.options[163] = new Option("Palestine","Palestine");
		document.pageform.spc.options[164] = new Option("Panama","Panama");
		document.pageform.spc.options[165] = new Option("Papua New","Papua New");
		document.pageform.spc.options[166] = new Option("Paraguay","Paraguay");
		document.pageform.spc.options[167] = new Option("Peru","Peru");
		document.pageform.spc.options[168] = new Option("Polynesia (French)","Polynesia (French)");
		document.pageform.spc.options[169] = new Option("Philippines","Philippines");
		document.pageform.spc.options[170] = new Option("Poland","Poland");
		document.pageform.spc.options[171] = new Option("Pitcairn","Pitcairn");
		document.pageform.spc.options[172] = new Option("Portugal","Portugal");
		document.pageform.spc.options[173] = new Option("Qatar","Qatar");
		document.pageform.spc.options[174] = new Option("Reunion (French)","Reunion (French)");
		document.pageform.spc.options[175] = new Option("Romania","Romania");
		document.pageform.spc.options[176] = new Option("Russian Federation","Russian Federation");
		document.pageform.spc.options[177] = new Option("Rwanda","Rwanda");
		document.pageform.spc.options[178] = new Option("Saint Helena","Saint Helena");
		document.pageform.spc.options[179] = new Option("Saint Lucia","Saint Lucia");
		document.pageform.spc.options[180] = new Option("Saint Pierre and Miquelon","Saint Pierre and Miquelon");
		document.pageform.spc.options[181] = new Option("Saint Tome and Principe","Saint Tome and Principe");
		document.pageform.spc.options[182] = new Option("Samoa","Samoa");
		document.pageform.spc.options[183] = new Option("San Marino","San Marino");
		document.pageform.spc.options[184] = new Option("Saudi Arabia","Saudi Arabia");
		document.pageform.spc.options[185] = new Option("Senegal","Senegal");
		document.pageform.spc.options[186] = new Option("Serbia and Montenegro","Serbia and Montenegro");
		document.pageform.spc.options[187] = new Option("Seychelles","Seychelles");
		document.pageform.spc.options[188] = new Option("Sierra Leone","Sierra Leone");
		document.pageform.spc.options[189] = new Option("Singapore","Singapore");
		document.pageform.spc.options[190] = new Option("Slovak Republic","Slovak Republic");
		document.pageform.spc.options[191] = new Option("Slovenia","Slovenia");
		document.pageform.spc.options[192] = new Option("Solomon Islands","Solomon Islands");
		document.pageform.spc.options[193] = new Option("Somalia","Somalia");
		document.pageform.spc.options[194] = new Option("South Africa","South Africa");
		document.pageform.spc.options[195] = new Option("Soviet Union (Former)","Former Soviet Union");
		document.pageform.spc.options[196] = new Option("Sri Lanka","Sri Lanka");
		document.pageform.spc.options[197] = new Option("Sudan","Sudan");
		document.pageform.spc.options[198] = new Option("Suriname","Suriname");
		document.pageform.spc.options[199] = new Option("Svalbard and Jan Mayen Islands","Svalbard and Jan Mayen Islands");
		document.pageform.spc.options[200] = new Option("Sweden","Sweden");
		document.pageform.spc.options[201] = new Option("El Salvador","El Salvador");
		document.pageform.spc.options[202] = new Option("Syria","Syria");
		document.pageform.spc.options[203] = new Option("Swaziland","Swaziland");
		document.pageform.spc.options[204] = new Option("Switzerland","Switzerland");
		document.pageform.spc.options[205] = new Option("Tadjikistan","Tadjikistan");
		document.pageform.spc.options[206] = new Option("Taiwan","Taiwan");
		document.pageform.spc.options[207] = new Option("Tanzania","Tanzania");
		document.pageform.spc.options[208] = new Option("Thailand","Thailand");
		document.pageform.spc.options[209] = new Option("East Timor","East Timor");
		document.pageform.spc.options[210] = new Option("Togo","Togo");
		document.pageform.spc.options[211] = new Option("Tokelau","Tokelau");
		document.pageform.spc.options[212] = new Option("Tonga","Tonga");
		document.pageform.spc.options[213] = new Option("Trinidad and Tobago","Trinidad and Tobago");
		document.pageform.spc.options[214] = new Option("Tunisia","Tunisia");
		document.pageform.spc.options[215] = new Option("Turkmenistan","Turkmenistan");
		document.pageform.spc.options[216] = new Option("Turks and Caicos Islands","Turks and Caicos Islands");
		document.pageform.spc.options[217] = new Option("Turkey","Turkey");
		document.pageform.spc.options[218] = new Option("Tuvalu","Tuvalu");
		document.pageform.spc.options[219] = new Option("Ukraine","Ukraine");
		document.pageform.spc.options[220] = new Option("Uganda","Uganda");
		document.pageform.spc.options[221] = new Option("United Arab Emirates","United Arab Emirates");
		document.pageform.spc.options[222] = new Option("Uruguay","Uruguay");
		document.pageform.spc.options[223] = new Option("Uzbekistan","Uzbekistan");
		document.pageform.spc.options[224] = new Option("Vatican City State","Vatican City State");
		document.pageform.spc.options[225] = new Option("Saint Vincent and Grenadines","Saint Vincent and Grenadines");
		document.pageform.spc.options[226] = new Option("Venezuela","Venezuela");
		document.pageform.spc.options[227] = new Option("Virgin Islands (British)","Virgin Islands (British)");
		document.pageform.spc.options[228] = new Option("Vietnam","Vietnam");
		document.pageform.spc.options[229] = new Option("Vanuatu","Vanuatu");
		document.pageform.spc.options[230] = new Option("Wallis and Futuna Islands","Wallis and Futuna Islands");
		document.pageform.spc.options[231] = new Option("Yemen","Yemen");
		document.pageform.spc.options[232] = new Option("Zambia","Zambia");
		document.pageform.spc.options[233] = new Option("Zaire","Zaire");
		document.pageform.spc.options[234] = new Option("Zimbabwe","Zimbabwe");
	}
	
	//set selected index if location is defined
    for (optionCounter = 0; optionCounter < document.pageform.spc.length; optionCounter++) { 
		if (location == document.pageform.spc.options[optionCounter].value){
			//this is selected index
			document.pageform.spc.selectedIndex = optionCounter;
			break;			
		}		
	}

}
	
function processAreaChange(area){
	//if area.options[area.selectedIndex].value == "other"
	//set spc's values to be countries
	//else if it == usa set spc's values to be states
	//else set spc's values to be provinces
	
	//this would be either usa, canada, other
	var area_val = area.options[area.selectedIndex].value;
	//this will be 0, 1, 2
	var area_sel_i = area.selectedIndex;
	 
	setSPC(area_val,'');
}

//takes in an id for pulldown to set and will populate it with usa states
function setPulldownOptions(pd_id){
	//set new options for usa states
		document.getElementById(pd_id).options[0] = new Option("(Choose State)","");
		document.getElementById(pd_id).options[1] = new Option("Alabama","AL");
                document.getElementById(pd_id).options[2] = new Option("Alaska","AK");
                document.getElementById(pd_id).options[3] = new Option("Arizona","AZ");
                document.getElementById(pd_id).options[4] = new Option("Arkansas","AR");
                document.getElementById(pd_id).options[5] = new Option("California","CA");
                document.getElementById(pd_id).options[6] = new Option("Colorado","CO");
                document.getElementById(pd_id).options[7] = new Option("Connecticut","CT");
                document.getElementById(pd_id).options[8] = new Option("Delaware","DE");
                document.getElementById(pd_id).options[9] = new Option("District of Columbia","DC");
                document.getElementById(pd_id).options[10] = new Option("Micronesia","FM");
                document.getElementById(pd_id).options[11] = new Option("Florida","FL");
                document.getElementById(pd_id).options[12] = new Option("Georgia","GA");
                document.getElementById(pd_id).options[13] = new Option("Guam","GU");
                document.getElementById(pd_id).options[14] = new Option("Hawaii","HI");
                document.getElementById(pd_id).options[15] = new Option("Idaho","ID");
                document.getElementById(pd_id).options[16] = new Option("Illinois","IL");
                document.getElementById(pd_id).options[17] = new Option("Indiana","IN");
                document.getElementById(pd_id).options[18] = new Option("Iowa","IA");
                document.getElementById(pd_id).options[19] = new Option("Kansas","KS");
                document.getElementById(pd_id).options[20] = new Option("Kentucky","KY");
                document.getElementById(pd_id).options[21] = new Option("Louisiana","LA");
                document.getElementById(pd_id).options[22] = new Option("Maine","ME");
                document.getElementById(pd_id).options[23] = new Option("Mariana Islands","MP");
                document.getElementById(pd_id).options[24] = new Option("Marshall Islands","MH");
                document.getElementById(pd_id).options[25] = new Option("Maryland","MD");
                document.getElementById(pd_id).options[26] = new Option("Massachusetts","MA");
                document.getElementById(pd_id).options[27] = new Option("Michigan","MI");
                document.getElementById(pd_id).options[28] = new Option("Minnesota","MN");
                document.getElementById(pd_id).options[29] = new Option("Mississippi","MS");
                document.getElementById(pd_id).options[30] = new Option("Missouri","MO");
                document.getElementById(pd_id).options[31] = new Option("Montana","MT");
                document.getElementById(pd_id).options[32] = new Option("Nebraska","NE");
                document.getElementById(pd_id).options[33] = new Option("Nevada","NV");
                document.getElementById(pd_id).options[34] = new Option("New Hampshire","NH");
                document.getElementById(pd_id).options[35] = new Option("New Jersey","NJ");
                document.getElementById(pd_id).options[36] = new Option("New Mexico","NM");
                document.getElementById(pd_id).options[37] = new Option("New York","NY");
                document.getElementById(pd_id).options[38] = new Option("North Carolina","NC");
                document.getElementById(pd_id).options[39] = new Option("North Dakota","ND");
                document.getElementById(pd_id).options[40] = new Option("N. Mariana Islands","MP");
                document.getElementById(pd_id).options[41] = new Option("Ohio","OH");
                document.getElementById(pd_id).options[42] = new Option("Oklahoma","OK");
                document.getElementById(pd_id).options[43] = new Option("Oregon","OR");
                document.getElementById(pd_id).options[44] = new Option("Pennsylvania","PA");
                document.getElementById(pd_id).options[45] = new Option("Puerto Rico","PR");
                document.getElementById(pd_id).options[46] = new Option("Rhode Island","RI");
                document.getElementById(pd_id).options[47] = new Option("South Carolina","SC");
                document.getElementById(pd_id).options[48] = new Option("South Dakota","SD");
                document.getElementById(pd_id).options[49] = new Option("Swan Islands","Swan Islands");
                document.getElementById(pd_id).options[50] = new Option("Tennessee","TN");
                document.getElementById(pd_id).options[51] = new Option("Texas","TX");
                document.getElementById(pd_id).options[52] = new Option("Palau","PW");
                document.getElementById(pd_id).options[53] = new Option("Pacific Islands","Trust Territory of the Pacific Islands");
                document.getElementById(pd_id).options[54] = new Option("US Miscellaneous","US Miscellaneous Pacific Islands");
                document.getElementById(pd_id).options[55] = new Option("Utah","UT");
                document.getElementById(pd_id).options[56] = new Option("Vermont","VT");
                document.getElementById(pd_id).options[57] = new Option("Virgin Islands","VI");
                document.getElementById(pd_id).options[58] = new Option("Virginia","VA");
                document.getElementById(pd_id).options[59] = new Option("Washington","WA");
                document.getElementById(pd_id).options[60] = new Option("West Virginia","WV");
                document.getElementById(pd_id).options[61] = new Option("Wisconsin","WI");
                document.getElementById(pd_id).options[62] = new Option("Wyoming","WY");
}


/*
core.js - @ 

This lib holds all the variables and functions needed to interact
with forms and html pages.

these functions provide the base functinos for retrieving and setting objects and
using diff browser cross compatibility.

*/



var field, id, myObj, index;
var DHTML = (document.getElementById || document.all || document.layers);

var ns4 = false;
var ie4 = false;
  
if(document.layers) {
    ns4 = true;
}
else if(document.all) {
    ie4 = true;
}


function getObj(name){
	  if (document.getElementById){
      myObj = document.getElementById(name);
    }else if (document.all){
			myObj = document.all[name];
    }else if (document.layers){
	   	myObj = document.layers[name];
    }   
    
}


function showObject(obj) {
    if (ns4) {
         var style2 = document.layers[obj].style;
         style2.display = "block";
    } else if (ie4) {
         var style2 = document.all[obj].style;
         style2.display = "block";
    } else {
    		 var style2 = document.getElementById(obj).style;
         style2.display = "block";
    }
}

function hideObject(obj) {
    if (ns4) {
         var style2 = document.layers[obj].style;
         style2.display = "none";
    } else if (ie4) {
         var style2 = document.all[obj].style;
         style2.display = "none";
    } else {
    		 var style2 = document.getElementById(obj).style;
         style2.display = "none";
    }
}

function toggleObject(obj) {
	if(document.getElementById(obj).style.display == "none"){
		showObject(obj);
	}
	else{
		hideObject(obj);
	}
}

function xmlUnescape(sxml){
       sxml = sxml.replace(/\&lt\;/g, "<");
       sxml = sxml.replace(/\&gt\;/g, ">");
       sxml = sxml.replace(/\&quot\;/g, "\"");
       sxml = sxml.replace(/\&apos\;/g, "'");
       sxml = sxml.replace(/\&amp\;/g, "&");
       
       return sxml;
}

function decodeQuotes(sxml){
       sxml = sxml.replace(/\&quot\;/g, "\"");
       sxml = sxml.replace(/\&apos\;/g, "'");
       
       return sxml;
}

function encodeQuotes(sxml){
       sxml = sxml.replace(/\"/g, "\&quot\;");
       sxml = sxml.replace(/\'/g, "\&apos\;");
       
       return sxml;
}

function checkBadChars(id) {
    if ($(id) != undefined) {
        $(id).value = convertBadChars($(id).value);
    }
}

//still use this in case other code refs it
function convert(s) {
    return convertBadChars(s);
}


function convertBadChars(s) {
    s = s.replace(/[\u2018\u2019]/g, "'");
    s = s.replace(/[\u201c\u201d]/g, '"');
    s = s.replace(/[\u0013\u2013\u2014]/g, '--');

    // these get removed no matter what
    s = s.replace(/[\x00-\x09\x0b\x0c\x0e-\x1f]/g, '');

    var c = '';
    for (i = 0; i < s.length; i++) {
        if (s.charCodeAt(i) > 127) { c += '&#' + s.charCodeAt(i) + ';'; } else { c += s.charAt(i); }
    }
    return c;
}

function removeBadChars(s) {
    s = s.replace(/[\u2018\u2019]/g, "'");
    s = s.replace(/[\u201c\u201d]/g, '"');
    s = s.replace(/[\u0013\u2013\u2014]/g, '--');
    s = s.replace(/[\x00-\x09\x0b\x0c\x0e-\x1f\u007f-\uffff]/g, '');

    return s;
}


function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function elementAllInViewport(el) {
 var top = el.offsetTop;
 var left = el.offsetLeft;
 var width = el.offsetWidth;
 var height = el.offsetHeight;
 
 var tmp  = getScrollXY();
 var pXoff = tmp[0];
 var pYoff = tmp[1]; 
 
 while(el.offsetParent) {
   el = el.offsetParent;
   top += el.offsetTop;
   left += el.offsetLeft;
 }

 return (
   top >= window.pageYOffset &&
   left >= window.pageXOffset &&
   (top + height) <= (window.pageYOffset + window.innerHeight) &&
   (left + width) <= (window.pageXOffset + window.innerWidth)
 );
}


function elementPartInViewport(el) {
 var top = el.offsetTop;
 var left = el.offsetLeft;
 var width = el.offsetWidth;
 var height = el.offsetHeight;

 while(el.offsetParent) {
   el = el.offsetParent;
   top += el.offsetTop;
   left += el.offsetLeft;
 }

 return (
   top < (window.pageYOffset + window.innerHeight) &&
   left < (window.pageXOffset + window.innerWidth) &&
   (top + height) > window.pageYOffset &&
   (left + width) > window.pageXOffset
 );
}


//takes in a id for a pulldown
//will look through options and get the selected index and return value
//of pd_val if found
function getSelectedValue(pulldownObj){
	if(!pulldownObj)
		return "";
		
  for (var optionCounter = 0; optionCounter < pulldownObj.length; optionCounter++) { 
			if (pulldownObj.selectedIndex == optionCounter){
				//this is selected index so return value
				return pulldownObj.options[optionCounter].value;
			}		
	}
	
	return "";
}


//takes in a id for a pulldown
//will look through options and get the selected index and return value
//if 2nd param is true list is returned csl otherwise no seperators
//of pd_val if found
function getMultSelectedValues(pulldownObj, csl){
	if(!pulldownObj)
		return "";
	
	var ret_val = "";
  for (var optionCounter = 0; optionCounter < pulldownObj.length; optionCounter++) { 
			if (pulldownObj.options[optionCounter].selected && 
			(pulldownObj.options[optionCounter].value != undefined && pulldownObj.options[optionCounter].value != '')){
				//this is selected index so add to list
				if(csl){
					ret_val += pulldownObj.options[optionCounter].value + ',';
				}
				else{
					ret_val += pulldownObj.options[optionCounter].value;
				}
			}		
	}
	
	if(csl && ret_val.length > 0){
		//remove last ,
		ret_val = ret_val.slice(0, -1);
	}
	
	return ret_val;
}

function isCheckedSubmit(frm, fld, tmsg){
	//check if passed in fld was checked.
	//this assumes that fld is a checkbox input type
	//if yes then submit form otherwise alert tmsg
	getObj(fld);
	if(myObj.checked){
		getObj('Submit');
		myObj.value='Processing, please wait ...';
		myObj.onclick = new Function('return false'); 
		frm.submit();
	}
	else{
		//not checked
		alert(tmsg);
		return false;
	}
	
}

function init() {

      for (var i=0; i<document.images.length; i++) {
        if (!document.images[i].complete) {
            document.images[i].src = document.images[i].src;
        }
			}
}


//map code
var coords = {};
var centLat = 0;
var centLon = 0;
var centAdd = '';
var map;
var geocoder;
var plain_icons = false;

function setCenterCoords(cadd, cla, clo){
	if(centLat == 0 && cla != ''){
		centLat = parseFloat(cla);
	}
	
	if(centLon == 0 && clo != ''){
		centLon = parseFloat(clo);
	}
	
	if(centAdd == '' && cadd != ''){
		centAdd = cadd;
	}
	
}

function initializeMap(zoom, picons) {
	plain_icons = (picons) ? true : plain_icons;
	//check that coords are set. if none don't show
	if((centLat == 0  || centLon == 0) && document.getElementById("map_canvas") != null){
		document.getElementById("map_canvas").style.display = 'none';
		return 1;
	}
	else if(document.getElementById("map_canvas") == null){
		return 1;
	}
	
  if (GBrowserIsCompatible()) {  	    
    geocoder = new GClientGeocoder();

    map = new GMap2(document.getElementById("map_canvas"));
    /*
    if(centLat == 0 || centLon == 0){
    	//get center from address
    	geocoder.getLatLng(
          centAdd,
          function(point) {
            if (!point) {
              document.getElementById("map_canvas").style.display = 'none';
							return 1;
            } else {
              map.setCenter(point, zoom);
            }
          }
        );
    }
    else{
    	map.setCenter(new GLatLng(centLat, centLon), zoom);
    }
    */
    map.setCenter(new GLatLng(centLat, centLon), zoom);
    
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());

    // Create a base icon for all of our markers that specifies the
    // shadow, icon dimensions, etc.
    var baseIcon = new GIcon();
    baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
    baseIcon.iconSize = new GSize(20, 34);
    baseIcon.shadowSize = new GSize(37, 34);
    baseIcon.iconAnchor = new GPoint(9, 34);
    baseIcon.infoWindowAnchor = new GPoint(9, 2);
    baseIcon.infoShadowAnchor = new GPoint(18, 25);
  
		// Creates a marker whose info window displays the letter corresponding
		// to the given index.
		function createMarker(point, index, html, act, marker_title) {
		  // Create a lettered icon for this point using our icon class
		  var marker;
		  if(plain_icons){		 		  	
		  		var letteredIcon = new GIcon(baseIcon);
		  		if(act == '1'){
		  			//alert('active');
				  	letteredIcon.image = "/images/active_marker.png";		
				  }
				  else{
				  	letteredIcon.image = "http://www.google.com/mapfiles/marker.png";		
				  }
				  // Set up our GMarkerOptions object
				  marker = new GMarker(point, { title: marker_title, icon:letteredIcon });				  		  
		  }
			else{
			  var letter = String.fromCharCode("A".charCodeAt(0) + index);
			  //alert(letter);
			  var letteredIcon = new GIcon(baseIcon);
				letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";			
			  // Set up our GMarkerOptions object
			  //markerOptions = { icon:letteredIcon };
			  marker = new GMarker(point, { title: marker_title, icon:letteredIcon });
			}
		
		  GEvent.addListener(marker, "click", function() {
		    marker.openInfoWindowHtml(html);
		  });
		  return marker;
		}
		
		//add markers
		var z = 0;
    for (var i in coords) {
    	if(coords[i]['lat'] != '' && coords[i]['lon'] != ''){
	    	//alert('lat= ' + coords[i]['lat'] + 'lon = ' + coords[i]['lon']);
	      var point = new GLatLng(parseFloat(coords[i]['lat']),parseFloat(coords[i]['lon']));
	      var tmp_marker = createMarker(point, z, coords[i]['html'], coords[i]['active'], coords[i]['title']);
	      map.addOverlay(tmp_marker);	      
	    }
	    z++;
    }
  }
  else{
  	//hide map since can't view it
  	document.getElementById("map_canvas").style.display = 'none';
  }
}

function showMapPopup(i){
	if(coords[i]['lat'] != '' && coords[i]['lon'] != ''){
		map.openInfoWindowHtml(new GLatLng(parseFloat(coords[i]['lat']),parseFloat(coords[i]['lon'])), coords[i]['html']);
	}
	else{
		geocoder.getLatLng(
          coords[i]['address'],
          function(point) {
            if (point) {
              map.openInfoWindowHtml(point, coords[i]['html']);
            }
          }
        );
	}
}

/* code for dynamic searching map */

var listings_shown = false;
function initializeSearchMap(zoom) {
	
	//check that coords are set. if none don't show
	if((centLat == 0  || centLon == 0) && document.getElementById("search_map_canvas") != null){
		document.getElementById("search_map_canvas").style.display = 'none';
		return 1;
	}
	else if(document.getElementById("search_map_canvas") == null){
		return 1;
	}
	
  if (GBrowserIsCompatible()) {
  	geocoder = new GClientGeocoder();
  	document.getElementById('rr-sc').value = 'asdfh8203327843jlksafnhuiui';
    map = new GMap2(document.getElementById("search_map_canvas"));
    
    map.setCenter(new GLatLng(centLat, centLon), zoom);
    
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    
    
    //add listeners used for search
    //GEvent.addListener(map, "dragend", function (){ MapSearchEvent(); });
    //GEvent.addListener(map, "zoomend", function (){ MapSearchEvent(); });		  
		GEvent.addListener(map, "moveend", function (){ MapSearchEvent(); });
  }
  else{
  	//hide map since can't view it
  	document.getElementById("search_map_canvas").style.display = 'none';
  }
}

function MapSearchEvent() {
	//alert('MOVEEND - zoom level: ' + map.getZoom() + ' center coords: ' + map.getCenter().toUrlValue());
	var cur_zoom = map.getZoom();
	var cur_cent_lat = map.getCenter().lat();
	var cur_cent_lng = map.getCenter().lng();
	
	if(cur_zoom >= 13 && ! listings_shown){
		//alert('you can see the bars now ' + cur_zoom + ' ' + cur_cent_lat + ' x ' + cur_cent_lng);
		
		//ajax the radius search results for this center point with a 50-100 mi radius around it.
		//set markers for resutls.
		document.getElementById("search_map_canvas").style.display = 'none';
		document.getElementById("search_map_canvas_wait").style.display = '';
		DrawListingMarkers(cur_cent_lat, cur_cent_lng, 5);
	}
	else if(cur_zoom < 13){
		listings_shown = false;
    for (var i in coords) {
    	if(coords[i]['marker_obj'] != '' && coords[i]['marker_obj'] != 'undefined'){
	      map.removeOverlay(coords[i]['marker_obj']);	
	    }
    }
	}

}

//used to zoom to address from main form.
function zoomToAddress(address) {			
  listings_shown = false;
  for (var i in coords) {
  	if(coords[i]['marker_obj'] != '' && coords[i]['marker_obj'] != 'undefined'){
      map.removeOverlay(coords[i]['marker_obj']);	
    }
  }
  if (geocoder) {
    geocoder.getLatLng(
      address,
      function(point) {
        if (!point) {
          alert("Location: " + address + " not found, enter an address or zipcode to ZOOM to.");
        } else {
          map.setCenter(point, 13);
          //var marker = new GMarker(point);
          //map.addOverlay(marker);
          //marker.openInfoWindowHtml(address);
        }
      }
    );
  }
}

function PanByAdd(addr){
	if (geocoder) {
    geocoder.getLatLng(
      addr,
      function(point) {
        if (point) {
          map.panTo(point);
        }
      }
    );
  }
}


//called from search result page and will reposition wrapper if not in view any more
function checkMapWrapper(){
	if($('search-results-map-wrapper') != undefined){
		//if( ! elementAllInViewport($('search-results-map-wrapper'))){
		if(getScrollXY()[1] > 300){
			//alert('need to move');
			$('search-results-map-wrapper').className = 'search-results-map-wrapper-fixed';
		}
		else{
			//alert('its all shown');
			$('search-results-map-wrapper').className = 'search-results-map-wrapper';
		}
	}
}

/* ends dyn search map code */



//Javascript name: My Date Time Picker
//Date created: 16-Nov-2003 23:19
//Scripter: TengYong Ng
//Website: http://www.rainforestnet.com
//Copyright (c) 2003 TengYong Ng
//FileName: DateTimePicker.js
//Version: 0.8
//Contact: contact@rainforestnet.com
// Note: Permission given to use this script in ANY kind of applications if
//       header lines are left unchanged.

//Global variables
var winCal;
var dtToday=new Date();
var Cal;
var docCal;
var MonthName=["January", "February", "March", "April", "May", "June","July", 
	"August", "September", "October", "November", "December"];
var WeekDayName=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];	
var exDateTime;//Existing Date and Time

//Configurable parameters
var cnTop="200";//top coordinate of calendar window.
var cnLeft="500";//left coordinate of calendar window
var WindowTitle ="DateTime Picker";//Date Time Picker title.
var WeekChar=2;//number of character for week day. if 2 then Mo,Tu,We. if 3 then Mon,Tue,Wed.
var CellWidth=20;//Width of day cell.
var DateSeparator="-";//Date Separator, you can change it to "/" if you want.
var TimeMode=24;//default TimeMode value. 12 or 24

var ShowLongMonth=true;//Show long month name in Calendar header. example: "January".
var ShowMonthYear=true;//Show Month and Year in Calendar header.
var MonthYearColor="#cc0033";//Font Color of Month and Year in Calendar header.
var WeekHeadColor="#0099CC";//Background Color in Week header.
var SundayColor="#6699FF";//Background color of Sunday.
var SaturdayColor="#CCCCFF";//Background color of Saturday.
var WeekDayColor="white";//Background color of weekdays.
var FontColor="blue";//color of font in Calendar day cell.
var TodayColor="#FFFF33";//Background color of today.
var SelDateColor="#FFFF99";//Backgrond color of selected date in textbox.
var YrSelColor="#cc0033";//color of font of Year selector.
var ThemeBg="";//Background image of Calendar window.
//end Configurable parameters
//end Global variable

function NewCal(pCtrl,pFormat,pShowTime,pTimeMode)
{
	Cal=new Calendar(dtToday);
	if ((pShowTime!=null) && (pShowTime))
	{
		Cal.ShowTime=true;
		if ((pTimeMode!=null) &&((pTimeMode=='12')||(pTimeMode=='24')))
		{
			TimeMode=pTimeMode;
		}		
	}	
	if (pCtrl!=null)
		Cal.Ctrl=pCtrl;
	if (pFormat!=null)
		Cal.Format=pFormat.toUpperCase();
	
	exDateTime=document.getElementById(pCtrl).value;
	if (exDateTime!="")//Parse Date String
	{
		var Sp1;//Index of Date Separator 1
		var Sp2;//Index of Date Separator 2 
		var tSp1;//Index of Time Separator 1
		var tSp1;//Index of Time Separator 2
		var strMonth;
		var strDate;
		var strYear;
		var intMonth;
		var YearPattern;
		var strHour;
		var strMinute;
		var strSecond;
		//parse month
		Sp1=exDateTime.indexOf(DateSeparator,0)
		Sp2=exDateTime.indexOf(DateSeparator,(parseInt(Sp1)+1));
		
		if ((Cal.Format.toUpperCase()=="DDMMYYYY") || (Cal.Format.toUpperCase()=="DDMMMYYYY"))
		{
			strMonth=exDateTime.substring(Sp1+1,Sp2);
			strDate=exDateTime.substring(0,Sp1);
		}
		else if ((Cal.Format.toUpperCase()=="MMDDYYYY") || (Cal.Format.toUpperCase()=="MMMDDYYYY"))
		{
			strMonth=exDateTime.substring(0,Sp1);
			strDate=exDateTime.substring(Sp1+1,Sp2);
		}
		if (isNaN(strMonth))
			intMonth=Cal.GetMonthIndex(strMonth);
		else
			intMonth=parseInt(strMonth,10)-1;	
		if ((parseInt(intMonth,10)>=0) && (parseInt(intMonth,10)<12))
			Cal.Month=intMonth;
		//end parse month
		//parse Date
		if ((parseInt(strDate,10)<=Cal.GetMonDays()) && (parseInt(strDate,10)>=1))
			Cal.Date=strDate;
		//end parse Date
		//parse year
		strYear=exDateTime.substring(Sp2+1,Sp2+5);
		YearPattern=/^\d{4}$/;
		if (YearPattern.test(strYear))
			Cal.Year=parseInt(strYear,10);
		//end parse year
		//parse time
		if (Cal.ShowTime==true)
		{
			tSp1=exDateTime.indexOf(":",0)
			tSp2=exDateTime.indexOf(":",(parseInt(tSp1)+1));
			strHour=exDateTime.substring(tSp1,(tSp1)-2);
			Cal.SetHour(strHour);
			strMinute=exDateTime.substring(tSp1+1,tSp2);
			Cal.SetMinute(strMinute);
			strSecond=exDateTime.substring(tSp2+1,tSp2+3);
			Cal.SetSecond(strSecond);
		}	
	}
	winCal=window.open("","DateTimePicker","toolbar=0,status=0,menubar=0,fullscreen=no,width=195,height=245,resizable=0,top="+cnTop+",left="+cnLeft);
	docCal=winCal.document;
	RenderCal();
}

function RenderCal()
{
	var vCalHeader;
	var vCalData;
	var vCalTime;
	var i;
	var j;
	var SelectStr;
	var vDayCount=0;
	var vFirstDay;

	docCal.open();
	docCal.writeln("<html><head><title>"+WindowTitle+"</title>");
	docCal.writeln("<script>var winMain=window.opener;</script>");
	docCal.writeln("</head><body background='"+ThemeBg+"' link="+FontColor+" vlink="+FontColor+"><form name='Calendar'>");

	vCalHeader="<table border=1 cellpadding=1 cellspacing=1 width='100%' align=\"center\" valign=\"top\">\n";
	//Month Selector
	vCalHeader+="<tr>\n<td colspan='7'><table border=0 width='100%' cellpadding=0 cellspacing=0><tr><td align='left'>\n";
	vCalHeader+="<select name=\"MonthSelector\" onChange=\"javascript:winMain.Cal.SwitchMth(this.selectedIndex);winMain.RenderCal();\">\n";
	for (i=0;i<12;i++)
	{
		if (i==Cal.Month)
			SelectStr="Selected";
		else
			SelectStr="";	
		vCalHeader+="<option "+SelectStr+" value >"+MonthName[i]+"\n";
	}
	vCalHeader+="</select></td>";
	//Year selector
	vCalHeader+="\n<td align='right'><a href=\"javascript:winMain.Cal.DecYear();winMain.RenderCal()\"><b><font color=\""+YrSelColor+"\"><</font></b></a><font face=\"Verdana\" color=\""+YrSelColor+"\" size=2><b> "+Cal.Year+" </b></font><a href=\"javascript:winMain.Cal.IncYear();winMain.RenderCal()\"><b><font color=\""+YrSelColor+"\">></font></b></a></td></tr></table></td>\n";	
	vCalHeader+="</tr>";
	//Calendar header shows Month and Year
	if (ShowMonthYear)
		vCalHeader+="<tr><td colspan='7'><font face='Verdana' size='2' align='center' color='"+MonthYearColor+"'><b>"+Cal.GetMonthName(ShowLongMonth)+" "+Cal.Year+"</b></font></td></tr>\n";
	//Week day header
	vCalHeader+="<tr bgcolor="+WeekHeadColor+">";
	for (i=0;i<7;i++)
	{
		vCalHeader+="<td align='center'><font face='Verdana' size='2'>"+WeekDayName[i].substr(0,WeekChar)+"</font></td>";
	}
	vCalHeader+="</tr>";	
	docCal.write(vCalHeader);
	
	//Calendar detail
	CalDate=new Date(Cal.Year,Cal.Month);
	CalDate.setDate(1);
	vFirstDay=CalDate.getDay();
	vCalData="<tr>";
	for (i=0;i<vFirstDay;i++)
	{
		vCalData=vCalData+GenCell();
		vDayCount=vDayCount+1;
	}
	for (j=1;j<=Cal.GetMonDays();j++)
	{
		var strCell;
		vDayCount=vDayCount+1;
		if ((j==dtToday.getDate())&&(Cal.Month==dtToday.getMonth())&&(Cal.Year==dtToday.getFullYear()))
			strCell=GenCell(j,true,TodayColor);//Highlight today's date
		else
		{
			if (j==Cal.Date)
			{
				strCell=GenCell(j,true,SelDateColor);
			}
			else
			{	 
				if (vDayCount%7==0)
					strCell=GenCell(j,false,SaturdayColor);
				else if ((vDayCount+6)%7==0)
					strCell=GenCell(j,false,SundayColor);
				else
					strCell=GenCell(j,null,WeekDayColor);
			}		
		}						
		vCalData=vCalData+strCell;

		if((vDayCount%7==0)&&(j<Cal.GetMonDays()))
		{
			vCalData=vCalData+"</tr>\n<tr>";
		}
	}
	docCal.writeln(vCalData);	
	//Time picker
	if (Cal.ShowTime)
	{
		var showHour;
		showHour=Cal.getShowHour();		
		vCalTime="<tr>\n<td colspan='7' align='center'>";
		vCalTime+="<input type='text' name='hour' maxlength=2 size=1 style=\"WIDTH: 22px\" value="+showHour+" onchange=\"javascript:winMain.Cal.SetHour(this.value)\">";
		vCalTime+=" : ";
		vCalTime+="<input type='text' name='minute' maxlength=2 size=1 style=\"WIDTH: 22px\" value="+Cal.Minutes+" onchange=\"javascript:winMain.Cal.SetMinute(this.value)\">";
		vCalTime+=" : ";
		vCalTime+="<input type='text' name='second' maxlength=2 size=1 style=\"WIDTH: 22px\" value="+Cal.Seconds+" onchange=\"javascript:winMain.Cal.SetSecond(this.value)\">";
		if (TimeMode==12)
		{
			var SelectAm =(parseInt(Cal.Hours,10)<12)? "Selected":"";
			var SelectPm =(parseInt(Cal.Hours,10)>=12)? "Selected":"";

			vCalTime+="<select name=\"ampm\" onchange=\"javascript:winMain.Cal.SetAmPm(this.options[this.selectedIndex].value);\">";
			vCalTime+="<option "+SelectAm+" value=\"AM\">AM</option>";
			vCalTime+="<option "+SelectPm+" value=\"PM\">PM<option>";
			vCalTime+="</select>";
		}	
		vCalTime+="\n</td>\n</tr>";
		docCal.write(vCalTime);
	}	
	//end time picker
	docCal.writeln("\n</table>");
	docCal.writeln("</form></body></html>");
	docCal.close();
}

function GenCell(pValue,pHighLight,pColor)//Generate table cell with value
{
	var PValue;
	var PCellStr;
	var vColor;
	var vHLstr1;//HighLight string
	var vHlstr2;
	var vTimeStr;
	
	if (pValue==null)
		PValue="";
	else
		PValue=pValue;
	
	if (pColor!=null)
		vColor="bgcolor=\""+pColor+"\"";
	else
		vColor="";	
	if ((pHighLight!=null)&&(pHighLight))
		{vHLstr1="color='red'><b>";vHLstr2="</b>";}
	else
		{vHLstr1=">";vHLstr2="";}	
	
	if (Cal.ShowTime)
	{
		vTimeStr="winMain.document.getElementById('"+Cal.Ctrl+"').value+=' '+"+"winMain.Cal.getShowHour()"+"+':'+"+"winMain.Cal.Minutes"+"+':'+"+"winMain.Cal.Seconds";
		if (TimeMode==12)
			vTimeStr+="+' '+winMain.Cal.AMorPM";
	}	
	else
		vTimeStr="";		
	PCellStr="<td "+vColor+" width="+CellWidth+" align='center'><font face='verdana' size='2'"+vHLstr1+"<a href=\"javascript:winMain.document.getElementById('"+Cal.Ctrl+"').value='"+Cal.FormatDate(PValue)+"';"+vTimeStr+";window.close();\">"+PValue+"</a>"+vHLstr2+"</font></td>";
	return PCellStr;
}

function Calendar(pDate,pCtrl)
{
	//Properties
	this.Date=pDate.getDate();//selected date
	this.Month=pDate.getMonth();//selected month number
	this.Year=pDate.getFullYear();//selected year in 4 digits
	this.Hours=pDate.getHours();	
	
	if (pDate.getMinutes()<10)
		this.Minutes="0"+pDate.getMinutes();
	else
		this.Minutes=pDate.getMinutes();
	
	if (pDate.getSeconds()<10)
		this.Seconds="0"+pDate.getSeconds();
	else		
		this.Seconds=pDate.getSeconds();
		
	this.MyWindow=winCal;
	this.Ctrl=pCtrl;
	this.Format="ddMMyyyy";
	this.Separator=DateSeparator;
	this.ShowTime=false;
	if (pDate.getHours()<12)
		this.AMorPM="AM";
	else
		this.AMorPM="PM";	
}

function GetMonthIndex(shortMonthName)
{
	for (i=0;i<12;i++)
	{
		if (MonthName[i].substring(0,3).toUpperCase()==shortMonthName.toUpperCase())
		{	return i;}
	}
}
Calendar.prototype.GetMonthIndex=GetMonthIndex;

function IncYear()
{	Cal.Year++;}
Calendar.prototype.IncYear=IncYear;

function DecYear()
{	Cal.Year--;}
Calendar.prototype.DecYear=DecYear;
	
function SwitchMth(intMth)
{	Cal.Month=intMth;}
Calendar.prototype.SwitchMth=SwitchMth;

function SetHour(intHour)
{	
	var MaxHour;
	var MinHour;
	if (TimeMode==24)
	{	MaxHour=23;MinHour=0}
	else if (TimeMode==12)
	{	MaxHour=12;MinHour=1}
	else
		alert("TimeMode can only be 12 or 24");		
	var HourExp=new RegExp("^\\d\\d$");
	if (HourExp.test(intHour) && (parseInt(intHour,10)<=MaxHour) && (parseInt(intHour,10)>=MinHour))
	{	
		if ((TimeMode==12) && (Cal.AMorPM=="PM"))
		{
			if (parseInt(intHour,10)==12)
				Cal.Hours=12;
			else	
				Cal.Hours=parseInt(intHour,10)+12;
		}	
		else if ((TimeMode==12) && (Cal.AMorPM=="AM"))
		{
			if (intHour==12)
				intHour-=12;
			Cal.Hours=parseInt(intHour,10);
		}
		else if (TimeMode==24)
			Cal.Hours=parseInt(intHour,10);	
	}
}
Calendar.prototype.SetHour=SetHour;

function SetMinute(intMin)
{
	var MinExp=new RegExp("^\\d\\d$");
	if (MinExp.test(intMin) && (intMin<60))
		Cal.Minutes=intMin;
}
Calendar.prototype.SetMinute=SetMinute;

function SetSecond(intSec)
{	
	var SecExp=new RegExp("^\\d\\d$");
	if (SecExp.test(intSec) && (intSec<60))
		Cal.Seconds=intSec;
}
Calendar.prototype.SetSecond=SetSecond;

function SetAmPm(pvalue)
{
	this.AMorPM=pvalue;
	if (pvalue=="PM")
	{
		this.Hours=(parseInt(this.Hours,10))+12;
		if (this.Hours==24)
			this.Hours=12;
	}	
	else if (pvalue=="AM")
		this.Hours-=12;	
}
Calendar.prototype.SetAmPm=SetAmPm;

function getShowHour()
{
	var finalHour;
    if (TimeMode==12)
    {
    	if (parseInt(this.Hours,10)==0)
		{
			this.AMorPM="AM";
			finalHour=parseInt(this.Hours,10)+12;	
		}
		else if (parseInt(this.Hours,10)==12)
		{
			this.AMorPM="PM";
			finalHour=12;
		}		
		else if (this.Hours>12)
		{
			this.AMorPM="PM";
			if ((this.Hours-12)<10)
				finalHour="0"+((parseInt(this.Hours,10))-12);
			else
				finalHour=parseInt(this.Hours,10)-12;	
		}
		else
		{
			this.AMorPM="AM";
			if (this.Hours<10)
				finalHour="0"+parseInt(this.Hours,10);
			else
				finalHour=this.Hours;	
		}
	}
	else if (TimeMode==24)
	{
		if (this.Hours<10)
			finalHour="0"+parseInt(this.Hours,10);
		else	
			finalHour=this.Hours;
	}	
	return finalHour;	
}				
Calendar.prototype.getShowHour=getShowHour;		

function GetMonthName(IsLong)
{
	var Month=MonthName[this.Month];
	if (IsLong)
		return Month;
	else
		return Month.substr(0,3);
}
Calendar.prototype.GetMonthName=GetMonthName;

function GetMonDays()//Get number of days in a month
{
	var DaysInMonth=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	if (this.IsLeapYear())
	{
		DaysInMonth[1]=29;
	}	
	return DaysInMonth[this.Month];	
}
Calendar.prototype.GetMonDays=GetMonDays;

function IsLeapYear()
{
	if ((this.Year%4)==0)
	{
		if ((this.Year%100==0) && (this.Year%400)!=0)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return false;
	}
}
Calendar.prototype.IsLeapYear=IsLeapYear;

function FormatDate(pDate)
{
	if (this.Format.toUpperCase()=="DDMMYYYY")
		return (pDate+DateSeparator+(this.Month+1)+DateSeparator+this.Year);
	else if (this.Format.toUpperCase()=="DDMMMYYYY")
		return (pDate+DateSeparator+this.GetMonthName(false)+DateSeparator+this.Year);
	else if (this.Format.toUpperCase()=="MMDDYYYY")
		return ((this.Month+1)+DateSeparator+pDate+DateSeparator+this.Year);
	else if (this.Format.toUpperCase()=="MMMDDYYYY")
		return (this.GetMonthName(false)+DateSeparator+pDate+DateSeparator+this.Year);			
}
Calendar.prototype.FormatDate=FormatDate;	

/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact

Modified
*/

var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 400;	// maximum image size. 270 was orig

if (document.getElementById || document.all){
	document.write('<div id="trailimageid">');
	document.write('</div>');
}

function gettrailobj(){
if (document.getElementById)
return document.getElementById("trailimageid").style
else if (document.all)
return document.all.trailimagid.style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("trailimageid")
else if (document.all)
return document.all.trailimagid
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showtrail(imagename,title,description,ratingaverage,ratingnumber,showthumb,height, width){

	if (height > 0){
		currentimageheight = height;
	}

	document.onmousemove=followmouse;

	cameraHTML = '';

	/*
	if (ratingnumber == 0){
		ratingaverage = 0;
	}

	for(x = 1; x <= 5; x++){

		if (ratingaverage >= 1){
			cameraHTML = cameraHTML + '<img src="/images/camera_1.gif">';
		} else if (ratingaverage >= 0.5){
			cameraHTML = cameraHTML + '<img src="/images/camera_05.gif">';
		} else {
			cameraHTML = cameraHTML + '<img src="/images/camera_0.gif">';
		}
	
		ratingaverage = ratingaverage - 1;
	}

	cameraHTML = cameraHTML + ' (' + ratingnumber + ' Review';
	if ( ratingnumber != 1 ) cameraHTML += 's';
	cameraHTML = cameraHTML + ')';
	*/

	newHTML = '<div style="padding: 1px; background-color: #FFF; border: 1px solid #888;">';
	newHTML = newHTML + '<span style="font-weight: bold; font-size: 14px; ">' + title + ' </span>';
	newHTML = newHTML + '<span style="font-size: 14px; ">' + description+'</span><br/><br/>';
	//newHTML = newHTML + 'Rating: ' + cameraHTML + '<br/>';
	//newHTML = newHTML + description + '<br/>';

	//added hardcoded widths and height in image tag based on params passed in.
	//we may opt to not do this if the program returning the image cna resize dynamically.

	if (showthumb > 0){
		//newHTML = newHTML + '<div align="center" style="padding: 8px 2px 2px 2px;"><img src="' + imagename + '" border="0" width="'+width+'" height="'+height+'"></div>';
		newHTML = newHTML + '<div align="center"><img src="' + imagename + '" border="0"></div>';
	}

	//newHTML = newHTML + '<br /><center><span style="font-size: 12px;color:#62567a">Click for Details</span></center><br/></div>';
	newHTML = newHTML + '<br/></div>';
	
	gettrailobjnostyle().innerHTML = newHTML;

	gettrailobj().visibility="visible";

}

/*
call by adding this to tag
 onmouseover="showstatictrail(
								'TITLE','something to show can be html if escaped',150,250);" 
		onmouseout="hidetrail();"
*/
function showstatictrail(title,description,height, width){

	if (height > 0){
		currentimageheight = height;
	}
	
	document.getElementById('trailimageid').style.width = width;

	document.onmousemove=followmouse;

	
	newHTML = '<div style="padding: 10px; background-color: #DAF1DA; border: 1px solid #1C661C;">';
	newHTML = newHTML + '<span style="font-weight: bold; font-size: 14px; ">' + title + ' </span>';
	newHTML = newHTML + '<span style="font-size: 14px; ">' + description+'</span>';


	newHTML = newHTML + '</div>';
	
	gettrailobjnostyle().innerHTML = newHTML;

	gettrailobj().visibility="visible";

}



function hidetrail(){
	gettrailobj().visibility="hidden"
	document.onmousemove=""
	gettrailobj().left="-500px"

}

function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	//if (document.all){
	//	gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br>B = ' + truebody().clientHeight;
	//} else {
	//	gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	//}

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 450){
			xcoord = e.pageX - xcoord - 450; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 110)){
			ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 450){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 450; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 110)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}


//DD Tab Menu- Last updated April 27th, 07: http://www.dynamicdrive.com
//Only 1 configuration variable below
var current_submenu = '';
var previous_submenu = '';
var logged_in = false; //might get overwritten and will bsed for patrons subtab option
var logged_in_as = ''; //might get overwritten and will bsed for patrons subtab option

//build html divs for submenus
//do it here rather then in xsl so we can limit the amount of text rendered on page load
var  tab_sb1 = "<a href=\"/\" title=\"Index\">Index</a>            <a href=\"/aboutus.aspx\" title=\"About Us\">About US</a>            <a href=\"/contactus.aspx\" title=\"Contact Us\">Contact US</a>            <a href=\"/sponsors.aspx\" title=\"Links\">Sponsored Links</a>            <a href=\"/vote_best_of.aspx\" title=\"Best Of BarFinder\">Best Of BarFinder</a>            <a href=\"/beerpong.aspx\" title=\"Beer Pong\">Beer Pong</a>	<a href=\"/the-party-card.aspx\" title=\"The Party Card\">The Party Card</a> 	<a href=\"/newsletters.aspx\" title=\"Newsletter Index\">Newsletters</a>";
			 
var  tab_sb2 = "<a href=\"/listings.aspx\" title=\"Bars Home\">Home</a>            <a href=\"/barowner.aspx\" title=\"Own a Bar\">Own A Bar/Club</a>            <a href=\"/listings/add.aspx\" title=\"Add Bar\">Add</a>            <a href=\"/listings/manage.aspx\" title=\"Manage Your Bars\">Manage</a>            <a href=\"/listings/search.aspx\" title=\"Search Bars\">Search</a>            <a href=\"/listings/browse.aspx\" title=\"Browse Bars By Area\">Browse</a>            <a href=\"/cameras.aspx\" title=\"Live Video Camera Feeds\">Live Bar Cameras</a>            <a href=\"/bartenders.aspx\" title=\"Bartenders\">Bartenders</a>	<a href=\"/user/premiere_signup.aspx\" title=\"Premier Packages\">Premier Packages</a>";

var  tab_sb3 = "<a href=\"/bands_djs.aspx\" title=\"Bands Home\">Home</a>            <a href=\"/band_dj_owner.aspx\" title=\"Own a Band\">Own A Band/DJ</a>            <a href=\"/bands_djs/add.aspx\" title=\"Add Bands\">Add</a>            <a href=\"/bands_djs/manage.aspx\" title=\"Manage Your Bands\">Manage</a>            <a href=\"/bands_djs/search.aspx\" title=\"Search Bands\">Search</a>            <a href=\"/bands_djs/browse.aspx\" title=\"Browse Bands By Area\">Browse</a>            <a href=\"/user/premiere_signup.aspx?type=bands_djs\" title=\"Premier Packages\">Premier Packages</a>";

//tab 4 is user based so login status matters
var  tab_sb4_out = "<a href=\"/user/login.aspx\" title=\"Login\">Login</a>             			<a href=\"/user/join.aspx\" title=\"Join\">Join</a>         <a href=\"/poll_archives.aspx\" title=\"Poll Archives\">Polls</a>            <a href=\"/top_users.aspx\" title=\"Top Patrons\">Top Patrons</a>                        <a href=\"/user/search.aspx\" title=\"Search Users\">Search</a>                        <a href=\"/user/favorites.aspx\" title=\"My Favorites\">Favs</a>            <a href=\"/user/manage_friends.aspx\" title=\"My Buddies\">Buds</a>            <a href=\"/user/manage_messages.aspx\" title=\"My Messages\">Messages</a>            <a href=\"/user/manage_calendar.aspx\" title=\"My Calendar\">Calendar</a>            <a href=\"/filelibrary/web/previous/uploads/uid//search.aspx\" title=\"My Photos\">Photos</a> ";

var  tab_sb4_in = "<a href=\"/user/login.aspx?action=logout\" title=\"Logout\">Logout</a>              		<a href=\"/user/profile.aspx\" title=\"Manage Account\">Settings</a>              		<a href=\"/web/"+logged_in_as+"/\" title=\"My Profile\">Profile</a>       <a href=\"/poll_archives.aspx\" title=\"Poll Archives\">Polls</a>                              <a href=\"/user/search.aspx\" title=\"Search Users\">Search</a>                        <a href=\"/user/favorites.aspx\" title=\"My Favorites\">Favs</a>            <a href=\"/user/manage_friends.aspx\" title=\"My Buddies\">Buds</a>            <a href=\"/user/manage_messages.aspx\" title=\"My Messages\">Messages</a>            <a href=\"/user/manage_calendar.aspx\" title=\"My Calendar\">Calendar</a>            <a href=\"/filelibrary/web/previous/uploads/uid//search.aspx\" title=\"My Photos\">Photos</a> ";

var  tab_sb5 = "<a href=\"/drinks.aspx\" title=\"Drinks Home\">Home</a>            <a href=\"/drinks/add.aspx\" title=\"Add Drink\">Add Recipe</a>            <a href=\"/drinks/search.aspx\" title=\"Search Drinks\">Search Recipes</a>            <a href=\"/drinks/browse.aspx\" title=\"Browse Drinks\">Browse Recipes</a>			<a href=\"/drinks/beers.aspx\" title=\"Beer List\">Beer List</a>			<a href=\"/drinks/breweries.aspx\" title=\"Breweries List\">Breweries List</a>";

var  tab_sb6 = "<a href=\"/forum/\" title=\"Home\">Home</a>            <a href=\"/forum/index.aspx?forum_id=11\" title=\"Behind the Bar\">The Bar</a>            <a href=\"/forum/index.aspx?forum_id=2\" title=\"Games\">Games</a>            <a href=\"/forum/index.aspx?forum_id=3\" title=\"Work\">Work</a>            <a href=\"/forum/index.aspx?forum_id=4\" title=\"Sex\">Sex</a>            <a href=\"/forum/index.aspx?forum_id=5\" title=\"College\">College</a>            <a href=\"/forum/index.aspx?forum_id=6\" title=\"Life After College\">After College</a>            <a href=\"/forum/index.aspx?forum_id=7\" title=\"Sports\">Sports</a>            <a href=\"/forum/index.aspx?forum_id=8\" title=\"Parties\">Parties</a>            <a href=\"/forum/index.aspx?forum_id=9\" title=\"Open\">Open</a>            <a href=\"/forum/index.aspx?forum_id=1\" title=\"Development\">Dev</a> ";

var  tab_sb7 = "<a href=\"/filelibrary.aspx\" title=\"Filelibrary Home\">Home</a>            <a href=\"/filelibrary/\" title=\"Upload Photo\">Add</a>            <a href=\"/filelibrary/\" title=\"Search Photos\">Search</a>";

var  tab_sb8 = "<a href=\"/adinfo.aspx\" title=\"Info\">Info</a>            <a href=\"/adinquire.aspx\" title=\"Inquire\">Inquire</a>            <a href=\"/adadvantages.aspx\" title=\"Advantages\">Advantages</a>";

var  tab_sb9 = "<a href=\"/myareainfo.aspx\" title=\"My Area Home\">Home</a>			<a href=\"/myarea/\" title=\"View/Post Announcements\">View/Post Announcements</a>";

//var social_network_links = "<div style=\"position:relative; right:-40px; float:right;\"><a href=\"/feeds.aspx\" title=\"RSS Feeds\"><img src=\"/images/buttons/icons/rss.png\" height=\"16\" width=\"16\" class=\"absmiddle\"/></a>    <a href=\"http://www.facebook.com/barfinder\" title=\"Friend Us\" rel=\"nofollow\" target=\"_blank\">Facebook</a> <a href=\"https://twitter.com/barfindercom\" title=\"Follow Us\" rel=\"nofollow\" target=\"_blank\">Twitter</a>  <a href=\"http://www.myspace.com/barfinder\" title=\"Friend Us\" rel=\"nofollow\" target=\"_blank\">MySpace</a></div>";

var social_network_links = "<div style=\"position:relative; right:-40px; float:right;\"><a href=\"/feeds.aspx\" title=\"Follow Us\">Follow Us: <img src=\"/images/buttons/icons/rss.png\" height=\"16\" width=\"16\" class=\"absmiddle\"/>  <img src=\"/images/buttons/icons/facebook2.png\" height=\"16\" width=\"16\" class=\"absmiddle\"/>   <img src=\"/images/buttons/icons/twitter.png\" height=\"16\" width=\"16\" class=\"absmiddle\"/>  </a></div>";

var ddsubtabs = {};
ddsubtabs["sb1"] = tab_sb1;
ddsubtabs["sb2"] = tab_sb2;
ddsubtabs["sb3"] = tab_sb3;
ddsubtabs["sb4"] = tab_sb4_out;
ddsubtabs["sb5"] = tab_sb5;
ddsubtabs["sb6"] = tab_sb6;
ddsubtabs["sb7"] = tab_sb7;
ddsubtabs["sb8"] = tab_sb8;
ddsubtabs["sb9"] = tab_sb9;

var ddtabmenu={
	disabletablinks: false, ////Disable hyperlinks in 1st level tabs with sub contents (true or false)?
	stickytabs: true, ////require tab to be clicked to show subs and then clicked again to load tab
	currentpageurl: window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, ""), //get current page url (minus hostname, ie: http://www.dynamicdrive.com/)

definemenu:function(tabid, dselected){
	//since forums (tab 5 is gone anything above 5 needs to be dropped to avoid having to update all the pages)
	dselected = (dselected > 5) ? (dselected-1) : dselected
	
	this[tabid+"-menuitems"]=null
	this.addEvent(window, function(){ddtabmenu.init(tabid, dselected)}, "load")
},

showsubmenu:function(tabid, targetitem){
	var menuitems=this[tabid+"-menuitems"]
 for (i=0; i<menuitems.length; i++){
 	if(menuitems[i].className=="current"){
 		previous_submenu = menuitems[i];
 	}
		menuitems[i].className=""
		if (typeof menuitems[i].hasSubContent!="undefined"){
			//document.getElementById(menuitems[i].getAttribute("rel")).style.display="none";
		}
	}
	targetitem.className="current"
	current_submenu = targetitem;
	if (typeof targetitem.hasSubContent!="undefined"){
		//document.getElementById(targetitem.getAttribute("rel")).style.display="block"		
	   var attrs = {
			'id'   : targetitem.getAttribute("rel"),
			'class' : 'tabcontent',
			'style' : "display: block"
		};
		var submenu = new Element('div', attrs);

		//check if users - sb4 and if logged in		
		if(logged_in && targetitem.getAttribute("rel") == "sb4"){
			ddsubtabs["sb4"] = tab_sb4_in.replace("/web//", "/web/"+logged_in_as+"/");
		}
		else{
			ddsubtabs["sb4"] = tab_sb4_out;
		}
		
		submenu.update(social_network_links + ddsubtabs[targetitem.getAttribute("rel")]);		
		//submenu.innerHTML;
		$('ddsubtabs').update(); //clears it
		$('ddsubtabs').appendChild(submenu);
		$(targetitem.getAttribute("rel")).className = "tabcontent";
		//$('ddsubtabs').innerHTML;
		$('ddsubtabs').show();
	}
},

isSelected:function(menuurl){
	var menuurl=menuurl.replace("http://"+menuurl.hostname, "").replace(/^\//, "")
	return (ddtabmenu.currentpageurl==menuurl)
},

addEvent:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
},

init:function(tabid, dselected){
	var menuitems=document.getElementById(tabid).getElementsByTagName("a")
	this[tabid+"-menuitems"]=menuitems
	for (var x=0; x<menuitems.length; x++){
		if (menuitems[x].getAttribute("rel")){
			this[tabid+"-menuitems"][x].hasSubContent=true
			if (ddtabmenu.disabletablinks)
				menuitems[x].onclick=function(){return false}
		}
		else //for items without a submenu, add onMouseout effect
			menuitems[x].onmouseout=function(){this.className=""}
		menuitems[x].onclick=function(){ddtabmenu.showsubmenu(tabid, this); return isSubmenuDisplayed(tabid,this);}
		if (dselected=="auto" && typeof setalready=="undefined" && this.isSelected(menuitems[x].href)){
			ddtabmenu.showsubmenu(tabid, menuitems[x])
			var setalready=true
		}
		else if (parseInt(dselected)==x)
			ddtabmenu.showsubmenu(tabid, menuitems[x])
	}
}
}

function isSubmenuDisplayed(tabid, targetitem){
	if(previous_submenu == targetitem && targetitem.className == "current"){
		return true;
	}
	else{
		return false;
	}
}

/**
 * COMMON DHTML FUNCTIONS
 * These are handy functions I use all the time.
 *
 * By Seth Banks (webmaster at subimage dot com)
 * http://www.subimage.com/
 *
 * Up to date code can be found at http://www.subimage.com/dhtml/
 *
 * This code is free for you to use anywhere, just keep this comment block.
 */

/**
 * X-browser event handler attachment and detachment
 * TH: Switched first true to false per http://www.onlinetools.org/articles/unobtrusivejavascript/chapter4.html
 *
 * @argument obj - the object to attach event to
 * @argument evType - name of the event - DONT ADD "on", pass only "mouseover", etc
 * @argument fn - function to call
 */
function addEvent(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, false);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
}
function removeEvent(obj, evType, fn, useCapture){	
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
}

/**
 * Code below taken from - http://www.evolt.org/article/document_body_doctype_switching_and_more/17/30655/
 *
 * Modified 4/22/04 to work with Opera/Moz (by webmaster at subimage dot com)
 *
 * Gets the full width/height because it's different for most browsers.
 */
function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 
	return window.undefined; 
}
function getViewportWidth() {
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
	return window.undefined; 
}

// ============= simple ajax class ============== //
// use:
/*

httpObj = new http_class();
httpObj.setAsync(true); // defaults to true, no need to set this unless you want synchronous communication
httpObj.setURL("http://www.domain.com");
httpObj.httpMessage({"param1":1, "param2":2});

if you want the page to reload instead
httpObj.setAsync(false); // forces a page reload and does not do AJAX
httpObj.setURL("http://www.domain.com");
httpObj.httpMessage({"param1":1, "param2":2});


*/

var HTTP_SIMULATE = false;
var HTTP_SIMULATE_RESPONSE = "<status>3</status>one\ntwo\nthree\n";

var HTTP_DEBUG = false;

function http_class()
{
	this.getXmlHttpRequestObject = function()
	{
		if (window.XMLHttpRequest) 
		{
			return new XMLHttpRequest();
		} 
		else if(window.ActiveXObject) 
		{
			return new ActiveXObject("Microsoft.XMLHTTP");
		} 
		else 
		{
			alert('Status: Cound not create XmlHttpRequest Object.  Please consider upgrading your browser.');
		}
	}	
	
	this.httpObj = this.getXmlHttpRequestObject();
	this.url;
	this.async = true;
	this.response = "";
	this.callback = null;
	this.busy = false;
	this.method = "GET";
	
	this.setURL = function(url)
	{
		this.url = url;
	}

	this.setAsync = function(async)
	{
		this.async = async;
	}

	this.setPost = function()
	{
		this.method = "POST";
	}
	
	this.setGet = function()
	{
		this.method = "GET";
	}
	
	this.httpMessage = function(params)
	{
		this.url = this.getURL(params);
		this.send();
	}
	
	this.send = function()
	{
		if (HTTP_SIMULATE)
		{
			alert("Simulating call to: " + this.url);
			this.response = HTTP_SIMULATE_RESPONSE;
			if (HTTP_DEBUG)
					alert("callback:" + this.callback);
				eval(this.callback+'()');
			return;
		}
	
		if (this.busy)
		{
			//alert("Still processing previous request. Please try again in a moment");
			return;
		}
		
		if (this.async)
		{
			if (HTTP_DEBUG)
				alert(this.url);
			this.busy = true;
			this.httpObj.open(this.method, this.url, true);		
			this.httpObj.onreadystatechange = createObjectCallback(this, this.handler);
			this.httpObj.send(null);
		}
		else
		{
			window.location.href = this.url;
		}
	}
	
	this.getURL = function(params)
	{
		str = this.url + "?";

		for (n in params)
		{
			str += n + "=" + params[n] + "&";
		}
		
		str = str.substr(0,str.length-1);
		return str;
	}	

	this.handler = function() 
	{
		if (this.httpObj.readyState == 4) 
		{
			this.response = this.httpObj.responseText;
			if (HTTP_DEBUG)
				alert("Response:" + this.response);
			this.busy = false;

			if (this.callback != null)
			{
				if (HTTP_DEBUG)
					alert("callback:" + this.callback);
				eval(this.callback+'()');
			}
			else
			{
				if (HTTP_DEBUG)
					alert("No callback defined");
			}
		}
	}	
	
	this.getResponse = function()
	{
		return this.response;
	}
	
	this.setCallback = function(cback)
	{
		this.callback = cback;
	}
}

function createObjectCallback(obj, fn)
{
	return function() { fn.apply(obj, arguments); };
} 


function hideEl(id)
{
	document.getElementById(id).style.display = "none";
	return false;
}

function showEl(id, x, y)
{
	if (x != null && y != null)
	{
		document.getElementById(id).style.top = y + "px";
		document.getElementById(id).style.left = x + "px";				
	}

	document.getElementById(id).style.display = "";
	return true;
}


/*********** options_help ************/


var current_rating = {};

function checkMouseEnter(element, evt) 
{
  if (element.contains && evt.fromElement) {
	return !element.contains(evt.fromElement);
  }
  else if (evt.relatedTarget) {
	return !this.containsDOM(element, evt.relatedTarget);
  }
}

function checkMouseLeave(element, evt) 
{
  if (element.contains && evt.toElement) {
	return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
	return !this.containsDOM(element, evt.relatedTarget);
  }
}

function containsDOM(container, containee) 
{
  var isParent = false;
  do {
	if ((isParent = container == containee))
	  break;
	  try{
			containee = containee.parentNode;
		}
		catch(err){
			containee = null;
		}
  }
  while (containee != null);
  return isParent;
}



function checkEnter(id, obj, evt)
{
	if (checkMouseEnter(obj, evt)) 
	{
			showPermanent[id] = undefined;
	}
}	

function checkLeave(id, obj, evt)
{
	if (checkMouseLeave(obj, evt)) 
	{
		if (showPermanent[id] == undefined)
		{
			showStars(id + "_" + (current_rating[id] - 1));
		}
	}
}	


var showPermanent = {};	
function showStars(id)
{
	arr = id.split("_");
	num = arr[1];
	id = arr[0];
	stars = parseInt(num) + 1;

	if (showPermanent[id] != undefined)
		return;

	for (var i=0;i <= num; i++)
	{
		//alert("showstars: "+id+"_"+i);
		document.getElementById(id+"_"+i).setAttribute('src', "/images/stars/star.gif");
	}
	
	//update text
	document.getElementById(id + "_container_text").innerHTML = getRatingText(stars);
}

function hideStars(id)
{
	if (showPermanent[id] != undefined)
	{
		return;
	}

	for (var i=0;i < 4; i++)
	{
		//alert("hidestars: "+id+"_"+i);
		document.getElementById(id+"_"+i).setAttribute('src', "/images/stars/no_star.gif");
	}
}

function showPermanentStars(id, num)
{
	showPermanent[id] = undefined;
	hideStars(id);
	showStars(id+"_"+num);
	showPermanent[id] = 1;
}

function setStars(id)
{
	orig = id;
	arr = id.split("_");
	stars = arr[1];
	id = arr[0];
	temp = stars - 1;
	showPermanentStars(id, temp);
	current_rating[id] = stars;
	
	//alert(current_rating[id]);

	//update text
	document.getElementById(id + "_container_text").innerHTML = getRatingText(stars);;
}

function getRatingText(r)
{
	if(r == 4)
		return 'Best EVER!!';
	if(r == 3)
		return 'Awesome';
	if(r == 2)
		return 'Cool';

	return 'Okay';
}



/// used for actual save call ///

//this library allows for easy integration of ajax into web apps.
//to use simply call the DoAjax method with the required params from any webpage
//that uses this js.
//below is a sample of how you can call it
/*

//this funciton would go in the html page which is going to be using the ajax
function Login() {
	
	var params = {};
	params['username'] = document.getElementById('username').value;
	params['password'] = document.getElementById('password').value;
		
	//url, params, result id, error class, success class, is post
	DoAjax('login.aspx?', params, 'loginResult', 'bad', 'good', true);
}

basically what is happening is there should be a div or span tag on your html
page with the id of "loginResult" 
your css used by that page should contain a definition for the classes: bad and good

this call is going to send the values entered in two text boxes: username and password
to a program named login.aspx using a post method. the result will have the proper class applied
so it is formatted appropriately and it will be put in the innerHTML of the tag with the id of loginResult


*/

var xmlHttp;
/*
var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0;
var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0;
var is_opera = ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0;
//netscape, safari, mozilla behave the same???
var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0;
*/

//vars set in DoAjax call
var result_id; //id so put output in
var error_style; //class of error msg if error occurs
var success_style; //class of success message if good
var request_url; //url built from program and params
var params; //key value hash containing params to send to url
var is_post; //true or false representing if call is post or get
var param_string; //string of parsed key-value pairs used for post request
var gl_eflag; //true if error <status=0>
var gl_ajaxresult; //holds error message or result message from ajax call


/* quick ajax code - uses http_class.js */
var httpObj= new http_class();
function DoQuickAjax(url, params, processResult)
{
	httpObj.setURL(url);
	httpObj.setCallback(processResult);
	httpObj.setAsync(true);
	httpObj.httpMessage(params);
}

function isError(str)
{
	if (str.indexOf('<status>0</status>') >= 0)
		return true;
}

function doParse(str)
{
	if (str.indexOf('<status>1</status>') >= 0)
		return true;
}

//takes in url which can be relative or absolute
//params should be an associative array with key value pairs
//these pairs will be parsed to key=value and appended to url
//with (?) and (&) as needed
//result_id is the id of the div or tag that will have its innerHTML set
//es is the error_style to be applied as class for outputted error message. can be blank
//if no style is desired
//ss is the same as es but for successful output
//ip = is_post shuold be true (post) or false (get)
//used to determine how backing program is called with params
//with the result of the ajax call.
function DoAjax(u, p, ri, es, ss, ip){
	request_url = u;
	result_id = ri;
	params = p;
	error_style = es;
	success_style = ss;
	is_post = ip;

    if (request_url.length > 0 && HashSize(params) > 0 && result_id.length > 0){    
        //Append the params to the request_url to build the full url
        //to send/call
        
        param_string = '';
        for(var k in params){
			param_string += k + '=' + params[k] + '&';		   
        }
        
        //remove trailing &
        var re = new RegExp("\\&$");
        param_string = param_string.replace(re, "");
        
        //remove ? from url if present
        re = new RegExp("\\?$");
        request_url = request_url.replace(re, "");
        
        var url;
        if (! is_post) {
			//get request
			url = request_url + "?" + param_string;
        }
        else{
			url = request_url;
		}
        
        //Create the xmlHttp object to use in the request
        //stateChangeHandler will fire when the state has changed, i.e. data is received back
        // This is non-blocking (asynchronous)
        xmlHttp = GetXmlHttpObject(stateChangeHandler);
        
        //Send the xmlHttp get to the specified url
        xmlHttp_Get(xmlHttp, url);
        
        //alert('URL='+request_url+' RID='+result_id+' P='+HashSize(params)+' URLSENT='+url);
    }
    else {
        //output error
        SetOutput('AJAX call is BAD - data missing! URL='+request_url+' RID='+result_id+' P='+HashSize(params), true, false);
    }
}

//stateChangeHandler will fire when the state has changed, i.e. data is received back
// This is non-blocking (asynchronous)
function stateChangeHandler()
{
		//alert(xmlHttp.readyState);
    //readyState of 4 or 'complete' represents that data has been returned
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete'){
        //Gather the results from the callback
        var str = xmlHttp.responseText;
        //alert('returned' + str);
		//check if str contains a status element.
		//it will (or should) be the first tag returned and be like:
		//<status>0</status> - means error 1 value would be good
		//if none is returned assume good
		//remove status tag so it isn't outputted
		
		var eflag = false;
		var pflag = false;
		if (str.indexOf('<status>0</status>') >= 0) {
			eflag = true;
			str = str.replace("<status>0</status>", "");
		}
		
		if (str.indexOf('<status>1</status>') >= 0) {
			str = str.replace("<status>1</status>", "");
		}
		
		if (str.indexOf('<status>3</status>') >= 0) {
			pflag = true;
			str = str.replace("<status>3</status>", "");
		}

		//set globals used byu some controls
		gl_eflag = eflag;
		gl_ajaxresult = str;		

        //Populate the innerHTML of the div with the results
        SetOutput(str, eflag, pflag);
    }
}

// XMLHttp send GET/POST request
function xmlHttp_Get(xmlhttp, url) {
	if (! is_post) {
		xmlhttp.open('GET', url, true);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlhttp.send(null);
	}
	else {
		xmlhttp.open('POST', url, false);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlhttp.send(param_string);
	}
}

function GetXmlHttpObject(handler) {
    var objXmlHttp = null;    //Holds the local xmlHTTP object instance

    //Depending on the browser, try to create the xmlHttp object
    /*
    if (is_ie){
        //The object to create depends on version of IE
        //If it isn't ie5, then default to the Msxml2.XMLHTTP object
        var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP';
        
        //Attempt to create the object
        try{
            objXmlHttp = new ActiveXObject(strObjName);
            objXmlHttp.onreadystatechange = handler;
        }
        catch(e){
        //Object creation errored
			SetOutput('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled', true, false);            
            return;
        }
    }
    else if (is_opera){
        //Opera has some issues with xmlHttp object functionality
        SetOutput('Opera detected. The page may not behave as expected.', true, false);
        return;
    }
    else{
        // Mozilla | Netscape | Safari
        objXmlHttp = new XMLHttpRequest();
        objXmlHttp.onload = handler;
        objXmlHttp.onerror = handler;
    }
    */
    
    if(window.XMLHttpRequest){
    	try{
    		objXmlHttp = new XMLHttpRequest();
        objXmlHttp.onload = handler;
        objXmlHttp.onerror = handler;
        objXmlHttp.onreadystatechange = handler;
      }
      catch(e){
      	//alert('object creation failed 1');
      }    		
    }
    else if(window.ActiveXObject){
    	try {
    		objXmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
        objXmlHttp.onreadystatechange = handler;
      }
      catch(e){
      	try {
	    		objXmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
	        objXmlHttp.onreadystatechange = handler;
	      }
	      catch(e){
	      	//alert('object creation failed 2');
	      }  
      }  
    }
    else{
    	//alert('object creation failed 3');
    }
    
    //Return the instantiated object
    return objXmlHttp;
}

//will either populate the innerHTML of the result_id tag or 
//do an alert popup if that id is null
function SetOutput(em,error,pflag){
	
		//needs to be parsed so assume handled elsewhere
		if(pflag){
			 document.getElementById(result_id).innerHTML = '';
			 return; }
	
    if(document.getElementById(result_id) != null){
		if (error) {
			document.getElementById(result_id).innerHTML = '<div class="'+error_style+'">' + em + '</div>';
		}
		else{
			document.getElementById(result_id).innerHTML = '<div class="'+success_style+'">' + em + '</div>';
		}
	}
	else{
		alert(em);
	}	
}

//takes in a hash or associative array and returns # of eles in it
function HashSize(p){

  var i = 0;
  for (var j in p) {
    //if (p.propertyIsEnumerable(j)) {
      i++;
    //}
  }
  return i;
}


//takes in id. checks if style is block or "" and sets it to opposite
function toggleDiv(dn){

	var display_value = document.getElementById(dn).style.display;
	
	if(display_value == "" || display_value == "block"){
		document.getElementById(dn).style.display = "none";	
	}
	else{
		document.getElementById(dn).style.display = "";	
	}
}


//send link of item to email desired
function SendToFriend() {
	
	var params = {};
	
	params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
	params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';
	params['email'] = (document.getElementById('email') != null) ? document.getElementById('email').value : '';
	params['friend_note'] = (document.getElementById('friend_note') != null) ? document.getElementById('friend_note').value : '';
	params['friend_note'] = XssPrevention(params['friend_note']);
	params['target'] = 'send';
	params['action'] = 'send';
		
	//url, params, result id, error class, success class, is post
	DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
	
	if(! gl_eflag){	
		//hide form
		hideEl('optionsform');
		showEl('closepane');
	}
		
}


function SaveItem() {
	
	var params = {};
	
	params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
	params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';
	
	params['target'] = 'favorites';
	params['action'] = 'add_favorite';
	
	//get save values such as tags etc
	params['description'] = (document.getElementById('description') != null) ? document.getElementById('description').value : '';
	//params['rating'] = (document.getElementById('rating') != null) ? getSelectedValue(document.getElementById('rating')) : '';
	params['rating'] = (current_rating[0] > 0) ? current_rating[0] : 1;
	
	//XSS prevention for short description
	params['description'] = XssPrevention(params['description']);
	
	if(params["description"].length > 300){
		alert('Notes can not exceed 300 chars. Your notes are currently ' + params["description"].length + '.');
		return false;			
	}
	
	//remove spaces from tags
	document.getElementById('tag1').value = document.getElementById('tag1').value.replace(/ /g,'');
	document.getElementById('tag2').value = document.getElementById('tag2').value.replace(/ /g,'');
	document.getElementById('tag3').value = document.getElementById('tag3').value.replace(/ /g,'');
	document.getElementById('tag4').value = document.getElementById('tag4').value.replace(/ /g,'');	
	
	//build tags from indy boxes
	//params['tags'] = (document.getElementById('tags') != null) ? document.getElementById('tags').value : '';
	var t1 = (document.getElementById('tag1') != null) ? document.getElementById('tag1').value : '';
	var t2 = (document.getElementById('tag2') != null) ? document.getElementById('tag2').value : '';
	var t3 = (document.getElementById('tag3') != null) ? document.getElementById('tag3').value : '';
	var t4 = (document.getElementById('tag4') != null) ? document.getElementById('tag4').value : '';
	var all_tags = '';
	if(t1.length > 0)
		all_tags = (all_tags.length > 0) ? (all_tags + ',' + t1) : t1;	
	if(t2.length > 0)
		all_tags = (all_tags.length > 0) ? (all_tags + ',' + t2) : t2;
	if(t3.length > 0)
		all_tags = (all_tags.length > 0) ? (all_tags + ',' + t3) : t3;
	if(t4.length > 0)
		all_tags = (all_tags.length > 0) ? (all_tags + ',' + t4) : t4;
	
	params['tags'] = (all_tags.length == 0) ? params['t'].replace(/\_/g,'') : all_tags;
	
	//do tag checking. prevent them from entering dup tags
	//already defined for item.
	var tmp_tags = {};
	tmp_tags[document.getElementById('tag1').value.toLowerCase()] = (tmp_tags[document.getElementById('tag1').value.toLowerCase()] != null) ? parseInt(tmp_tags[document.getElementById('tag1').value.toLowerCase()])+1 : 1;
	tmp_tags[document.getElementById('tag2').value.toLowerCase()] = (tmp_tags[document.getElementById('tag2').value.toLowerCase()] != null) ? parseInt(tmp_tags[document.getElementById('tag2').value.toLowerCase()])+1 : 1;
	tmp_tags[document.getElementById('tag3').value.toLowerCase()] = (tmp_tags[document.getElementById('tag3').value.toLowerCase()] != null) ? parseInt(tmp_tags[document.getElementById('tag3').value.toLowerCase()])+1 : 1;
	tmp_tags[document.getElementById('tag4').value.toLowerCase()] = (tmp_tags[document.getElementById('tag4').value.toLowerCase()] != null) ? parseInt(tmp_tags[document.getElementById('tag4').value.toLowerCase()])+1 : 1;
	
	
	var valid_tag_counter = 0;
	for( var i in tmp_tags){
		if(i.length > 0 && tmp_tags[i.toLowerCase()] > 1){			
			alert('You are attempting to enter a duplicate tag: ' + i + '.');
			return false;
		}
		else if(i.length > 0 && ! i.match(/^[0-9a-zA-Z]+$/ig)){
			//check tag for invalid chars
			alert('Invalid Tag: ' + i + '. Tags can only contain letters and numbers with no spaces or other characters.');
			return false;
		}	
		//alert (i + " : " + tmp_tags[i]);
		if(i.length > 0){
			valid_tag_counter++;
		}
	}	
	
	//url, params, result id, error class, success class, is post
	DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
	
	if(! gl_eflag){	
		hideEl('optionsform');
		showEl('closepane');
	}
}


//code to deal with star settings during saving.

function UnsaveItem() {
	
	if(confirm('Are you sure you want to remove this item from your favorites?\n\nYou will not be able to undo this action.')){
		
		var params = {};
		
		params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
		params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';
		
		params['target'] = 'favorites';
		params['action'] = 'remove_favorite';
			
		//url, params, result id, error class, success class, is post
		DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
			
		if(! gl_eflag){
			hideEl('optionsform');
			showEl('closepane');
		}
	}
}



//saves current window.location to an id for later use
function setReloadUrl(){
	if(document.getElementById('reload_url') != null){
		document.getElementById('reload_url').value = window.location.href.replace("#","");
	}
}

function UpdateItem(upd) {
	
	//upd = 0 || 1 - 1 means update 0 means delete
	
	if(upd == '1'){
		var params = {};
		
		params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
		params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';
		
		params['target'] = 'modify';
		params['action'] = 'modify_favorite';
		
		params['update'] = '1';
				
		//get save values such as tags etc
		params['description'] = (document.getElementById('description') != null) ? document.getElementById('description').value : '';
		//params['rating'] = (document.getElementById('rating') != null) ? getSelectedValue(document.getElementById('rating')) : '';
		params['rating'] = (current_rating[0] > 0) ? current_rating[0] : 1;
		
		//XSS prevention for short description
		params['description'] = XssPrevention(params['description']);
		
		if(params["description"].length > 300){
			alert('Notes can not exceed 300 chars. Your notes are currently ' + params["description"].length + '.');
			return false;			
		}
		
		//remove spaces from tags
		document.getElementById('tag1').value = document.getElementById('tag1').value.replace(/ /g,'');
		document.getElementById('tag2').value = document.getElementById('tag2').value.replace(/ /g,'');
		document.getElementById('tag3').value = document.getElementById('tag3').value.replace(/ /g,'');
		document.getElementById('tag4').value = document.getElementById('tag4').value.replace(/ /g,'');	
		
		//build tags from indy boxes
		//params['tags'] = (document.getElementById('tags') != null) ? document.getElementById('tags').value : '';
		var t1 = (document.getElementById('tag1') != null) ? document.getElementById('tag1').value : '';
		var t2 = (document.getElementById('tag2') != null) ? document.getElementById('tag2').value : '';
		var t3 = (document.getElementById('tag3') != null) ? document.getElementById('tag3').value : '';
		var t4 = (document.getElementById('tag4') != null) ? document.getElementById('tag4').value : '';
		var all_tags = '';
		if(t1.length > 0)
			all_tags = (all_tags.length > 0) ? (all_tags + ',' + t1) : t1;	
		if(t2.length > 0)
			all_tags = (all_tags.length > 0) ? (all_tags + ',' + t2) : t2;
		if(t3.length > 0)
			all_tags = (all_tags.length > 0) ? (all_tags + ',' + t3) : t3;
		if(t4.length > 0)
			all_tags = (all_tags.length > 0) ? (all_tags + ',' + t4) : t4;
		
		params['tags'] = (all_tags.length == 0) ? params['t'].replace(/\_/g,'') : all_tags;
		
		//do tag checking. prevent them from entering dup tags
		//already defined for item.
		var tmp_tags = {};
		tmp_tags[document.getElementById('tag1').value.toLowerCase()] = (tmp_tags[document.getElementById('tag1').value.toLowerCase()] != null) ? parseInt(tmp_tags[document.getElementById('tag1').value.toLowerCase()])+1 : 1;
		tmp_tags[document.getElementById('tag2').value.toLowerCase()] = (tmp_tags[document.getElementById('tag2').value.toLowerCase()] != null) ? parseInt(tmp_tags[document.getElementById('tag2').value.toLowerCase()])+1 : 1;
		tmp_tags[document.getElementById('tag3').value.toLowerCase()] = (tmp_tags[document.getElementById('tag3').value.toLowerCase()] != null) ? parseInt(tmp_tags[document.getElementById('tag3').value.toLowerCase()])+1 : 1;
		tmp_tags[document.getElementById('tag4').value.toLowerCase()] = (tmp_tags[document.getElementById('tag4').value.toLowerCase()] != null) ? parseInt(tmp_tags[document.getElementById('tag4').value.toLowerCase()])+1 : 1;
		
		
		var valid_tag_counter = 0;
		for( var i in tmp_tags){
			if(i.length > 0 && tmp_tags[i.toLowerCase()] > 1){			
				alert('You are attempting to enter a duplicate tag: ' + i + '.');
				return false;
			}
			else if(i.length > 0 && ! i.match(/^[0-9a-zA-Z]+$/ig)){
				//check tag for invalid chars
				alert('Invalid Tag: ' + i + '. Tags can only contain letters and numbers with no spaces or other characters.');
				return false;
			}	
			//alert (i + " : " + tmp_tags[i]);
			if(i.length > 0){
				valid_tag_counter++;
			}
		}	
			
		//url, params, result id, error class, success class, is post
		DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
			
		if(! gl_eflag){
			//alert and close popup and reload parent.
			alert('Item has been updated');
			//window.parent.location = window.parent.location.href.replace("#","");			
			//alert(window.parent.document.getElementById('reload_url').value);
			window.location = window.document.getElementById('reload_url').value;
			//window.parent.hidePopWin(false);			
		}
	}
	else{	
		if(confirm('Are you sure you want to remove this item from your favorites?\n\nYou will not be able to undo this action.')){
			
			var params = {};
			
			params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
			params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';
			
			params['target'] = 'modify';
			params['action'] = 'modify_favorite';
			
			params['remove'] = '1';
				
			//url, params, result id, error class, success class, is post
			DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
				
			if(! gl_eflag){
				//alert and close popup and reload parent.
				alert('Item has been removed from your favorites');
				//window.parent.location = window.parent.location.href.replace("#","");				
				window.location = window.document.getElementById('reload_url').value;
				//window.parent.hidePopWin(false);
			}
		}
	}
}

function XssPrevention(str){
	if(str == undefined){
		return '';
	}
	str = str.replace(/>/g, "&gt;");
	str = str.replace(/</g, "&lt;");
	str = escape(str);
	return str;
}

// ------------------------------------ favorite gui code ---------------------------//

function clearFilters(){
	
	document.getElementById('tag').value = '';
	document.getElementById('page').value = '1';
	document.getElementById('foreign_table').selectedIndex = 0;
	document.getElementById('rating').selectedIndex = 0;
	
	document.getElementById('favoritesform').submit();
}

function setTagValue(str)
{
	if(str != "any tag" && document.getElementById('tag').value != "any tag" && document.getElementById('tag').value.length > 0){
		//not special tag && need append tag to existing
		//remove dups
		document.getElementById('tag').value = document.getElementById('tag').value.replace(str + ",","");			
		document.getElementById('tag').value = document.getElementById('tag').value.replace("," + str,"");			
		document.getElementById('tag').value = document.getElementById('tag').value.replace(str,"");			
		document.getElementById('tag').value = document.getElementById('tag').value + ',' + str;			
		document.getElementById('tag').value = document.getElementById('tag').value.replace(/^,|,$/,"");
	}
	else{
		//special or none present already so only use it
		document.getElementById('tag').value = str;
	}
	
	document.getElementById('page').value = '1';
	document.getElementById('favoritesform').submit();
}
	
function removeTagValue(str)
{
	if(document.getElementById('tag').value != str){
		//must be more so find replace
		document.getElementById('tag').value = document.getElementById('tag').value.replace(str + ",","");			
		document.getElementById('tag').value = document.getElementById('tag').value.replace("," + str,"");			
	}
	else{
		//just blank it
		document.getElementById('tag').value = '';
	}
	document.getElementById('page').value = '1';
	document.getElementById('favoritesform').submit();
}

function setFTValue(ft)
{
	document.getElementById('foreign_table').value = ft;
	
	document.getElementById('page').value = '1';
	document.getElementById('favoritesform').submit();
}

function removeFTValue(ft)
{
	document.getElementById('foreign_table').value = '';
	
	document.getElementById('page').value = '1';
	document.getElementById('favoritesform').submit();
}


//add or delete friends
function AddFriend() {
	
	var params = {};
	
	params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
	params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';
	params['email'] = (document.getElementById('email') != null) ? document.getElementById('email').value : '';
	params['target'] = 'add_friend';
	params['action'] = 'add_friend';
		
	//url, params, result id, error class, success class, is post
	DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
	
	if(! gl_eflag){	
		//hide form
		hideEl('optionsform');
	}
}

function DeleteFriend() {
	
	var params = {};
	
	params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
	params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';
	params['target'] = 'add_friend';
	params['action'] = 'delete_friend';
		
	//url, params, result id, error class, success class, is post
	DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
	
	if(! gl_eflag){	
		//hide form
		hideEl('optionsform');
	}
	
}
			
//actions from profile page
function SendMessage() {
	
	var params = {};
	
	params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
	params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';	
	params['subject'] = (document.getElementById('subject') != null) ? document.getElementById('subject').value : '';
	params['msgbody'] = (document.getElementById('msgbody') != null) ? document.getElementById('msgbody').value : '';
	params['target'] = 'send_message';
	params['action'] = 'send_message';
		
	//url, params, result id, error class, success class, is post
	DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
	
	if(! gl_eflag){	
		//hide form
		hideEl('optionsform');
	}
	
}

function PostComment() {
	
	var params = {};
	
	params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
	params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';
	params['comment'] = (document.getElementById('comment') != null) ? document.getElementById('comment').value : '';
	params['target'] = 'post_comment';
	params['action'] = 'post_comment';
		
	//url, params, result id, error class, success class, is post
	DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
	
	if(! gl_eflag){	
		//hide form
		hideEl('optionsform');
		//window.parent.location = window.parent.location;
		//window.parent.hidePopWin(false);
	}
	
}

function DeleteComment(cid) {
	
	if(cid.length > 0 && confirm('Are you sure you want to delete this comment?')){
		var params = {};
		
		params['t'] = 'users';
		params['id'] = cid;
		params['target'] = 'post_comment';
		params['action'] = 'delete_comment';
			
		//url, params, result id, error class, success class, is post
		DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
		
		if(! gl_eflag){	
			hideEl('commentrow_' + params['id']);
			//window.location = window.location;
		}
	}
	
}			

function ReplyToMessage() {
	
	var params = {};
	
	params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
	params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';	
	params['msgbody'] = (document.getElementById('msgbody') != null) ? document.getElementById('msgbody').value : '';
	params['target'] = 'reply_message';
	params['action'] = 'reply_message';
		
	//url, params, result id, error class, success class, is post
	DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
	
	if(! gl_eflag){	
		//hide form
		hideEl('optionsform');
	}
	
}

function DeleteMessage(cid) {
	
	if(cid.length > 0 && confirm('Are you sure you want to delete this message?')){
		var params = {};
		
		params['t'] = 'users';
		params['id'] = cid;
		params['target'] = 'delete_message';
		params['action'] = 'delete_message';
			
		//url, params, result id, error class, success class, is post
		DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
		
		if(! gl_eflag){	
			hideEl('messagerow_' + params['id']);
			//window.location = window.location;
		}
	}
	
}			

function AcceptFriend(fid) {
	
	var params = {};
	
	params['t'] = 'users';
	params['id'] = fid;
	params['target'] = 'accept_friend';
	params['action'] = 'accept_friend';
		
	//url, params, result id, error class, success class, is post
	DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
	
	if(! gl_eflag){	
		hideEl('friendrow_' + params['id']);
	}
	
}

function RejectFriend(fid) {
	
	if(fid.length > 0 && confirm('Are you sure you want to reject this person?')){
		var params = {};
		
		params['t'] = 'users';
		params['id'] = fid;
		params['target'] = 'delete_friend';
		params['action'] = 'delete_friend';
			
		//url, params, result id, error class, success class, is post
		DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
		
		if(! gl_eflag){	
			hideEl('friendrow_' + params['id']);
		}
	}
	
}

function likedItem(tname,item_id, link_id){
	var params = {};
		
		params['t'] = tname;
		params['id'] = item_id;
		params['target'] = 'liked_item';
		params['action'] = 'liked_item';
			
		//url, params, result id, error class, success class, is post
		if(link_id != undefined){
			DoAjax('/user/options.aspx?', params, link_id, '', '', true);
		}
		else{
			DoAjax('/user/options.aspx?', params, 'liked_item_link', '', '', true);
		}
		
		if(link_id != undefined && document.getElementById(link_id) != null){
			//used when more then one place on page to like something
			document.getElementById(link_id).innerHTML = 'Thank you for telling us.';
		}
		
		if(document.getElementById('liked_item_link') != null){
			document.getElementById('liked_item_link').innerHTML = 'Thank you for telling us.';
		}
}

function Checkin() {
	
	var params = {};
	
	params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
	params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';
	params['comment'] = (document.getElementById('comment') != null) ? document.getElementById('comment').value : '';
	params['target'] = 'checkin';
	params['action'] = 'checkin';
		
	//url, params, result id, error class, success class, is post
	DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
	
	if(! gl_eflag){	
		//hide form
		hideEl('optionsform');
		//window.parent.location = window.parent.location;
		//window.parent.hidePopWin(false);
		//Modalbox.hide();
	}
}

function PostCheckinComment(){
	var params = {};
	
	params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
	params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';
	params['pid'] = (document.getElementById('pid') != null) ? document.getElementById('pid').value : '';
	params['comment'] = (document.getElementById('comment') != null) ? document.getElementById('comment').value : '';
	params['target'] = 'checkin_comment';
	params['action'] = 'checkin_comment';
		
	//url, params, result id, error class, success class, is post
	DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
	
	if(! gl_eflag){	
		//hide form
		hideEl('optionsform');
		//window.parent.location = window.parent.location;
		//window.parent.hidePopWin(false);
		//Modalbox.hide();
	}
}

function deleteCheckin(id){
	new Ajax.Request("/user/options.aspx", { 'parameters': { 'action': 'checkin_delete', 't': 'users_checkins', 'id': id, 'target': 'checkin_delete' }, 'onComplete': ProcessAjaxDeleteCheckin });	
	$('checkin' + id).hide();
}

function ProcessAjaxDeleteCheckin(http, json)
{
	// the js from this response contains variables
	var str = http.responseText;
	//alert(str);
}


//old single vote method
function voteBestOf(tname,item_id,ev){
	var params = {};
		
		params['t'] = tname;
		params['id'] = item_id;
		params['ev'] = ev;
		params['target'] = 'vote_best_of';
		params['action'] = 'vote_best_of';
			
		//url, params, result id, error class, success class, is post
		DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
		
		document.getElementById('vote_best_of_link').innerHTML = 'Thanks for voting';
}

function voteBestOfAll(){
	var params = {};
		
		params['t'] = document.getElementById('t').value;
		params['id'] = document.getElementById('id').value;
		params['ev'] = '0';
		params['action'] = 'vote_best_of';
		
		if(params['t'] == "listings"){				
			params['target'] = 'votelistings';
			
			params['new_bar'] = (document.getElementById('new_bar').checked) ? '1' : '0';
			params['sports_bar'] = (document.getElementById('sports_bar').checked) ? '1' : '0';
			params['wings'] = (document.getElementById('wings').checked) ? '1' : '0';
			params['karaoke'] = (document.getElementById('karaoke').checked) ? '1' : '0';
			params['irish'] = (document.getElementById('irish').checked) ? '1' : '0';
			params['hh'] = (document.getElementById('hh').checked) ? '1' : '0';
			params['college'] = (document.getElementById('college').checked) ? '1' : '0';
			params['neighborhood'] = (document.getElementById('neighborhood').checked) ? '1' : '0';
			params['dance'] = (document.getElementById('dance').checked) ? '1' : '0';
			params['music'] = (document.getElementById('music').checked) ? '1' : '0';
			params['outdoor'] = (document.getElementById('outdoor').checked) ? '1' : '0';
			params['burb'] = (document.getElementById('burb').checked) ? '1' : '0';
			params['beer'] = (document.getElementById('beer').checked) ? '1' : '0';
			params['martinis'] = (document.getElementById('martinis').checked) ? '1' : '0';
			params['restaurant'] = (document.getElementById('restaurant').checked) ? '1' : '0';
			params['food'] = (document.getElementById('food').checked) ? '1' : '0';
			params['improved'] = (document.getElementById('improved').checked) ? '1' : '0';
			params['dive'] = (document.getElementById('dive').checked) ? '1' : '0';
		}
		else if(params['t'] == "bands_djs"){				
			params['target'] = 'votebands_djs';
			
			params['wedding'] = (document.getElementById('wedding').checked) ? '1' : '0';
			params['vip'] = (document.getElementById('vip').checked) ? '1' : '0';
			params['party'] = (document.getElementById('party').checked) ? '1' : '0';
			params['bar'] = (document.getElementById('bar').checked) ? '1' : '0';
			params['dj'] = (document.getElementById('dj').checked) ? '1' : '0';
			params['rap'] = (document.getElementById('rap').checked) ? '1' : '0';
			params['rock'] = (document.getElementById('rock').checked) ? '1' : '0';
			params['punk'] = (document.getElementById('punk').checked) ? '1' : '0';
			params['country'] = (document.getElementById('country').checked) ? '1' : '0';
			params['jazz'] = (document.getElementById('jazz').checked) ? '1' : '0';
			params['blues'] = (document.getElementById('blues').checked) ? '1' : '0';
		}
			
		//url, params, result id, error class, success class, is post
		DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
		
		if(! gl_eflag){	
			window.document.getElementById('vote_best_of_link').innerHTML = 'Thanks for voting';
			//hide form
			hideEl('optionsform');
			showEl('closepane');
		}
}

/* used for event management */
function DeleteEvent() {
	
	if(confirm('Are you sure you want to delete this event from the calendar? If any other users saved this event to their calendar it will be removed from theirs as well.')){
		
		var params = {};
		
		params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
		params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';	
		params['target'] = 'delete_event';
		params['action'] = 'delete_event';
			
		//url, params, result id, error class, success class, is post
		DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
		
		if(! gl_eflag){	
			hideEl('read_only_event');
		}	
	}
}

function SaveEvent() {
	
	if(confirm('Are you sure you want to add this event to your calendar? If the creator of this event cancels it later on it will automatically be removed from your calendar.')){
		var params = {};
		
		params['t'] = (document.getElementById('t') != null) ? document.getElementById('t').value : '';
		params['id'] = (document.getElementById('id') != null) ? document.getElementById('id').value : '';	
		params['target'] = 'save_event';
		params['action'] = 'save_event';
			
		//url, params, result id, error class, success class, is post
		DoAjax('/user/options.aspx?', params, 'optionsResult', '', '', true);
		
		if(! gl_eflag){	
			hideEl('read_only_event');
		}	
	}
}

/* map searching functions */


function DrawListingMarkers(lat, lng, rad) {
	
	var params = {};
		
	params['mapsearch'] = '1';
	params['latitude'] = lat;	
	params['longitude'] = lng;	
	params['zipcode_radius'] = rad;
	params['sc'] = document.getElementById('rr-sc').value;
		
	//url, params, result id, error class, success class, is post
	DoQuickAjax('/listings/search.aspx', params, 'parseDrawListingMarkers');
	
}

function parseDrawListingMarkers()
{
	var str = httpObj.getResponse();	
	//alert(str);
	if (!isError(str)) 
	{
		if (doParse(str))
		{
			str = str.replace("<status>1</status>", "");
			var lines = str.split("\n");
			
			//remove old overlays
			coords = {};		
			listings_shown = true;
			
			var pd_i = 1;
			for(var i = 0; i < lines.length; i++)
			{
				if(lines[i].length > 0)
				{
					//alert(lines[i]);
					var tmp = lines[i].split("||");
					
					//format:
					//id||ln||name||address||city||state|zipcode||phone_number||rating||listing_level||latitude||longitude||image_content_type\n
					//1 2 3 4 5 6 7 8 9 10 11 12 13
					
					//only maps those with coords
					if (tmp.length > 1 && tmp[10].length > 0 && tmp[11].length > 0)
					//if (tmp.length > 1)
					{
						coords[pd_i] = {};
						coords[pd_i]['lat'] = tmp[10];
						coords[pd_i]['lon'] = tmp[11];
						if(tmp[12].length > 0){
							coords[pd_i]['html'] = '<img src="/displayimage/web/id/'+tmp[0]+'/table/listings/manip/frame/frame/40/no_stat/1/index.aspx" border="0" alt="bar" onmouseover="showtrail(\'/displayimage/web/id/'+tmp[0]+'/table/listings/manip/frame/frame/400/no_stat/1/index.aspx\',\'\',\'\',\'\',\'\',\'1\',400,400);" onmouseout="hidetrail();" />&#160;<a class="searchres" href="http://www.barfinder.com/listings/'+tmp[1]+'-'+tmp[0]+'-details.aspx">'+tmp[2].replace("'","\'")+'</a><br/><span class="searchrescontent"><b>'+tmp[7]+'</b><br/>'+tmp[3].replace("'","\'")+'<br/>'+tmp[4].replace("'","\'")+',&#160;'+tmp[5]+'&#160;'+tmp[6]+'</span>';
						}
						else{
							coords[pd_i]['html'] = '<a class="searchres" href="http://www.barfinder.com/listings/'+tmp[1]+'-'+tmp[0]+'-details.aspx">'+tmp[2].replace("'","\'")+'</a><br/><span class="searchrescontent"><b>'+tmp[7]+'</b><br/>'+tmp[3].replace("'","\'")+'<br/>'+tmp[4].replace("'","\'")+',&#160;'+tmp[5]+'&#160;'+tmp[6]+'</span>';
						}
						coords[pd_i]['title'] = tmp[2].replace("'","\'");
						coords[pd_i]['address'] = tmp[3].replace("'","\'") + ', ' + tmp[4].replace("'","\'") + ', ' + tmp[5].replace("'","\'") + ' ' + tmp[7].replace("'","\'");
						
						pd_i++;
							
					}
				}
			}
			
			// Create a base icon for all of our markers that specifies the
	    // shadow, icon dimensions, etc.
	   	var baseIcon = new GIcon();
	    baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
	    baseIcon.iconSize = new GSize(20, 34);
	    baseIcon.shadowSize = new GSize(37, 34);
	    baseIcon.iconAnchor = new GPoint(9, 34);
	    baseIcon.infoWindowAnchor = new GPoint(9, 2);
	    baseIcon.infoShadowAnchor = new GPoint(18, 25);
	    
			
			// Creates a marker whose info window displays the letter corresponding
			// to the given index.
			function createSearchMarker(point, index, html, marker_title) {
			  // Create a lettered icon for this point using our icon class
			  //var letter = String.fromCharCode("A".charCodeAt(0) + index);
			  var letteredIcon = new GIcon(baseIcon);
			  letteredIcon.image = "http://www.google.com/mapfiles/marker.png";
			
			  // Set up our GMarkerOptions object
			// markerOptions = { icon:letteredIcon };
			  //var marker = new GMarker(point, markerOptions);
			  var marker = new GMarker(point, { title: marker_title, clickable: true, icon:letteredIcon });
			
				
			  GEvent.addListener(marker, "click", function() {
			    marker.openInfoWindowHtml(html);
			  });
			  
			  
			  return marker;
			}
			
			
			//add markers
			var z = 0;
	    for (var i in coords) {
	    	if(coords[i]['lat'] != '' && coords[i]['lon'] != ''){
		    	//alert(lines[i] + '  lat= ' + coords[i]['lat'] + 'lon = ' + coords[i]['lon']);
		      var point = new GLatLng(parseFloat(coords[i]['lat']),parseFloat(coords[i]['lon']));
		      var tmp_marker = createSearchMarker(point, z, coords[i]['html'], coords[i]['title']);
		      coords[i]['marker_obj'] = tmp_marker;
		      map.addOverlay(tmp_marker);	
		    }
		    /*
		    else{
		    	//try it with geocode
		    	if (geocoder) {
		    		//setup local vars for callback
		    		var tmp_z = z;
		    		var tmp_i = i;
		    		var tmp_html = coords[i]['html'];
		    		var tmp_title = coords[i]['title'];
		    		var tmp_address = coords[i]['address'];
		        geocoder.getLatLng(
		          tmp_address,
		          function(point) {
		            if (point) {		
		            	coords[tmp_i]['marker_obj'] = createSearchMarker(point, tmp_z, tmp_html, tmp_title);
						      map.addOverlay(coords[tmp_i]['marker_obj']);	
		            }
		          }
		        );
		      }
		    }//ends else
		    */
		    
		    z++;
	    }
			
		} //ends if doParse		
	}
	else
	{
		//is error
	}
	
	//reshow map
	document.getElementById("search_map_canvas_wait").style.display = 'none';
	document.getElementById("search_map_canvas").style.display = '';
}


/************** form checkers ***********************/


function CheckManageTracksBandsForm(){
	//check if they selected any files to delete and warn them
	if(document.getElementById('delete_tracks') != null && getSelectedValue(document.getElementById('delete_tracks')).length > 0){
		if(confirm('You have selected track(s) to be deleted from your playlist. Are you sure you want to delete these tracks?')){
			return true;
		}
		else{
			return false;
		}
	}
	
	return true;
}

function CheckFileLibraryDetailsForm(){
	//checks if delete image was checked and prompts user to confirm
	//check if they selected any files to delete and warn them
	if(document.getElementById('delete_image') != null && document.getElementById('delete_image').checked){
		if(confirm('You have chosen to delete this file from the file library. This cannot be undone. Are you sure you want to delete this?\n\nIf you click OK this File will know longer be able to be viewed within the BarFinder.com community. \n\nClick cancel to leave it for others to enjoy.')){
			return true;
		}
		else{
			document.getElementById('delete_image').checked = false;
			return false;
		}
	}
	
	return true;
}

function CheckManageTracksUsersForm(){
	//check if they selected any files to delete and warn them
	if(document.getElementById('delete_tracks') != null && getSelectedValue(document.getElementById('delete_tracks')).length > 0){
		if(confirm('You have selected track(s) to be deleted from your playlist. Are you sure you want to delete these tracks?')){
			return true;
		}
		else{
			return false;
		}
	}
	
	return true;
}

function CheckBandSearchForm()
{
	if( !(document.pageform.zipcode.value.length > 0 ||
		document.pageform.keywords.value.length    > 0 ||
		  document.pageform.name.value.length    > 0 ||
		  document.pageform.spc.selectedIndex    > 0) )
	{
		alert("Please specify a search. A keyword, zipcode or location must be specified.");
		return false;
	}
	
	//check zipcode. if zipcode radius != 0 and zipcode length = 0 throw error
	//if raidus is not 0 and zipcode > 0 clear city and state and name to avoid 
	// too strict of a search
	
	if(document.pageform.zipcode_radius.value > 0 && document.pageform.zipcode.value.length == 0){
		alert("Please specify a zipcode to search around or do not use a radius search.");
		return false;
	}
	
	if(document.pageform.zipcode_radius.value > 0 && document.pageform.zipcode.value.length > 0){
		document.pageform.city.value = '';
		document.pageform.spc.selectedIndex = -1;
		//document.pageform.name.value = '';
	}
	return true;
}

//ensure comment filled in
function checkUserEventCommentForm(id){
    if($('comment'+id).value == ""){
        alert('Please enter a comment before clicking the button.');
        return false;
        }
        else{
        return true;
        }
}


function CheckBandCommentForm(button)
{
   <!--makes sure something is in the comment field-->
	if(document.pageform.comment.value.length <= 25)
	{
		alert("Please enter a comment that is at least a few words.");
		return false;
	}
	else
	{
		button.value='Processing, please wait ...';
		button.onclick = new Function('return false'); 
		return true;
	}
}

function CheckAddPostForumForm(button)
{ 
	if(! document.pageform.subject.value.length)
	{
		alert("Please Enter a Subject");
		return false;
	}
	else if(! document.pageform.body.value.length)
	{
		alert("Please Enter a Message");
		return false;
	}
	else
	{ 
		button.value='Processing, please wait ...';
		return true;
	}
}

function CheckAddThreadForumForm(button)
{ 
	if(! document.pageform.subject.value.length)
	{
		alert("Please Enter a Subject");
		return false;
	}
	else if(! document.pageform.body.value.length)
	{
		alert("Please Enter a Message");
		return false;
	}
	else
	{ 
		button.value='Processing, please wait ...';
		return true;
	}
}

function CheckEditForumForm(button)
{ 
	if(! document.pageform.subject.value.length)
	{
		alert("Please Enter a Subject");
		return false;
	}
	else if(! document.pageform.body.value.length)
	{
		alert("Please Enter a Message");
		return false;
	}
	else
	{ 
		button.value='Processing, please wait ...';
		return true;
	}
}


function CheckSearchBarsForm()
{
	if( !( document.pageform.zipcode.value.length > 0 ||
		  document.pageform.keywords.value.length    > 0 ||
		  document.pageform.name.value.length    > 0 ||
		  document.pageform.phone_number.value.length    > 0 ||
		  document.pageform.spc.selectedIndex    > 0) )
	{
		alert("Please specify a search. A keyword, phone, zipcode or location must be specified.");
		return false;
	}
	
	//if using phone ensure it is 10
	if(document.pageform.phone_number.value > 0 && document.pageform.phone_number.value.length < 10){
		alert("Please specify a valid 10 digit phone number to search for.");
		return false;
	}
	
	//check zipcode. if zipcode radius != 0 and zipcode length = 0 throw error
	//if raidus is not 0 and zipcode > 0 clear city and state and name to avoid 
	// too strict of a search
	
	if(document.pageform.zipcode_radius.value > 0 && document.pageform.zipcode.value.length == 0){
		alert("Please specify a zipcode to search around or do not use a radius search.");
		return false;
	}
	
	if(document.pageform.zipcode_radius.value > 0 && document.pageform.zipcode.value.length > 0){
		document.pageform.city.value = '';
		document.pageform.spc.selectedIndex = -1;
		//document.pageform.name.value = '';
	}
	return true;
}


function CheckBarCommentForm(button)
{
   <!--makes sure something is in the comment field-->
	if(document.pageform.comment.value.length <= 25)
	{
		alert("Please enter a comment that is at least a few words.");
		return false;
	}
	else
	{
		button.value='Processing, please wait ...';
		button.onclick = new Function('return false'); 
		return true;
	}
}

function CheckBartenderCommentForm(button)
{
   <!--makes sure something is in the comment field-->
	if(document.pageform.comment.value.length <= 25)
	{
		alert("Please enter a comment that is at least a few words.");
		return false;
	}
	else
	{
		button.value='Processing, please wait ...';
		button.onclick = new Function('return false'); 
		return true;
	}
}


/******************** menu item code ********************/
//called from menu item addition
//will show popup to allow item to be chosen from either beer or drink list 
function checkForMenuItemList(it){
	if(it == "Mixed Drink" || it == "Beer"){
		var wants_beer = (it == "Beer") ? '1' : '0';
		Modalbox.show('/listings/ajax_menu_item.aspx?wb='+wants_beer, {title: 'Choose Item', width: 400, height: 450});
	}
}

function getAjaxItemList(){
	$('search_button').innerHTML = 'Searching...';
	$('search_button').disabled = true;
	$('items_list_div').innerHTML = '';

	new Ajax.Request("/listings/ajax_menu_item.aspx", { 'parameters': { 'wb': $('wb').value, 'kw': $('kw').value, 'action': 'search' }, 'onComplete': ProcessAjaxItemList });	
}

function ProcessAjaxItemList(http, json)
{
	// the js from this response contains variables
	var str = http.responseText;
	//alert(str);
	if (!isError(str)) 
	{
		if (doParse(str))
		{
			str = str.replace("<status>1</status>", "");
			eval(str);
			
			if(_listing_items != undefined){
				var op = "";
				
				for(var k in _listing_items){
					if($('wb').value == "1"){
					 op += "<a href=\"#\" onclick=\"setPickedItem('" + _listing_items[k]['alcohols_id'] + "','" + _listing_items[k]['alcohols_name'].replace(/'/g, "\\'")  + "','" + _listing_items[k]['alcohol_makers_id'] + "','" + _listing_items[k]['alcohol_makers_name'].replace(/'/g, "\\'")  + "','',''); return false;\">" + _listing_items[k]['alcohols_name'] + '</a><br/>';
					}
					else if($('wb').value == "2"){
						//bartender
						op += "<a href=\"#\" onclick=\"setBartenderPickedItem('" + _listing_items[k]['drinks_id'] + "','" + _listing_items[k]['drinks_name'].replace(/'/g, "\\'")  + "', '" + _listing_items[k]['drinks_ln'] + "'); return false;\">" + _listing_items[k]['drinks_name'] + '</a><br/>';
					}
					else{
						op += "<a href=\"#\" onclick=\"setPickedItem('','','','','" + _listing_items[k]['drinks_id'] + "','" + _listing_items[k]['drinks_name'].replace(/'/g, "\\'")  + "'); return false;\">" + _listing_items[k]['drinks_name'] + '</a><br/>';
					}
				}
				$('items_list_div').innerHTML = op;
			}
			
		}
	}
	else
	{
		str = str.replace("<status>0</status>", "");
		if(str != ''){
			$('items_list_div').innerHTML = str;
		}
		else{
			$('items_list_div').innerHTML = 'Error trying to compute results. Try again.';
		}
	}
	
	$('search_button').innerHTML = 'Search';
	$('search_button').disabled = false;
}

function setPickedItem(alcohols_id, alcohols_name, alcohol_makers_id, alcohol_makers_name, drinks_id, drinks_name)
{
	$('alcohols_id').value = alcohols_id;
	$('alcohols_name').value = alcohols_name;
	$('alcohol_makers_id').value = alcohol_makers_id;
	$('alcohol_makers_name').value = alcohol_makers_name;
	$('drinks_id').value = drinks_id;
	$('drinks_name').value = drinks_name;
	$('item_desc').value = (drinks_name != "") ? drinks_name : alcohols_name;
	Modalbox.hide();
}

function setBartenderPickedItem(drinks_id, drinks_name, ln)
{
	var d = new Element('div', {id: 'drink-div'+drinks_id});
	var a = new Element('a', { 'target': '_blank', href: '/drinks/'+ln+'-'+drinks_id+'-recipe.aspx' }).update(drinks_name + ' ');
	d.appendChild(a);
	
	if($('do_ajax') == undefined){
		var a = new Element('a', { 'onclick': '$("drink-div'+drinks_id+'").remove(); return false;', href: '#', style: 'color: #000000' }).update(' [remove]');
		d.appendChild(a);
		var i = new Element('input', { 'type': 'hidden', name: 'drinks_ids', value: drinks_id });
		d.appendChild(i);
	}
	else{
		//being called by owner on page so actually save this
		var a = new Element('a', { 'onclick': '$("drink-div'+id+'").remove(); updateAjaxBartenderItems("drink_delete", "'+$('do_ajax').value+'", "'+drinks_id+'"); return false;', href: '#', style: 'color: #000000' }).update(' [remove]');
		d.appendChild(a);
		updateAjaxBartenderItems("drink_add", $('do_ajax').value, drinks_id)
	}
	
	$('drink_col').appendChild(d);
	Modalbox.hide();
}

/******************* bartender ajax calls ********************************/

function getAjaxBartenderJobSearchList(){
	$('search_button').innerHTML = 'Searching...';
	$('search_button').disabled = true;
	$('items_list_div').innerHTML = '';

	new Ajax.Request("/listings/search.aspx", { 'parameters': { 'keywords': $('kw').value, 'action': 'get_ajax_list' }, 'onComplete': ProcessAjaxBartenderJobSearchList });	
}

function ProcessAjaxBartenderJobSearchList(http, json)
{
	// the js from this response contains variables
	var str = http.responseText;
	//alert(str);
	if (!isError(str)) 
	{
		if (doParse(str))
		{
			str = str.replace("<status>1</status>", "");
			eval(str);
			
			if(_listing_items != undefined){
				var op = "";
				
				for(var k in _listing_items){
					op += "<a href=\"#\" onclick=\"setPickedBartenderJobItem('" + _listing_items[k]['ln'] + "', '" + _listing_items[k]['name'].replace(/'/g, "\\'")  + "','" + _listing_items[k]['city'].replace(/'/g, "\\'")  + "','" + _listing_items[k]['phone'] + "','" + k + "'); return false;\">" + _listing_items[k]['name'] + " in " + _listing_items[k]['city'] + ", " + _listing_items[k]['state'] + "</a> (<a href=\"/listings/" + _listing_items[k]['ln'] + "-"+k+"-details.aspx\" target=\"_blank\">View Page</a>)<br/>";
				}
				$('items_list_div').innerHTML = op;
			}
			
		}
	}
	else
	{
		str = str.replace("<status>0</status>", "");
		if(str != ''){
			$('items_list_div').innerHTML = str;
		}
		else{
			$('items_list_div').innerHTML = 'Error trying to compute results. Try again.';
		}
	}
	
	$('search_button').innerHTML = 'Search';
	$('search_button').disabled = false;
}

function setPickedBartenderJobItem(ln, name, city, phone, id)
{
	//alert(id);
	var d = new Element('div', {id: 'job-div'+id});
	var a = new Element('a', { 'target': '_blank', href: '/listings/'+ln+'-'+id+'-details.aspx' }).update(name + ' in ' + city + ' ');
	d.appendChild(a);
	
	
	if($('do_ajax') == undefined){
		var a = new Element('a', { 'onclick': '$("job-div'+id+'").remove(); return false;', href: '#', style: 'color: #000000' }).update(' [remove]');
		d.appendChild(a);
		var i = new Element('input', { 'type': 'hidden', name: 'listings_ids', value: id });
		d.appendChild(i);
	}
	else{
		//being called by owner on page so actually save this
		var a = new Element('a', { 'onclick': '$("job-div'+id+'").remove(); updateAjaxBartenderItems("job_delete", "'+$('do_ajax').value+'", "'+id+'"); return false;', href: '#', style: 'color: #000000' }).update(' [remove]');
		d.appendChild(a);
		updateAjaxBartenderItems("job_add", $('do_ajax').value, id)
	}
	
	$('job_col').appendChild(d);
	Modalbox.hide();
}

function updateAjaxBartenderItems(action, id, aid){
	//will handle add and removing jobs and drinks by owner from detial page
	new Ajax.Request("/listings/add-bartender.aspx", { 'parameters': { 'action': action, 'id': id, 'action_id': aid }, 'onComplete': ProcessAjaxBartenderDefault });	
}

function updateAjaxBartenderInfo(action, id, c, v){
	//will handle add and removing jobs and drinks by owner from detial page
	new Ajax.Request("/listings/add-bartender.aspx", { 'parameters': { 'action': action, 'id': id, 'action_col': c, 'action_val': v }, 'onComplete': ProcessAjaxBartenderDefault });	
}

function ProcessAjaxBartenderDefault(http, json)
{
	// the js from this response contains variables
	var str = http.responseText;
	//alert(str);
}


/******************** premier signup quick search code ********************/
//called from premier signup
//will show popup to allow item to be searched for and chosen instead of requiring user to hand enter info

function getAjaxPremierSearchList(){
	$('search_button').innerHTML = 'Searching...';
	$('search_button').disabled = true;
	$('items_list_div').innerHTML = '';

	new Ajax.Request("/"+$('type').value+"/search.aspx", { 'parameters': { 'keywords': $('kw').value, 'action': 'get_ajax_list' }, 'onComplete': ProcessAjaxPremierSearchList });	
}

function ProcessAjaxPremierSearchList(http, json)
{
	// the js from this response contains variables
	var str = http.responseText;
	//alert(str);
	if (!isError(str)) 
	{
		if (doParse(str))
		{
			str = str.replace("<status>1</status>", "");
			eval(str);
			
			if(_listing_items != undefined){
				var op = "";
				
				for(var k in _listing_items){
					op += "<a href=\"#\" onclick=\"setPickedPremierItem('" + _listing_items[k]['name'].replace(/'/g, "\\'")  + "','" + _listing_items[k]['city'].replace(/'/g, "\\'")  + "','" + _listing_items[k]['phone'] + "'); return false;\">" + _listing_items[k]['name'] + " in " + _listing_items[k]['city'] + ", " + _listing_items[k]['state'] + "</a> (<a href=\"/"+$('type').value+"/" + _listing_items[k]['ln'] + "-"+k+"-details.aspx\" target=\"_blank\">View Page</a>)<br/>";
				}
				$('items_list_div').innerHTML = op;
			}
			
		}
	}
	else
	{
		str = str.replace("<status>0</status>", "");
		if(str != ''){
			$('items_list_div').innerHTML = str;
		}
		else{
			$('items_list_div').innerHTML = 'Error trying to compute results. Try again.';
		}
	}
	
	$('search_button').innerHTML = 'Search';
	$('search_button').disabled = false;
}

function setPickedPremierItem(name, city, phone)
{
	if($('type').value == "bands_djs"){
		$('name').value = name;
		$('city').value = city;
	}
	else{
		$('phone').value = phone;
	}
	Modalbox.hide();
}

/************  quick count calls for forms  *****************/
var timer_id = 0;
var prequery_count_zero = 0;
var base_count_for = '';


function getBaseCount(delay){	
	
	params = {};
	params['action'] = 'get_base_count';
	
	if(base_count_for == 'drinks'){
		var s_keywords = $('keywords').value;
		params['keywords'] = s_keywords;
		if($('is_cup').checked) { params['is_cup'] = '1'; }
		if($('is_frozen').checked) { params['is_frozen'] = '1'; }
		if($('is_hot').checked) { params['is_hot'] = '1'; }
		if($('is_martini').checked) { params['is_martini'] = '1'; }
		if($('is_mixed').checked) { params['is_mixed'] = '1'; }
		if($('is_pint').checked) { params['is_pint'] = '1'; }
		if($('is_pitcher').checked) { params['is_pitcher'] = '1'; }
		if($('is_shot').checked) { params['is_shot'] = '1'; }
		if($('is_straight').checked) { params['is_straight'] = '1'; }
		if($('has_beer').checked) { params['has_beer'] = '1'; }
		if($('has_brandy').checked) { params['has_brandy'] = '1'; }
		if($('has_champagne').checked) { params['has_champagne'] = '1'; }
		if($('has_flavored_rum').checked) { params['has_flavored_rum'] = '1'; }
		if($('has_flavored_vodka').checked) { params['has_flavored_vodka'] = '1'; }
		if($('has_gin').checked) { params['has_gin'] = '1'; }
		if($('has_irish_cream').checked) { params['has_irish_cream'] = '1'; }
		if($('has_jagermeister').checked) { params['has_jagermeister'] = '1'; }
		if($('has_kahlua').checked) { params['has_kahlua'] = '1'; }
		if($('has_liqueur').checked) { params['has_liqueur'] = '1'; }
		if($('has_puckers').checked) { params['has_puckers'] = '1'; }
		if($('has_red_wine').checked) { params['has_red_wine'] = '1'; }
		if($('has_rum').checked) { params['has_rum'] = '1'; }
		if($('has_sambuca').checked) { params['has_sambuca'] = '1'; }
		if($('has_schnapps').checked) { params['has_schnapps'] = '1'; }
		if($('has_scotch').checked) { params['has_scotch'] = '1'; }
		if($('has_soda').checked) { params['has_soda'] = '1'; }
		if($('has_tequila').checked) { params['has_tequila'] = '1'; }
		if($('has_vodka').checked) { params['has_vodka'] = '1'; }
		if($('has_whiskey').checked) { params['has_whiskey'] = '1'; }
		if($('has_white_wine').checked) { params['has_white_wine'] = '1'; }
		if($('has_wine').checked) { params['has_wine'] = '1'; }
	}
	else if(base_count_for == 'users'){
		var s_keywords = $('keywords').value;
		params['keywords'] = s_keywords;		
		params['search_for'] = getCheckedValue(document.forms['pageform'].elements['search_for']);
	}
	else if(base_count_for == 'bands_djs'){
		params['keywords'] = $('keywords').value;
		params['name'] = $('name').value;
		params['address'] = $('address').value;
		params['city'] = $('city').value;
		params['zipcode'] = $('zipcode').value;
		params['zipcode_radius'] = $('zipcode_radius').value;
		params['spc'] = $('spc').value;
		params['area'] = $('area').value;
		if($('MatchExactly').checked) { params['MatchExactly'] = '1'; }
		if($('barfinder_reviewed') != undefined && $('barfinder_reviewed').checked) { params['barfinder_reviewed'] = '1'; }
		
		if($('advanced_search_options').value == '1'){
			params['members'] = $('members').value;		
			if($('dj').checked) { params['dj'] = '1'; }
			if($('band').checked) { params['band'] = '1'; }
			if($('music_type_blues').checked) { params['music_type_blues'] = '1'; }
			if($('music_type_folk').checked) { params['music_type_folk'] = '1'; }
			if($('music_type_art_music').checked) { params['music_type_art_music'] = '1'; }
			if($('music_type_country').checked) { params['music_type_country'] = '1'; }
			if($('music_type_electronic').checked) { params['music_type_electronic'] = '1'; }
			if($('music_type_heavy_metal').checked) { params['music_type_heavy_metal'] = '1'; }
			if($('music_type_industrial').checked) { params['music_type_industrial'] = '1'; }
			if($('music_type_hip_hop').checked) { params['music_type_hip_hop'] = '1'; }
			if($('music_type_jazz').checked) { params['music_type_jazz'] = '1'; }
			if($('music_type_popular_music').checked) { params['music_type_popular_music'] = '1'; }
			if($('music_type_reggae').checked) { params['music_type_reggae'] = '1'; }
			if($('music_type_rock').checked) { params['music_type_rock'] = '1'; }
			if($('music_type_classic_rock').checked) { params['music_type_classic_rock'] = '1'; }
			if($('music_type_hard_rock').checked) { params['music_type_hard_rock'] = '1'; }
			if($('music_type_punk').checked) { params['music_type_punk'] = '1'; }
			if($('music_type_classical').checked) { params['music_type_classical'] = '1'; }
			if($('music_type_cultural').checked) { params['music_type_cultural'] = '1'; }
			if($('music_type_big_band').checked) { params['music_type_big_band'] = '1'; }
			if($('music_type_irish').checked) { params['music_type_irish'] = '1'; }
			if($('music_type_spanish').checked) { params['music_type_spanish'] = '1'; }
			if($('price_cheap').checked) { params['price_cheap'] = '1'; }
			if($('price_moderate').checked) { params['price_moderate'] = '1'; }
			if($('price_expensive').checked) { params['price_expensive'] = '1'; }		
		}
	}
	else if(base_count_for == 'listings'){
		params['keywords'] = $('keywords').value;
		params['name'] = $('name').value;
		params['address'] = $('address').value;
		params['city'] = $('city').value;
		params['zipcode'] = $('zipcode').value;
		params['zipcode_radius'] = $('zipcode_radius').value;
		params['spc'] = $('spc').value;
		params['area'] = $('area').value;
		params['phone_number'] = $('phone_number').value;
		if($('MatchExactly').checked) { params['MatchExactly'] = '1'; }
		if($('barfinder_reviewed') != undefined && $('barfinder_reviewed').checked) { params['barfinder_reviewed'] = '1'; }
		if($('partycardflag') != undefined && $('partycardflag').checked) { params['partycardflag'] = '1'; }
		if($('cameraflag') != undefined && $('cameraflag').checked) { params['cameraflag'] = '1'; }
		
		if($('advanced_search_options').value == '1'){
			params['smoking'] = $('smoking').value;
			params['pooltables'] = $('pooltables').value;
			params['tvs'] = $('tvs').value;
			params['food_menu'] = $('food_menu').value;
			if($('dartboard').checked) { params['dartboard'] = '1'; }		
			if($('shuffleboard').checked) { params['shuffleboard'] = '1'; }		
			if($('jukebox').checked) { params['jukebox'] = '1'; }		
			if($('dj').checked) { params['dj'] = '1'; }		
			if($('live_entertainment').checked) { params['live_entertainment'] = '1'; }		
			if($('nightly_specials').checked) { params['nightly_specials'] = '1'; }		
			if($('table_seating').checked) { params['table_seating'] = '1'; }		
			if($('group_seating').checked) { params['group_seating'] = '1'; }		
			if($('video_games').checked) { params['video_games'] = '1'; }					
			if($('atmosphere_pub').checked) { params['atmosphere_pub'] = '1'; }		
			if($('atmosphere_upscale').checked) { params['atmosphere_upscale'] = '1'; }		
			if($('atmosphere_club').checked) { params['atmosphere_club'] = '1'; }		
			if($('atmosphere_bar').checked) { params['atmosphere_bar'] = '1'; }		
			if($('atmosphere_sportsbar').checked) { params['atmosphere_sportsbar'] = '1'; }		
			if($('atmosphere_lounge').checked) { params['atmosphere_lounge'] = '1'; }		
			if($('atmosphere_beachbar').checked) { params['atmosphere_beachbar'] = '1'; }		
			if($('atmosphere_hotelbar').checked) { params['atmosphere_hotelbar'] = '1'; }		
			if($('atmosphere_tikibar').checked) { params['atmosphere_tikibar'] = '1'; }		
			if($('atmosphere_divebar').checked) { params['atmosphere_divebar'] = '1'; }		
			if($('atmosphere_winebar').checked) { params['atmosphere_winebar'] = '1'; }		
			if($('atmosphere_neighborhoodbar').checked) { params['atmosphere_neighborhoodbar'] = '1'; }		
			if($('atmosphere_cigarbar').checked) { params['atmosphere_cigarbar'] = '1'; }		
			if($('atmosphere_billiardsbar').checked) { params['atmosphere_billiardsbar'] = '1'; }		
			if($('atmosphere_beerbar').checked) { params['atmosphere_beerbar'] = '1'; }		
			if($('atmosphere_sushibar').checked) { params['atmosphere_sushibar'] = '1'; }		
			if($('atmosphere_tequilabar').checked) { params['atmosphere_tequilabar'] = '1'; }		
			if($('atmosphere_brewery').checked) { params['atmosphere_brewery'] = '1'; }		
			if($('atmosphere_dancescene').checked) { params['atmosphere_dancescene'] = '1'; }		
			if($('atmosphere_livemusic').checked) { params['atmosphere_livemusic'] = '1'; }		
			if($('atmosphere_gaybar').checked) { params['atmosphere_gaybar'] = '1'; }		
			if($('atmosphere_bikerbar').checked) { params['atmosphere_bikerbar'] = '1'; }		
			if($('atmosphere_karaokebar').checked) { params['atmosphere_karaokebar'] = '1'; }		
			if($('atmosphere_poolbar').checked) { params['atmosphere_poolbar'] = '1'; }		
			if($('atmosphere_hookahlounge').checked) { params['atmosphere_hookahlounge'] = '1'; }				
			if($('atmosphere_membershiprequired').checked) { params['atmosphere_membershiprequired'] = '1'; }	
			if($('atmosphere_ethnic').checked) { params['atmosphere_ethnic'] = '1'; }	
			if($('atmosphere_japanese').checked) { params['atmosphere_japanese'] = '1'; }	
			if($('atmosphere_mexican').checked) { params['atmosphere_mexican'] = '1'; }	
			if($('atmosphere_italian').checked) { params['atmosphere_italian'] = '1'; }	
			if($('atmosphere_irish').checked) { params['atmosphere_irish'] = '1'; }	
			if($('atmosphere_mediterranean').checked) { params['atmosphere_mediterranean'] = '1'; }	
			if($('atmosphere_casinobar').checked) { params['atmosphere_casinobar'] = '1'; }	
			if($('atmosphere_afterwork').checked) { params['atmosphere_afterwork'] = '1'; }	
			if($('atmosphere_stripclub').checked) { params['atmosphere_stripclub'] = '1'; }	
			if($('atmosphere_pianobar').checked) { params['atmosphere_pianobar'] = '1'; }	
			if($('atmosphere_jazzbar').checked) { params['atmosphere_jazzbar'] = '1'; }	
			if($('atmosphere_tapasbar').checked) { params['atmosphere_tapasbar'] = '1'; }	
			if($('atmosphere_rooftop').checked) { params['atmosphere_rooftop'] = '1'; }	
			if($('atmosphere_foamparty').checked) { params['atmosphere_foamparty'] = '1'; }	
			if($('atmosphere_multiroom').checked) { params['atmosphere_multiroom'] = '1'; }	
			if($('atmosphere_modern').checked) { params['atmosphere_modern'] = '1'; }	
			if($('atmosphere_eclectic').checked) { params['atmosphere_eclectic'] = '1'; }	
			if($('atmosphere_latin').checked) { params['atmosphere_latin'] = '1'; }	
			if($('atmosphere_chinese').checked) { params['atmosphere_chinese'] = '1'; }	
			if($('atmosphere_creole').checked) { params['atmosphere_creole'] = '1'; }	
			if($('atmosphere_asian').checked) { params['atmosphere_asian'] = '1'; }	
			if($('atmosphere_african').checked) { params['atmosphere_african'] = '1'; }	
			if($('atmosphere_french').checked) { params['atmosphere_french'] = '1'; }	
			if($('atmosphere_bbq').checked) { params['atmosphere_bbq'] = '1'; }	
			if($('atmosphere_buffalowings').checked) { params['atmosphere_buffalowings'] = '1'; }	
			if($('atmosphere_steakhouse').checked) { params['atmosphere_steakhouse'] = '1'; }	
			if($('atmosphere_pizza').checked) { params['atmosphere_pizza'] = '1'; }	
			if($('atmosphere_russian').checked) { params['atmosphere_russian'] = '1'; }	
			if($('atmosphere_patiobar').checked) { params['atmosphere_patiobar'] = '1'; }	
			if($('atmosphere_tavern').checked) { params['atmosphere_tavern'] = '1'; }	
			if($('atmosphere_comedyclub').checked) { params['atmosphere_comedyclub'] = '1'; }	
			if($('atmosphere_collegebar').checked) { params['atmosphere_collegebar'] = '1'; }	
			if($('atmosphere_outdoorseating').checked) { params['atmosphere_outdoorseating'] = '1'; }	
			if($('atmosphere_upscale2').checked) { params['atmosphere_upscale2'] = '1'; }	
			if($('atmosphere_british').checked) { params['atmosphere_british'] = '1'; }	
			if($('atmosphere_german').checked) { params['atmosphere_german'] = '1'; }	
			if($('atmosphere_spanish').checked) { params['atmosphere_spanish'] = '1'; }	
			if($('atmosphere_belgian').checked) { params['atmosphere_belgian'] = '1'; }	
			if($('atmosphere_european').checked) { params['atmosphere_european'] = '1'; }	
			if($('atmosphere_american').checked) { params['atmosphere_american'] = '1'; }	
			if($('atmosphere_middleeastern').checked) { params['atmosphere_middleeastern'] = '1'; }	
			if($('atmosphere_polynesian').checked) { params['atmosphere_polynesian'] = '1'; }	
			if($('atmosphere_seafood').checked) { params['atmosphere_seafood'] = '1'; }	
			if($('atmosphere_burgers').checked) { params['atmosphere_burgers'] = '1'; }	
			if($('atmosphere_tacos').checked) { params['atmosphere_tacos'] = '1'; }	
			if($('atmosphere_sleek').checked) { params['atmosphere_sleek'] = '1'; }	
			if($('atmosphere_urban').checked) { params['atmosphere_urban'] = '1'; }	
			if($('atmosphere_fusion').checked) { params['atmosphere_fusion'] = '1'; }	
			if($('crowd_hiphop').checked) { params['crowd_hiphop'] = '1'; }	
			if($('crowd_technohouse').checked) { params['crowd_technohouse'] = '1'; }	
			if($('crowd_locals').checked) { params['crowd_locals'] = '1'; }	
			if($('crowd_rock').checked) { params['crowd_rock'] = '1'; }	
			if($('crowd_20somethings').checked) { params['crowd_20somethings'] = '1'; }	
			if($('crowd_singles').checked) { params['crowd_singles'] = '1'; }	
			if($('crowd_couples').checked) { params['crowd_couples'] = '1'; }	
			if($('crowd_romantic').checked) { params['crowd_romantic'] = '1'; }	
			if($('crowd_ethnic').checked) { params['crowd_ethnic'] = '1'; }	
			if($('crowd_outoftowners').checked) { params['crowd_outoftowners'] = '1'; }	
			if($('crowd_gay').checked) { params['crowd_gay'] = '1'; }	
			if($('crowd_crowded').checked) { params['crowd_crowded'] = '1'; }	
			if($('crowd_laidback').checked) { params['crowd_laidback'] = '1'; }	
			if($('crowd_college').checked) { params['crowd_college'] = '1'; }	
			if($('crowd_over40').checked) { params['crowd_over40'] = '1'; }	
			if($('crowd_vipceleb').checked) { params['crowd_vipceleb'] = '1'; }	
			if($('crowd_sophisticated').checked) { params['crowd_sophisticated'] = '1'; }	
			if($('crowd_localsportsfans').checked) { params['crowd_localsportsfans'] = '1'; }	
			if($('crowd_punkster').checked) { params['crowd_punkster'] = '1'; }	
			if($('crowd_artsy').checked) { params['crowd_artsy'] = '1'; }	
			if($('crowd_energetic').checked) { params['crowd_energetic'] = '1'; }	
			if($('crowd_heavydrinking').checked) { params['crowd_heavydrinking'] = '1'; }	
			if($('crowd_professionals').checked) { params['crowd_professionals'] = '1'; }	
			if($('twentyfourseven').checked) { params['twentyfourseven'] = '1'; }	
			if($('happyhourflag').checked) { params['happyhourflag'] = '1'; }	
			if($('quizzo').checked) { params['quizzo'] = '1'; }	
			if($('foosball').checked) { params['foosball'] = '1'; }	
			if($('bowling').checked) { params['bowling'] = '1'; }	
			if($('gambling').checked) { params['gambling'] = '1'; }	
			if($('take_out').checked) { params['take_out'] = '1'; }	
			if($('delivery').checked) { params['delivery'] = '1'; }	
			if($('bottle_service').checked) { params['bottle_service'] = '1'; }	
			if($('valet_parking').checked) { params['valet_parking'] = '1'; }	
			if($('margaritas').checked) { params['margaritas'] = '1'; }	
			if($('sake').checked) { params['sake'] = '1'; }	
			if($('gin').checked) { params['gin'] = '1'; }	
			if($('mechanical_bull').checked) { params['mechanical_bull'] = '1'; }	
			if($('beer_pong').checked) { params['beer_pong'] = '1'; }	
			if($('big_screen_tvs').checked) { params['big_screen_tvs'] = '1'; }	
			if($('flip_cup').checked) { params['flip_cup'] = '1'; }	
			if($('whiskey').checked) { params['whiskey'] = '1'; }	
			if($('bourbon').checked) { params['bourbon'] = '1'; }	
			if($('frozen').checked) { params['frozen'] = '1'; }	
			if($('mojitos').checked) { params['mojitos'] = '1'; }	
			if($('worldly_beers').checked) { params['worldly_beers'] = '1'; }	
			if($('microbrews').checked) { params['microbrews'] = '1'; }	
			if($('cordials').checked) { params['cordials'] = '1'; }	
			if($('vodka').checked) { params['vodka'] = '1'; }	
			if($('rum').checked) { params['rum'] = '1'; }	
			if($('scotch').checked) { params['scotch'] = '1'; }	
			if($('wine').checked) { params['wine'] = '1'; }	
			if($('tequila').checked) { params['tequila'] = '1'; }	
			//if($('signature_drink').checked) { params['signature_drink'] = '1'; }	
			//if($('signature_dish').checked) { params['signature_dish'] = '1'; }	
			if($('beer_aficionado').checked) { params['beer_aficionado'] = '1'; }	
			if($('price_cheap').checked) { params['price_cheap'] = '1'; }
			if($('price_moderate').checked) { params['price_moderate'] = '1'; }
			if($('price_expensive').checked) { params['price_expensive'] = '1'; }			
			if($('food_breakfast').checked) { params['food_breakfast'] = '1'; }	
			if($('food_lunch').checked) { params['food_lunch'] = '1'; }	
			if($('food_dinner').checked) { params['food_dinner'] = '1'; }	
			if($('visa').checked) { params['visa'] = '1'; }	
			if($('mastercard').checked) { params['mastercard'] = '1'; }	
			if($('discover').checked) { params['discover'] = '1'; }	
			if($('amex').checked) { params['amex'] = '1'; }	
		}
	}
	
	//show wait while we get count text
	$('count-text-div').show();
	$('count-text').innerHTML = '...computing results...';
	
	
	if(timer_id){
		clearTimeout(timer_id);
		timer_id = 0;
	}
	
	if(base_count_for == 'drinks'){
		timer_id = setTimeout('DoQuickAjax(\'/drinks/search.aspx\', params, \'parseGetBaseCount\')',delay);
	}
	else if(base_count_for == 'users'){
		timer_id = setTimeout('DoQuickAjax(\'/user/search.aspx\', params, \'parseGetBaseCount\')',delay);
	}
	else if(base_count_for == 'bands_djs'){
		timer_id = setTimeout('DoQuickAjax(\'/bands_djs/search.aspx\', params, \'parseGetBaseCount\')',delay);
	}
	else if(base_count_for == 'listings'){
		timer_id = setTimeout('DoQuickAjax(\'/listings/search.aspx\', params, \'parseGetBaseCount\')',delay);
	}
}

function parseGetBaseCount()
{
	prequery_count_zero = 0;
	var str = httpObj.getResponse();
	//alert(str);
	if (!isError(str)) 
	{
		if (doParse(str))
		{
			str = str.replace("<status>1</status>", "");
			//show counter and count
				$('count-text').innerHTML = str;
		}
		else{
			$('count-text').innerHTML = 'Error trying to compute results. Click search to view results.';
		}
	}
	else
	{
		str = str.replace("<status>0</status>", "");
		if(str != ''){
			$('count-text').innerHTML = str;
		}
		else{
			$('count-text').innerHTML = 'Error trying to compute results. Click search to view results.';
		}
	}
}


// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

///////////// video feed code

function reloadCameraFeed(id){
	if($(id) != undefined){	
		var nd = new Date();
		//alert(nd.getTime());
		var tsrc = $(id).src;
		tsrc = tsrc.replace(/\&ts=.*$/ig, "");
		$(id).src = tsrc + '&ts=' + nd.getTime();
	}
}

////////////// end video feed code


////////////// poll code
var current_poll_id = '';

function showPoll(){
	try{
		if(current_poll_id != '' && showPollHelper()){
			Modalbox.show('/user/poll.aspx', {title: 'Vote Now', width: 400, height: 450});
		}
	}
	catch(err){ 
		//do nothing.
		alert(err);
	}
}

//checks and drops cookie if not there indicating if poll should
//auto open if not done yet for this poll ont his computer
function showPollHelper(){
	var sp = GetCookie("showpoll");
	if(sp == "" || sp != current_poll_id){
		var theDate = new Date();
		var fiveYearFuture = new Date( theDate.getTime() + (31536000000 * 5) );
		SetCookie ("showpoll", current_poll_id, fiveYearFuture, "/");
		return true;
	}
	else{
		return false;
	}
}

//static search box helper methods

function staticSearchOptions(area){
	
	if(area == 'listings'){
		$('static_search_listings').show();
		$('static_search_bands_djs').hide();
		$('static_search_drinks').hide();
		$('static_search_files').hide();
		$('static_search_forum').hide();
	}
	else if(area == 'bands_djs'){
		$('static_search_listings').hide();
		$('static_search_bands_djs').show();
		$('static_search_drinks').hide();
		$('static_search_files').hide();
		$('static_search_forum').hide();
	}
	else if(area == 'drinks'){
		$('static_search_listings').hide();
		$('static_search_bands_djs').hide();
		$('static_search_drinks').show();	
		$('static_search_files').hide();
		$('static_search_forum').hide();
	}
	else if(area == 'files'){
		$('static_search_listings').hide();
		$('static_search_bands_djs').hide();
		$('static_search_drinks').hide();	
		$('static_search_files').show();
		$('static_search_forum').hide();
	}
	else if(area == 'forum'){
		$('static_search_listings').hide();
		$('static_search_bands_djs').hide();
		$('static_search_drinks').hide();	
		$('static_search_files').hide();
		$('static_search_forum').show();
	}
	else{
		$('static_search_listings').hide();
		$('static_search_bands_djs').hide();
		$('static_search_drinks').hide();
		$('static_search_files').hide();
		$('static_search_forum').hide();
	}
}

//called onsubmit for listings and bands_djs search, will clear un changed defaults
function checkStaticSearchDefaults(area){
	//name, city_state, states, zipcode
	if(area == 'listings'){
		if($('static_search_listings_name').value == " Bar/Club Name "){
			$('static_search_listings_name').value = "";
		}
		if($('static_search_listings_zipcode').value == " Zip "){
			$('static_search_listings_zipcode').value = "";
		}
	}
	
	if(area == 'bands_djs'){
		if($('static_search_bands_djs_name').value == " Group Name "){
			$('static_search_bands_djs_name').value = "";
		}
		if($('static_search_bands_djs_zipcode').value == " Zip "){
			$('static_search_bands_djs_zipcode').value = "";
		}
	}
}

//called from header submit
function submitStaticSearch(){
	//static_search_area, keywords, where
	var ssa = $('static_search_area').value;
	var ssk = $('static_search_keywords').value;
	var ssw = $('static_search_where').value.replace(/^\s+|\s+$/g,'');
	var gt = ''; //value to jump to
	var gtwhere = ''; //gets appended with proper where params
	
	//try and extract city_state, zipcode and spc from ssw if possible
	//address, city, state or zip
	if(ssw != ''){
		//try and get zip
		var tmp = ssw.match(/\d\d\d\d\d$/);
		if(tmp != null){
			gtwhere = "&zipcode="+tmp;
		}
		else{
			//no zip
			//tmp = ssw.match(/^(.+),\s*(.+),\s*(\D\D)/g);
			tmp = ssw.split(",");
			if(tmp != null && tmp.length == 3)
			{
				//address, city, state
				gtwhere = "&city_state="+tmp[1].replace(/^\s+|\s+$/g,'')+"|"+tmp[2].replace(/^\s+|\s+$/g,'');
			}
			else if(tmp != null && tmp.length == 2)
			{
				//city, state
				gtwhere = "&city_state="+tmp[0].replace(/^\s+|\s+$/g,'')+"|"+tmp[1].replace(/^\s+|\s+$/g,'');
			}
			else{
				//can't parse so enter as keywords
				ssk += " " + ssw;
			}
		}	
	}
	
	if(ssa == 'listings'){		
		gt = '/listings/search.aspx?area=&MatchExactly=1&zipcode_radius=15&keywords='+ssk+'&search=Submit'+gtwhere;
	}
	else if(ssa == 'bands_djs'){
		gt = '/bands_djs/search.aspx?area=usa&MatchExactly=1&zipcode_radius=15&keywords='+ssk+'&search=Submit'+gtwhere;
	}
	else if(ssa == 'drinks'){
		gt = '/drinks/search.aspx?action=search&target=results&keywords='+ssk+'&Submit=Search';
	}
	else if(ssa == 'files'){
		gt = '/filelibrary/search.aspx?action=search&file_search=Search&target=search&sort_by=name&keywords='+ssk+'&Submit=Search';
	}
	else if(ssa == 'forum'){
		gt = '/forum/search.aspx?value='+ssk+'&Submit=Search';
	}
	else{
		alert('Please enter some search criteria.');
		return;
	}

	window.location = gt;
	
}

/****************** share link toggle **********************/

function showShareLinks(u, t, i){

	if($(i) != undefined){
		//$(i).innerHTML = "<a target=\"_blank\" rel=\"nofollow\" href=\"http://del.icio.us/post?url="+u+"&amp;title="+t+"\"><img src=\"/images/buttons/icons/delicious.gif\" width=\"16\" height=\"16\" hspace=\"3\" border=\"0\" title=\"Add to del.icio.us\" alt=\"Add to del.icio.us\" align=\"absmiddle\"/></a> <a target=\"_blank\" rel=\"nofollow\" href=\"http://digg.com/submit?phase=2&amp;url="+u+"&amp;title="+t+"&amp;bodytext="+t+"\"><img src=\"/images/buttons/icons/digg.gif\" width=\"16\" height=\"16\" hspace=\"3\" border=\"0\" title=\"Digg!\" alt=\"Digg!\" align=\"absmiddle\"/></a> <a target=\"_blank\" rel=\"nofollow\" href=\"http://www.stumbleupon.com/submit?url="+u+"&amp;title="+t+"\"><img src=\"/images/buttons/icons/stumbleit.gif\" width=\"16\" height=\"16\" hspace=\"3\" border=\"0\" title=\"StumbleUpon\" alt=\"StumbleUpon\" align=\"absmiddle\"/></a> <a target=\"_blank\" rel=\"nofollow\" href=\"http://www.facebook.com/sharer.php?u="+u+"&amp;t="+t+"\"><img src=\"/images/buttons/icons/facebook.gif\" width=\"16\" height=\"16\" hspace=\"3\" border=\"0\" title=\"Share via Facebook\" alt=\"Share via Facebook\" align=\"absmiddle\"/></a> <a target=\"_blank\" rel=\"nofollow\" href=\"http://reddit.com/submit?url="+u+"&amp;title="+t+"\"><img src=\"/images/buttons/icons/reddit.gif\" width=\"16\" height=\"16\" hspace=\"3\" border=\"0\" title=\"Add to Reddit\" alt=\"Add to Reddit\" align=\"absmiddle\"/></a> <a target=\"_blank\" rel=\"nofollow\" href=\"http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk="+u+"&amp;title="+t+"\"><img src=\"/images/buttons/icons/google.gif\" width=\"16\" height=\"16\" hspace=\"3\" border=\"0\" title=\"Add to Google Bookmarks\" alt=\"Add to Google Bookmarks\" align=\"absmiddle\"/></a> <a target=\"_blank\" rel=\"nofollow\" href=\"http://myweb2.search.yahoo.com/myresults/bookmarklet?u="+u+"&amp;t="+t+"\"><img src=\"/images/buttons/icons/yahoomyweb.gif\" width=\"16\" height=\"16\" hspace=\"3\" border=\"0\" title=\"Add to Yahoo MyWeb\" alt=\"Add to Yahoo MyWeb\" align=\"absmiddle\"/></a> <a target=\"_blank\" rel=\"nofollow\" href=\"https://favorites.live.com/quickadd.aspx?marklet=1&amp;mkt=en-us&amp;url="+u+"&amp;title="+t+"&amp;top=1\"><img src=\"/images/buttons/icons/windowslive.gif\" width=\"16\" height=\"16\" hspace=\"3\" border=\"0\" title=\"Add to Windows Live\" alt=\"Add to Windows Live\" align=\"absmiddle\"/></a>";
		
		//var e_u = unescape(u);
		
		/*if(false && navigator.userAgent.indexOf('MSIE') >= 0){
			//iframes cause issues in ie
			//$(i).innerHTML = '<div><a href="http://www.facebook.com/share.php?u='+u+'" title="share on facebook"><img alt="share on facebook" title="share on facebook" src="/images/buttons/icons/facebook_medium.png"></a> <a style="margin-left: 5px;" href="http://twitter.com/share?count=none&amp;text='+t+'&amp;url='+u+'" title="share on twitter"><img alt="share on twitter" title="share on twitter" src="/images/buttons/icons/twitter_medium.png"></a></div>';
			
			var submenu = new Element('div');
			submenu.update('<a href="http://www.facebook.com/share.php?u='+u+'" title="share on facebook"><img alt="share on facebook" title="share on facebook" src="/images/buttons/icons/facebook_medium.png"/></a> <a style="margin-left: 5px;" href="http://twitter.com/share?count=none&amp;text='+t+'&amp;url='+u+'" title="share on twitter"><img alt="share on twitter" title="share on twitter" src="/images/buttons/icons/twitter_medium.png"/></a>');
			$(i).appendChild(submenu);
		}
		else{
			//$(i).innerHTML = '<div><iframe src="http://www.facebook.com/plugins/like.php?href='+u+'&amp;layout=standard&amp;show_faces=false&amp;width=225&amp;action=like&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:225px; height:35px;" allowTransparency="true"></iframe><br/><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url='+u+'&amp;text='+t+'&amp;via=barfindercom&amp;related=barfindercom" style="width:100px; height:21px;"></iframe></div>';
			*/
			var submenu = new Element('div');
			submenu.update('<iframe src="http://www.facebook.com/plugins/like.php?href='+u+'&amp;layout=standard&amp;show_faces=false&amp;width=400&amp;action=like&amp;colorscheme=light&amp;height=50" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:400px; height:50px;" allowTransparency="true"></iframe><br/><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url='+u+'&amp;text='+t+'&amp;via=barfindercom&amp;related=barfindercom" style="width:100px; height:21px;"></iframe>');
			$(i).innerHTML = '';
			$(i).appendChild(submenu);
		//}
	}
}


/******** all the add events onload go ehre ************/
if(navigator.userAgent.indexOf('bot') == -1){
	//we know it isn't a bot
	Event.observe(window,'load',showPoll);
}
