/*!
 * Scripts
 *
 */
jQuery(function($) {
 "use strict";

$(".bigpic-a a:first").click(function(){ 
	$(this).fadeToggle("slow", function () {
		if ($(".two p").hasClass("male"))
		{
			var theDate = new Date();
			var oneYearLater = new Date( theDate.getTime() + 31536000000 );
			var expiryDate = oneYearLater.toGMTString();
			document.cookie =  'interested_in=woman;expires=' + expiryDate;
			location.href="/gay-dating/";
		}
		else
		{
			var theDate = new Date();
			var oneYearLater = new Date( theDate.getTime() + 31536000000 );
			var expiryDate = oneYearLater.toGMTString();
			document.cookie =  'interested_in=man;expires=' + expiryDate;
			location.href="/gay-dating/";
		}
	});
});

	var Engine = {
		utils : {
			links : function(){
				$('a[rel*="external"]').click(function(e){
					e.preventDefault();
					window.open($(this).attr('href'));
				});
			},
			mails : function(){
				$('a[href^="mailto:"]').each(function(){
					var 
						mail = $(this).attr('href').replace('mailto:',''),
						replaced = mail.replace('/at/','@');
					$(this).attr('href','mailto:' + replaced);
					if($(this).text() === mail) {
						$(this).text(replaced);
					}
				});
			}
		},
		forms : {
			labels : function() {
				$('#access p label').compactize();
			},
			selects : function() {
				$('select.custom').customSelect();
				$('select.custom2').customSelect2();
				$('select.custom3').customSelect3();
				$('select.custom4').customSelect4();
			}
		},
		fixes : {
			enhancements : function() {
				if($.browser.msie && parseInt($.browser.version,10) < 9){
					if(parseInt($.browser.version,10) < 8){
						$('.register-a header, span.custom-select > span').before('<span class="before"></span>');						
					}
					$('hr').wrap('<div class="hr"></div>');
					$(':last-child:not(cufon)').addClass('last-child');
						
				}
			},
			pie : function() {
				$('body').bind('refresh.pie',function() {
					if($.browser.msie && parseInt($.browser.version,10) < 9){
						if(window.PIE !== undefined){							
							$('.INSERT_PIE_ELEMENTS_HERE').each(function() {
								window.PIE.detach(this);
								window.PIE.attach(this);
							});
						}
					}
				});
			}
		}
	};

	Engine.utils.links();
	Engine.utils.mails();
	Engine.forms.labels();
	Engine.forms.selects();
	Engine.fixes.enhancements();
	
});
