var overSuffix = '-over';

//videoWin(240, 300, 't=test&amp;v=DougHall_Promo')

function videoWin(wid, hght, title, vars)	{	
	pageTracker._trackPageview('guide/'+title+'/');
	window.open('/content/videoplayer.asp?' +vars+ '&w=' + wid+ '&h=' + hght +'&t=' + title, 'video', "width="+(wid + 16)+",height="+(hght + 30)+",scrollbars=no");	
}

function popwin(page,wid,hght,winname)	{	
	window.open(page, winname, "width="+wid+",height="+hght+",scrollbars=yes");	
}


$(document).ready(function(){ 

	// All the button rollovers - the rollover image must have an _over suffix and site in the same folder as the normal state. eg   
	// normal    :   button.gif
	// over		 :	 button_over.gif
	$('.rollOver').hover(
		function ()	{	
			$(this).attr('src',doOverImg($(this).attr('src')))
		},	
		function ()	{	
			$(this).attr('src',doDefaultImg($(this).attr('src')))
		}
	)

}); 

// Roll over helpers
function doOverImg(path)	{
	start = path.substring(0, path.indexOf('.'))
	end = path.substring(path.indexOf('.'))
	overpath = (start + overSuffix + end);
	return overpath
}
function doDefaultImg(path)	{
	return path.replace(overSuffix,'');
}


function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function showHideSPFields(me){
	whichOpt = $(me).val();
	$('#div_valuePurchase').css('display', 'none');
	$('#div_valueSale').css('display', 'none');

	if (whichOpt == '1')	{
		$('#div_valuePurchase').css('display', 'block');
	}

	if (whichOpt == '2')	{
		$('#div_valueSale').css('display', 'block');
	}

	if (whichOpt == '3')	{
		$('#div_valuePurchase').css('display', 'block');
		$('#div_valueSale').css('display', 'block');
	}

	if (whichOpt == '4')	{
		$('#div_valuePurchase').css('display', 'block');
	}
}


$(document).ready(function() {

	$("#accompany").autocomplete("/override/autocomplete.asp", {minChars: 2,
										max: 20,
										autoFill: false,
										mustMatch: false,
										matchContains: true,
										scrollHeight: 120
		});
		
		
});