(function($){
 $.fn.extend({
 
 	customStyle : function(options) {
	  if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
	  return this.each(function() {
	  
			var currentSelected = $(this).find(':selected');
			$(this).after('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">'+currentSelected.text()+'</span></span>').css({position:'absolute', opacity:0,fontSize:$(this).next().css('font-size')});
			var selectBoxSpan = $(this).next();
			var selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));			
			var selectBoxSpanInner = selectBoxSpan.find(':first-child');
			selectBoxSpan.css({display:'inline-block'});
			// selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
			var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
			$(this).height(selectBoxHeight).change(function(){
				selectBoxSpanInner.text($(this).val()).parent().addClass('changed');
			});
			
	  });
	  }
	}
 });
})(jQuery);
	
function swapStory(storyName){
	$('div.currentStory').hide();
	$('div.currentStory').removeClass('currentStory');
	$('div [id = ' + storyName + ']').addClass('currentStory');
	$('div [id = ' + storyName + ']').fadeIn("slow");
}

$(function() {

	$('div#success_story_column > div:not(".currentStory")').hide();
	$('a.success_thumb_link').click(function(){
		swapStory($(this).attr("id"));
		return(false);
	});

	$('dl#plan_list dd:not(:first)').hide('slow'); // use this to expand first box
	// $('dl#plan_list dd').hide('slow'); // comment this one out before hiding first
	$('dl#plan_list dt').hover(
		function(){
			$(this).css({'color' : '#950000', 'cursor' : 'pointer'});
		},
		function(){
			$(this).css({'color' : '#555555'});
		});
	$('dl#plan_list dt').click(function(){
		$(this).next('dd').slideToggle().siblings("dd:visible").slideUp("slow");
	});
});

/*
$(function() {
  $("#menu img").hover(function() {
    $(this).attr("src", $(this).attr("src").split(".").join("-hover."));
  }, function() {
    $(this).attr("src", $(this).attr("src").split("-hover.").join("."));
  });
});*/

function popURL(strURL,strType,strHeight,strWidth) 
	{
		var strOptions="";

		if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
		if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
		if (strType=="elastic") strOptions="scrollbars,resizable,height="+strHeight+",width="+strWidth;

		newWin = window.open(strURL, 'newWin', strOptions);

		newWin.focus();
}

/*$(document).ready(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
  $('.button').click(function() {
      // validate and process form here
 	$('.error').hide();
	
  	  var first_name = $("input#first_name").val();
  		if (first_name == "") {
        $("label#first_name_error").show();
        $("input#first_name").focus();
        return false;
      }
  	  var last_name = $("input#last_name").val();
  		if (last_name == "") {
        $("label#last_name_error").show();
        $("input#last_name").focus();
        return false;
      }
  	  var freelife_id = $("input#freelife_id").val();
  		if (freelife_id == "") {
        $("label#id_error").show();
        $("input#freelife_id").focus();
        return false;
      }		    
  		var email = $("input#email").val();
  		if (email == "") {
        $("label#email_error").show();
        $("input#email").focus();
        return false;
      }
  		var phone = $("input#phone_number").val();
  		if (phone == "") {
        $("label#phone_error").show();
        $("input#phone_number").focus();
        return false;
      }
  	  var weight = $("input#weight").val();
  		if (weight == "") {
        $("label#weight_error").show();
        $("input#weight").focus();
        return false;
      }	
	 
	// var dataString = 'test data to be passed to form';
		//alert (dataString);return false;
	  
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h3>Thank you! The contest form has been submitted!</h3>")
        .append("<p>You can now <a href='mailto:taislim@freelife.com'>email your photo</a>.</p>")
        .hide()
        .fadeIn(1500);
    return false;
	});
	$(".popup").colorbox({maxWidth:"500px", maxHeight:"500px", opacity:"0.35"});
	$('.countrySelect').customStyle();
});*/

$(document).ready(function() {
	$(".popup").colorbox({maxWidth:"500px", maxHeight:"500px", opacity:"0.35"});
	$('.countrySelect').customStyle();
});