$(function(){
	initCufon();
});
function initCufon(){
	Cufon.replace('#top-nav>li>a', {textShadow: '1px 2px #474747', fontFamily: '"Avant"',hover: true});
	Cufon.replace('.top-info li', {textShadow: '1px 2px #181818', fontFamily: '"Avant"'});
	Cufon.replace('.slogan', { fontFamily: '"Avant"'});
	Cufon.replace('.map-search .title h3, .welcome-box h2, .quick-search h3, .rss-holder .title h3', {textShadow: '2px 3px #0f0f0f', color: '-linear-gradient(#fff, #bebebe)', fontFamily: '"Avant"' });
	Cufon.replace('.featured-box .title h3', {textShadow: '1px 2px #000', fontFamily: '"Avant"'});
	Cufon.replace('.aside .title h3', {textShadow: '1px 2px #eaca8c', fontFamily: '"Avant"'});
}


function mycarousel_initCallback(carousel)
{
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});

	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});

   jQuery('#mycarousel-next').bind('click', function() {
		carousel.next();
		return false;
	});
	jQuery('#mycarousel-prev').bind('click', function() {
		carousel.prev();
		return false;
	});

	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};

jQuery(document).ready(function() {
	jQuery('#mycarousel').jcarousel({
		vertical: true,
		scroll: 1,
		auto: 3,
		animation: 1000,
		initCallback: mycarousel_initCallback
	});
});

function getAgent(theForm) {
	jQuery.ajax({
		type: "POST",
		dataType: "html",
		url: "/century_21_gold/index.cfm/search/?searchaction=ajax",
		data: "refresh=true&getashtml=true&method=Ajax_getAgents&siteid=century_21_gold&theField=" + jQuery('#MLS_Agent_ID').val(),
		success: function(json){
			var theJSON = jQuery.parseJSON(json);
			var theTarget = jQuery('#agentsearchresults');
			theTarget.html('');
			theTarget.append('<div class="firstname" style="float:left;width:100px;">First Name</div><div class="lastname" style="float:left;width:100px;">Last Name</div><div class="agentid" style="float:left;width:100px;">Agent ID</div><div class="selectthisagent" style="float:left;width:100px;font-weight:bolder;">Select</div><div style="clear:both;"></div>');
			jQuery.each(theJSON.DATA, function(index, value) {
				theTarget.append('<div class="firstname" style="float:left;width:100px;">' + value[0] + '</div><div class="lastname" style="float:left;width:100px;">' + value[1] + '</div><div class="agentid" style="float:left;width:100px;">' + value[3] + '</div><div class="selectthisagent" style="float:left;width:100px;font-weight:bolder;"><a href="javascript:void(0);" onclick="selectagent(' + value[2] + ')" style="color:green">Select</a></div><div style="clear:both;"></div>');
			});
		}
	 });
	return false;
}
function selectagent(nagentsid) {
	jQuery.ajax({
		type: "POST",
		dataType: "html",
		url: "/century_21_gold/index.cfm/search/?searchaction=ajax",
		data: "refresh=true&getashtml=true&method=Ajax_getAgent&siteid=century_21_gold&theField=" + nagentsid,
		success: function(json){
			var theJSON = jQuery.parseJSON(json);
			jQuery('#agentsearchresults').html('');
			jQuery('#Address').val(theJSON.DATA[0][19]);
			jQuery('#City').val(theJSON.DATA[0][20]);
			jQuery('#Email_Address').val(theJSON.DATA[0][11]);
			jQuery('#Full_Name').val(theJSON.DATA[0][3] + ' ' + theJSON.DATA[0][4]);
			jQuery('#Phone_1').val(theJSON.DATA[0][5]);
			jQuery('#Phone_2').val(theJSON.DATA[0][7]);
			jQuery('#Phone_3').val(theJSON.DATA[0][9]);
			jQuery('#Phone_4').val('Cell: ' + theJSON.DATA[0][13]);
			jQuery('#State').val(theJSON.DATA[0][21]);
			jQuery('#Website_Address').val(theJSON.DATA[0][12]);
			jQuery('#Zipcode').val(theJSON.DATA[0][22]);
		}
	});
}
function setDesign(id) {
	jQuery('#Design_Choice').val('Design: ' + id);
	jQuery('#Design_Choice_Hidden').val('Design: ' + id);
	alert('You have selected Design: ' + id);
}

