$(document).ready(function() {
	
	$("a#donate").bind("click", function() {
		$("#donate_form").submit()
	});

	$("a#form_link").fancybox({
		'hideOnContentClick': false,
		'frameWidth' : 430,
		'frameHeight': 554,
		'padding' : 8
	});
	
	$("a#jamie_link").fancybox({
		'hideOnContentClick': false,
		'frameWidth' : 250,
		'frameHeight': 100,
		'padding' : 8
	});

});

function debug(debug_msg){
        if(window.console){
            console.log("DEBUG>>>>>>>>>");
            console.log(debug_msg);
        }
        return false;
}

function popupJamiePicks() {
	$("#jamie_link").trigger("click");
}

function setupClassifications(destination_options) {
	$("#destination_type").html(destination_options);
}

function popupPostForm() {
	$("#form_link").trigger("click");
}

function trim(str) {
	return str.replace(/^\s+|\s+$/g,"");
}

function validate(name, email, location, address) {

	// Validate the form first
	if (trim(name) == "") {
		alert('Please enter your name.');
		return;
	} else if (trim(email) == "") {
		alert('Please enter your email address.');
		return;
	} else if (trim(location) == "") {
		alert('Please enter a name for the location.');
		return;
	} else if (trim(address) == "") {
		alert('Please enter an address for you location.');
		return;
	}
	
	
	// Assuming all was entered, validate address
	document.getElementById('ck_map_iframe').contentWindow.validateLocation(location, address);
	//window.frames[1].validateLocation(location, address);
	//$("frame[src='http://ckfreemap.calvinkleinfragrances.com/?frame=true']").next();
	
	// Close the fancybox
	$.fn.fancybox.close();
}

function setLatlng(latlng) {
	$('#fancy_inner').find('#latlng').val(latlng);
}

function submitPost() {
	// IF IE6
	if ($.browser.msie && parseInt($.browser.version.substr(0,1)) < 7) {
		$('#fancy_inner').find('#spot_form').attr("action","http://ckfree.wiredset.com/index/post.spot");
		$('#fancy_inner').find("input[type='button']").remove();
		$('#fancy_inner').find('#spot_form').append('<input type="submit" style="display:none;" value="Go" />');
		$('#fancy_inner').find('#spot_form').submit();
	}
	else {
		$('#fancy_inner').find('#spot_form').attr("action","http://ckfree.wiredset.com/index/post.spot");
		$('#fancy_inner').find('#spot_form').submit();
	}
}