var myTimer;
var imageIsLoading = false;
var hoverImage;

$('jimagediv');



function dispImg(urlIn, imgId)
{
	$('parent-'+imgId).innerHTML = "<img src='"+urlIn+"' width='300' height='400' />";
	$('parent-'+imgId).style.display = "block";
}

function returnImg(imgId)
{
	$('parent-'+imgId).style.display = "none";
}


// Show image links
function showLinkingCodes(imageId, check)
{
	if (check == "") check = 0;

	var pageUrl = "http://www.morphthing.com/image/"+imageId;

	var fullUrl = "http://www.morphthing.com/showimage/2/"+check+"/0/"+imageId+"/pic.jpeg";
	var thumbUrl = "http://www.morphthing.com/showimage/1/"+check+"/0/"+imageId+"/pic.jpeg";;

	Modalbox.show("<div id='linkingcodes'><div class='left'>Link to this page</div><div class='right'><input type='text' value='"+pageUrl+"' /></div><div class='left'>Direct link to image</div><div class='right'><input type='text' value='"+fullUrl+"' /></div><div class='left'>Thumbnail for forums</div><div class='right'><input type='text' value='[URL="+pageUrl+"][IMG]"+thumbUrl+"[/IMG][/URL]' /></div><div class='left'>Full image for forums</div><div class='right'><input type='text' value='[URL="+pageUrl+"][IMG]"+fullUrl+"[/IMG][/URL]' /></div></div>",



	{title: "Linking Codes", width: 360});
}


$('linkContent');
$('socialContent');
$('emailContent');

function tabSelect(tab)
{
	var tabsList = document.getElementById("mtTabsList");

	$('linkContent').style.display = "none";
	$('socialContent').style.display = "none";
	$('emailContent').style.display = "none";


	for (var i=0; i<tabsList.childNodes.length; i++)
	{
		if (tabsList.childNodes[i].nodeName == "LI")
		{
			if (tabsList.childNodes[i].id == tab+"Tab")
			{
				tabsList.childNodes[i].setAttribute("class", "active");
				tabsList.childNodes[i].setAttribute("className", "active");
				$(tab+'Content').style.display="block";
			}
			else
			{
				tabsList.childNodes[i].setAttribute("class", "");
				tabsList.childNodes[i].setAttribute("className", "");
			}
		}
	}

	$('shareTabContent');
}


$('wildfireContent');
var fullSelected = 1;

function socialImageChange()
{
	if (fullSelected==1)
	{
		$('wildfireContent').innerHTML = thumbImageUrl;
		fullSelected = 0;
	}
	else
	{
		$('wildfireContent').innerHTML = fullImageUrl;
		fullSelected = 1;
	}
//	Wildfire.divWildfirePost.applyConfig(pconf);
}

function addFavorite(im, imageCheck, type)
{
	startRequest("image", "imageId="+im+"&operation=addFavorite"+"&imageCheck="+imageCheck+"&type="+type);
	//Effect.Pulsate('addToFavorites', { pulses: 1, duration: 0.5 });
}





function imageRating(e)
{
	mousePos = getMousePosition(e, 'ratingDiv');

	rating = Math.round(0.8+5*(mousePos[0]-13)/107);

	$('ratingFill').style.width = ((rating/5)*100)+"%";
	$('ratingFill').style.backgroundColor = "green";
	$('ratingDiv').onclick = "";

	startRequest("rating", "imageId="+imageId+"&rating="+rating+"&check="+imageCheck);

}


function fbs_click() {
	startRequest("clickSplits", "");
	u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}

function GetThis(T, C, U, L)
{
	var targetUrl = 'http://www.myspace.com/index.cfm?fuseaction=postto&' + 't=' + encodeURIComponent(T)
	+ '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) + '&l=' + L;
	window.open(targetUrl);
}