// JavaScript Document
$(document).ready(function() {


	

	
	
	
});


function loadFileList(pageNo){
	$('#thumbs').block({ message: '<img src="images/ajax-loader.gif"  />', css : { border: 'none'} });
	$.post(appUrl+"imageList.ajax.php",	{page: pageNo, mode:'load', categoryId:categoryId},
		function(data){
			var strHTML = '';
			var fileList = data.fileList;
			var numpad = data.numPad;
			var popSource='';
			var title;
			//alert(fileList+' - '+categoryId);
			if(fileList!=null){
				if (fileList.length > 0){
				for(i = 0; i < fileList.length; i++){
					if(fileList[i].image_url){
						popSource =  fileList[i].image_url;
					}else {
						popSource =  appUrl+'main_image/'+fileList[i].unified_image_name+'?parameter=value&width=512&height=288';
					}
					title = fileList[i].title;
					strHTML += '<li><a rel="prettyPhoto[mixed]" href="'+popSource+'" class="thumb" title="'+title+'" ><img src="thump_image/'+fileList[i].thumb_image_name+'" width="60" height="56" /></a></li>';
				}
				}
			}
			if(numpad==null){numpad = '';}
			$(".thumbs").html('');
			$("#numberPad").html(numpad);
			$(".thumbs").html(strHTML);			
			var t=setTimeout("fadeout()",10);
			$('#thumbs').unblock();
			// $("a[rel^='prettyPhoto']").prettyPhoto();
			pretty();	
		}, "json"
	);
	
	return false;
}

function fadeout(){
	var onMouseOutOpacity = 0.6;
	$('#thumbs ul.thumbs li').opacityrollover({
		mouseOutOpacity:   onMouseOutOpacity,
		mouseOverOpacity:  1.0,
		fadeSpeed:         'fast',
		exemptionSelector: '.selected'
	});
}

function fadeoutPersonal(){
	var onMouseOutOpacity = 0.6;
	$('#thumbs ul.personal li').opacityrollover({
		mouseOutOpacity:   onMouseOutOpacity,
		mouseOverOpacity:  1.0,
		fadeSpeed:         'fast',
		exemptionSelector: '.selected'
	});
}


function loadPortfolioAssets(catId){
	categoryId = catId;
	loadCategoryDescription();
	loadFileList(1);
	return false;
}	

function loadCategoryDescription(){
	$.post(appUrl+"imageList.ajax.php",	{mode:'loadDesc', categoryId:categoryId},
			function(data){
				$("#workTitle").html(data[0]["category"]);	
				$("#catDescr p").html(data[0]["category_description"]);	
				
			}, "json"
		);
}

function pretty(){
	$("a[rel^='prettyPhoto']").prettyPhoto({	
			image_markup: '<img id="fullResImage" src="{path}" />',
			flash_markup: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}" /><embed src="{path}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',
			quicktime_markup: '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="{height}" width="{width}"><param name="src" value="{path}"><param name="autoplay" value="{autoplay}"><param name="type" value="video/quicktime"><embed src="{path}" height="{height}" width="{width}" autoplay="{autoplay}" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>',
			iframe_markup: '<iframe src ="{path}" width="{width}" height="{height}" frameborder="no"></iframe>',
			inline_markup: '<div class="pp_inline">{content}</div>',
			custom_markup: '',
			deeplinking: false,
			social_tools:''
										   
	});									   
}


function prettyPersonal(){
	$("a[rel^='prettyPhotoPersonal']").prettyPhoto({	
			image_markup: '<img id="fullResImage" src="{path}" />',
			flash_markup: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}" /><embed src="{path}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',
			quicktime_markup: '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="{height}" width="{width}"><param name="src" value="{path}"><param name="autoplay" value="{autoplay}"><param name="type" value="video/quicktime"><embed src="{path}" height="{height}" width="{width}" autoplay="{autoplay}" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>',
			iframe_markup: '<iframe src ="{path}" width="{width}" height="{height}" frameborder="no"></iframe>',
			inline_markup: '<div class="pp_inline">{content}</div>',
			custom_markup: '',
			deeplinking: false,
			social_tools:''
	});									   
}



function showMediumImage(imageUrl,id){
	if ($("#dailyDoseThumb").length > 0 ) {
		$('#mediumWraper').block({ message: '<img src="images/ajax-loader.gif"  />', css : { border: 'none'} });
		$("#dailyDoseMedium").attr("src", imageUrl);
		$("#dailyDesc").html($("#des_"+id).html());
		var str = '&nbsp;<br/><a class="readmore" id="dailyUrl" href="'+$("#des_link"+id).html()+'" target="_blank">Read more</a>';
		$("#dailyDesc").append(str);
		
		$("#dailyUrl").removeAttr("href");
		$("#dailyUrl").attr("href", $("#des_link"+id).html());
		$("#dailyUrl").attr("title", $("#des_link"+id).html());
		
		$('#mediumWraper').unblock();
		return false; 
	}
}

function loadPersonalFileList(pageNo){
	$('#thumbs2').block({ message: '<img src="images/ajax-loader.gif"  />', css : { border: 'none'} });
	$.post(appUrl+"imageList.ajax.php",	{page: pageNo, mode:'loadPersonal'},
		function(data){
			var strHTML = '';
			var fileList = data.fileList;
			var numpad = data.numPad;
			var popSource='';
			var title;
			if(fileList.length > 0){
				for(i = 0; i < fileList.length; i++){
					if(fileList[i].image_url){
						popSource =  fileList[i].image_url;
					}else {
						popSource =  appUrl+'main_image/'+fileList[i].unified_image_name+'?parameter=value&width=512&height=288';
					}
					title = fileList[i].title;
					strHTML += '<li><a rel="prettyPhotoPersonal[mixed]" href="'+popSource+'" class="thumb" title="'+title+'" ><img src="thump_image/'+fileList[i].thumb_image_name+'" width="60" height="56" /></a></li>';
				}
				
				
			}
			if(numpad==null){numpad = '';}
			$(".personal").html('');
			$("#numberPad2").html(numpad);
			$(".personal").html(strHTML);			
			var t=setTimeout("fadeoutPersonal()",10);
			$('#thumbs2').unblock();
			// $("a[rel^='prettyPhoto']").prettyPhoto();
			pretty();	
		}, "json"
	);
	
	return false;
	
}
