// JavaScript Document

function showPicture(pId)
{
//alert(pId);
/*
	currentRoom = currentRoom > room ? currentRoom : room;
	currentCrib = currentCrib > crib ? currentCrib : crib;
*/	
//	alert(pId + " " +currentCrib + " " + currentRoom);	
	if (document.getElementById('imgThumbs').style.display == 'block'){
		document.getElementById('imgThumbs').style.display = 'none';
		document.getElementById('imgFullsize').style.display = 'block';
	}  
	
/*	var data = ' +
               '<div id="newCribs imagesTable fullImgTable">" +
               '<h1>Duschhörnanmassamer...</h1>  <p class="datum bigSmall"><strong><a href="#" title="Prev">< Föregående</a> / <a href="#" title="Nästa">Nästa ></a></strong></p>" +
               '    <div class="bigImgHolder fullImg">" +
               '    <a href="/defender/nästabild"><img src="http://www.cribdisplay.com/showpicture.php?picture=5579290&size=large" title="Users hem" /></a>" +
               '        <div class="fullImgInfo">" +
                       <p class="imageText">Uppladdad 12 nov 09 kl 14:34</p> " +
                       <h2>Hör skrivs den beskrivande texten ut, fint fint värre. Jalle jalla. Incentive baaads asdjd asdjdf  fdjf dsf jdfs ." +
                       Hör skrivs den beskrivande texten ut, fint fint värre. Jalle jalla. Incentive baaads asdjd asdjdf  fdjf dsf jdfs .</h2>" +
                       <p class="latestComments">" +
                       <strong><span class="pink">Taggar</span></strong><br />" +
                       <a href="#" title="Lampa">lampa</a>, <a href="#" title="Lampa">magnet</a>" +
               "        </p>" +
               "        </div>" +
               "    </div>" +
               "</div>";
*/	
	$.post('/site/php/action.php', { pId: pId, currentRoom: currentRoom, currentCrib: currentCrib, action: "showFullSizePicture" }, function(data) {
		var response = data.split(":::::::::::::");
		$('#imgFullsize').html(response[0]);
	  	$('#cribInspire').html(response[1]);
//		alert(response[0]);
		
	});

/*
	var picFirst = fileId;
	var picLast = fileId;
	var picNum = 0; // antal bilder i rum/crib
	
	for ( var i in pictures )
	{
		if (pictures[i]['pRoomId'] == currentRoom || currentRoom < 0){
			picNum++;
//			alert( pictures[i]['pId'] );
		}
	}

	
	var data = ' '+
               '<div id="newCribs imagesTable fullImgTable">' +
               '<h1>'+pictures[fileId]["pTitle"]+'</h1>  <p class="datum bigSmall"><strong><a href="#" title="Prev">< Föregående</a> / <a href="#" title="Nästa">Nästa ></a></strong></p>' +
               '    <div class="bigImgHolder fullImg">' +
               '    <a href="/defender/nästabild"><img src="/picture/' + pictures[fileId]["pOwnerUsername"] + '/large/'+pictures[fileId]["pFilename"]+'" title="Users hem" /></a>' +
               '        <div class="fullImgInfo">' +
               '        <p class="imageText">Uppladdad '+pictures[fileId]["lastUpdate"]+' <!--12 nov 09 kl 14:34 --></p> '+
               '        <h2>'+pictures[fileId]["pDesc"]+'</h2> ' +
               '        <p class="latestComments">' +
               '        <strong><span class="pink">Taggar</span></strong><br />' +
               '        <a href="#" title="Lampa">lampa</a>, <a href="#" title="Lampa">magnet</a>' +
               '        </p>' +
               '        </div>' +
               '    </div>' +
               '</div>';
	
	$('#imgFullsize').html(data);
*/


/*
   $("#imgThumbs").fadeOut('slow'); // This sets the opacity of the thumbs to fade down to 30% when the page loads
   $(".latest_img").hover(function(){
   $(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
   },function(){
   $(this).fadeTo("slow", 0.3); // This should set the opacity back to 30% on mouseout
   });
*/   

/*	
	$('#imgThumbs').fadeOut('slow');
	if ($('#imgThumbs').is(':animated'))
	{
	}
	else
	{
	$('#imgFullsize').fadeIn('slow');
	}
	
	
//	$('#imgThumbs').css({display: 'none'});
/*	$(document).ready(function(){

	$('#imgThumbs').fadeOut('slow');
							   });
	
	$(document).ready(function(){

	$('#imgFullsize').fadeIn('slow');
							   });
	*/
//	alert(filename);
}



function getPictureComments(pId,offset,currentPic){
//	alert('ok');
	$.post('/site/php/action.php', { pId: pId, offset: offset,currentPic:currentPic, currentRoom: currentRoom, currentCrib: currentCrib, action: "getPictureComments" }, function(data) {
	  	$('#cribInspire').html(data);	
	});
} 

function givePoints(result){
	if(allreadyVoted==false){
		$.post('/site/php/action.php', { currentCrib: currentCrib, result: result, action: "givePoints" }, function(data) {
			$('#cribPoints').html(data);	
		});
		allreadyVoted=true;
	}
	else{
		alert('You have allready voted on this crib.');
	}
	
}
var allreadyVoted=false;
