$(function() {

	$('#results').hide();
	$('form.mailer-form').submit(function(){
		$.ajax({
			type: "POST",
			url: $(this).attr('action'),
			data: $(this).serialize(),
			success: function(msg){
				if ($("input[name='mailer_name']")[0].value == 'mailer') {
					$('form.mailer-form').toggle();
					$('#results').toggle();
				} else {
					window.location = '/graphcomm-galaxy/my-profile';
				}
			}
		});
		return false;
	});
	$('form.profile_mailer').submit(function(){
		$.ajax({
			type: "POST",
			url: $(this).attr('action'),
			data: $(this).serialize(),
			success: function(msg){
				$('form.mailer-form').toggle();
				$('#results').toggle();
			}
		});
		return false;
	});

 	if ($.browser.msie) {
    $('div#textfield').css({marginLeft: 400 - $('div#textfield').width() + 'px'});
    $("div#textfield").animate({opacity: 1.0}, 3000).animate({ marginLeft: "-180px", opacity: 1 }, 3000 );
  } else {
    $('div#textfield').css({marginLeft: 620 - $('div#textfield').width() + 295 + 'px'});
    $("div#textfield").animate({opacity: 0.0}, 3000).animate({ marginLeft: "295px", opacity: 1 }, 3000 );
  }

  image_hover('div#wrapper-imaging dd a');
  image_hover('div#wrapper-web dd a');
  image_hover('div#wrapper-print dd a');
  
  $('h1#web').css({cursor:'hand'}).click(function() {
    window.navigate('/web');
  });
  $('h1#imaging').css({cursor:'hand'}).click(function() {
    window.navigate('/imaging');
  });
  $('h1#print').css({cursor:'hand'}).click(function() {
    window.navigate('/print');
  });

});

function image_hover(src) {
  $(src).hover(function() {
    var img = $(this).find('img');
    img.attr('src',img.attr('src').replace(/.png/,"_o.png"));
    // console.log(img.attr('src'));    
  }, function() {
    var img = $(this).find('img');
    img.attr('src', img.attr('src').replace(/_o.png/,".png"));
    // console.log(img.attr('src'));
  });
}

function careerPopUp(URL) {
  var popup = window.open(URL, '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=250');
}

function careerAdvisorPopUp(URL) {
  var popup = window.open(URL, '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=500');
}