// JavaScript Document
function checkPM (member) {
	$.ajax({
		type: "POST",								// type of request
		url: "/members/ajax_checkPM.php",						// URL to request
		data: "member=" + member,		// data to pass to URL
		dataType: "script",							// type of returned data (xml, html, script, json)
		success: function(msg) { }	// function to call upon success of request
	});
	
	var t = setTimeout("checkPM(" + member + ")", 30000);
	
}

function displayPMList (member) {
	$.ajax({
		type: "POST",								// type of request
		url: "/members/ajax_displayPMList.php",						// URL to request
		data: "member=" + member,		// data to pass to URL
		dataType: "script",							// type of returned data (xml, html, script, json)
		success: function(msg) { }	// function to call upon success of request
	});
	
	var t = setTimeout("displayPMList(" + member + ")", 10000);
	
}

function deletePM (member, id) {
	$.ajax({
		type: "POST",								// type of request
		url: "/members/ajax_deletePM.php",						// URL to request
		data: "member=" + member + "&ID=" + id,		// data to pass to URL
		dataType: "script",							// type of returned data (xml, html, script, json)
		success: function(msg) { }	// function to call upon success of request
	});
	
	return false;
}

$(document).ready(function(){
	$("a[rel=gallery]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">(' + (currentIndex + 1) + ' / ' + currentArray.length + ')' + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
	$("a.zoomimg").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade'
	});
	
	$("a.fancybox").fancybox({
		'width'				: 400,
		'height'			: 500,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	$("a.fancybox_small").fancybox({
		'width'				: 400,
		'height'			: 350,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	$("a.openmessage").live('click', function() {
		$.fancybox({
			'width'				: 400,
			'height'			: 350,
			'autoScale'     	: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'href'				: this.href
		});
		
		return false;
	});
	
	//alert(document.domain);
	//if (document.domain != "www.bbka.org.uk") alert(document.domain);
	
	$("a.showHide").click(function() {
		var id = $(this).attr('rel');
		
		$(".pmList").hide();
		$("#" + id).show();
		
		$("a.showHide").removeClass('selected');
		$(this).addClass('selected');
		
		return false;
		
	});
	
	if(!Modernizr.input.placeholder){
		$('[placeholder]').focus(function() {
			var input = $(this);
			if (input.val() == input.attr('placeholder')) {
				input.val('');
				input.removeClass('placeholder');
			}
			}).blur(function() {
				var input = $(this);
				if (input.val() == '' || input.val() == input.attr('placeholder')) {
				input.addClass('placeholder');
				input.val(input.attr('placeholder'));
			}
		}).blur();
		$('[placeholder]').parents('form').submit(function() {
			$(this).find('[placeholder]').each(function() {
				var input = $(this);
				if (input.val() == input.attr('placeholder')) {
					input.val('');
				}
			})
		});
	}
	
});
