$(document).ready(function() {
	if($('#homepagelogobar').length){
		$('#homepagelogobar').cycle();
	}
	
	if($("a[rel^='prettyPhoto']").length){
		$("a[rel^='prettyPhoto']").prettyPhoto();
	}
	
	if($('#frmContact').length){
		$('#frmContact').validate({
			submitHandler: function() {
				$("#contactmsg").empty().html('<img src="/images/ajax-loader.gif" />');
				$.post("/common/script/contactform-handler.php", {name: $('#txtName').val(), email: $('#txtEmail').val(), phone: $('#txtPhone').val(), message: $('#taMsg').val()}, function(msg){
					$('#contactmsg').text(msg).show();
				});
			}
		});
	}
	
	if($('ul.sortablelist').length){
		$("ul.sortablelist").sortable({
			cursor: 'move',
			update: function(){
				var order = $(this).sortable("serialize");
				$.post("/common/script/order-gallery.php", order);
			}
		});
	}
	
	if($('#frmUpload').length){
		$('#frmUpload').validate({
			rules: {
				'uploadpwd': {
					required: true,
					remote: '/common/script/chkupper.php'
				}
			},
			messages: {
				'uploadpwd': 'That is not the correct password'	
			},
			submitHandler: function() {
				$('#file_upload').uploadifyUpload();
			}
		});
		
		$('#file_upload').uploadify({
				'uploader'  : '/common/script/uploadify/uploadify.swf',
				'script'    : '/common/script/uploadify/uploadify.php',
				'cancelImg' : '/common/script/uploadify/cancel.png',
				'folder'    : '/uploads',
				'removeCompleted' : false,
				'multi'		: true
//				'onError'   : function (event,ID,fileObj,errorObj) {
//					alert(errorObj.type + ' Error: ' + errorObj.info);
//				}
		});
	}
});

function confirmDelete(){
	var agree=confirm("Are you sure you want to delete this item?");
	if (agree)
		return true ;
	else
		return false ;
}
