// remap jQuery to $
(function($){})(window.jQuery);


/* trigger when page is ready */
$(document).ready(function (){
	setTimeout(topCaption('usrHdr','in'),7500);
});


/* optional triggers

$(window).load(function() {
	
});

$(window).resize(function() {
	
});

*/

function topCaption(id,method)
	{
		if(method == 'in')
		{
			document.getElementById(id).style.marginTop = '-10px';
		}
		if(method == 'out')
		{
			document.getElementById(id).style.marginTop = '-30px';
		}
	}
		
function bottomCaption(id,method,color)
	{
		if(method == 'in')
		{
			document.getElementById(id).style.display = 'block';
			document.getElementById(id).style.backgroundColor = color;
			document.getElementById(id).style.opacity = '.975';
		}
		if(method == 'out')
		{
			document.getElementById(id).style.display = 'none';
		}
	}
		
function rightCaption(id,method)
	{
	}
		
function leftCaption(id,method)
	{
	}

function popOverWindow(url,method)
{
	if(method == 'in')
	{
		var mastery_list = ' ';
		document.getElementById('popover').style.display = 'block';
		document.getElementById('popover').style.marginTop = '750px';
			if(url == '/wp-content/themes/fshanbl/img/promo/wp-mm-sushi-sensei.png')
			{
				mastery_list = 'sushi';
			}
			else
			{
				mastery_list = 'maki';
			}
		document.getElementById('popover').innerHTML = '<Center><div style = "margin-bottom: -130px;"><table><tr><td><img src = \''+ url +'\' style = "margin-bottom: -25px;"></td></tr><tr><td style = "color: #ccc; padding: 10px; font-style: italic;">you have finished:</td></tr><tr><td style = "font-size: 18px; color: #ccc; font-style: italic; width: 500px;"><div id = "the_list"></div></span></td></tr></table></div><br/><span style = "font-size: 25px; font-style: italic;"><br/><a href = "javascript: popOverWindow(\'\',\'out\')">&raquo; click here to close</a></span></center>';
		ajaxMastery(mastery_list);
	}
	if(method == 'out')
	{
		document.getElementById('popover').style.display = 'none';
		document.getElementById('popover').innerHTML = '';
	}
}

function ajaxMastery(mastery_list)
{
	document.getElementById('the_list').innerHTML = '';
	document.getElementById('the_list').style.textAlign = 'justify';
		if(mastery_list)
		{
			if(window.XMLHttpRequest)
			{
				http_rq = new XMLHttpRequest();
			}
			else
			{
				http_rq = new ActiveXObject("Microsoft.XMLHTTP");
			}
				http_rq.onreadystatechange=function(){
					if(http_rq.readyState==4 && http_rq.status == 200)
					{
						var response = http_rq.responseText;
						parsedJSON = jQuery.parseJSON(response);
						if(parsedJSON)
						{
							for(i=0;i<=parsedJSON.length-1;i++)
							{
								if(i<parsedJSON.length-1)
								{
									document.getElementById('the_list').innerHTML += parsedJSON[i]+" | ";
								}
								else
								{
									document.getElementById('the_list').innerHTML += parsedJSON[i];
								}
							}
						} else {
							document.getElementById('the_list').innerHTML += "you have not started on this mastery yet!";
						}
					}
				}									
			http_rq.open("GET","/wp-content/themes/fshanbl/_/php/wp-mm-masteries.php?uid="+uid+"&mastery="+mastery_list,true);
			http_rq.send();
		}
	return parsedJSON;
}
