var name;
function b(){
alert("Nomi kesa he");
$(function() {
			// there's the gallery and the trash
			var $gallery = $('#gallery'), $trash = $('#trash');

			// let the gallery items be draggable
			$('li',$gallery).draggable({
				cancel: 'a.ui-icon',// clicking an icon won't initiate dragging
				revert: 'invalid', // when not dropped, the item will revert back to its initial position
				containment: $('#demo-frame').length ? '#demo-frame' : 'document', // stick to demo-frame if present
				helper: 'clone',
				cursor: 'move'
			});

			// let the trash be droppable, accepting the gallery items
			$trash.droppable({
				accept: '#gallery > li',
				activeClass: 'ui-state-highlight',
				drop: function(ev, ui) {
					deleteImage(ui.draggable);
				}
			});

			// let the gallery be droppable as well, accepting items from the trash
			$gallery.droppable({
				accept: '#trash li',
				activeClass: 'custom-state-active',
				drop: function(ev, ui) {
					recycleImage(ui.draggable);
				}
			});

			// image deletion function
			var recycle_icon = '<a href="link/to/recycle/script/when/we/have/js/off" title="Recycle this image" class="ui-icon ui-icon-refresh">Recycle image</a>';
			function deleteImage($item) {
			
				$item.fadeOut(function() {
					var $list = $('ul',$trash).length ? $('ul',$trash) : $('<ul class="gallery ui-helper-reset"/>').appendTo($trash);

					$item.find('a.ui-icon-trash').remove();
					$item.append(recycle_icon).appendTo($list).fadeIn(function() {
						$item.animate({ width: '48px' }).find('img').animate({ height: '36px' });
						alert(name);
					});
				});
			}

			// image recycle function
			var trash_icon = '<a href="link/to/trash/script/when/we/have/js/off" title="Delete this image" class="ui-icon ui-icon-trash">Delete image</a>';
			function recycleImage($item,$link) {
			
				$item.fadeOut(function() {
					$item.find('a.ui-icon-refresh').remove();
					$item.css('width','96px').append(trash_icon).find('img').css('height','72px').end().appendTo($gallery).fadeIn();
					
				});
			}

			// image preview function, demonstrating the ui.dialog used as a modal window
			function viewLargerImage($link) {
				var src = $link.attr('href');
				alert(src);
				var title = $link.siblings('img').attr('alt');
				var $modal = $('img[src$="'+src+'"]');

				if ($modal.length) {
					$modal.dialog('open')
				} else {
					var img = $('<img alt="'+title+'" width="384" height="288" style="display:none;padding: 8px;" />')
						.attr('src',src).appendTo('body');
					setTimeout(function() {
						img.dialog({
								title: title,
								width: 400,
								modal: true
							});
					}, 1);
				}
			}

			// resolve the icons behavior with event delegation
			$('ul.gallery > li').click(function(ev) {
				var $item = $(this);
				var $target = $(ev.target);

				if ($target.is('a.ui-icon-trash')) {
					deleteImage($item);
				} else if ($target.is('a.ui-icon-zoomin')) {
					viewLargerImage($target);
				} else if ($target.is('a.ui-icon-refresh')) {
					recycleImage($item);
				}

				return false;
			});
		});
		}
	


	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	function lookup(inputString,flag) {
		
		if(inputString.length == 0) {
			// Hide the suggestion box.
			$('#suggestions').hide();
		} else {
			$.post("../BL/rpc.php", {queryString: ""+inputString+"",fg:flag}, function(data){
				if(data.length >0) {
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
				}
			});
		}
	} // lookup
	
	function fill(thisValue) {
		$('#inputString').val(thisValue);
		setTimeout("$('#suggestions').hide();", 200);
	}
	function a(url){
		
		name=url;
	}
	

	function initMenu1() {
			
		$('#gallery a').lightBox();
		
	}
    function initMenu() {
    //$('#menu1 ul').hide();
    $('#menu1 li a').click(
    function() {
    $(this).next().slideToggle('slow');
    }
    );
    }
    $(document).ready(function() {initMenu();})
	
function change_profile_pic(url){
	$.post(url,function(data)
	{
		
		document.getElementById("mainbody").innerHTML=data;
	});
}
function loadPage(url)
{
	alert(url);
	$.post(url,function(data)
	{
		alert(data);
		document.getElementById("mainbody").innerHTML=data;
	});
}
function search(flag)
{
	un=document.getElementById("inputString").value;
	$.post("../BL/search.php",{un:un,flag:flag},function(data)
	{		
		
		document.getElementById("mainbody").innerHTML=data;
	});
}
function viewalbum(){
	an=document.getElementById("album").value;	
	$.post("viewalbum.php",{an:an},function(data)
	{
		document.getElementById("mainbody").innerHTML=data;
	});
}
function validate()
{
	alert(document.getElementById("album1").value+"  =  "+document.getElementById("album2").value)
	if(document.getElementById("album2").value==document.getElementById("album1").value)
	{
		alert("Please Select Different Name");
		return false;
	}
	else 
		return true;
}
function delalbum(url){
	an=document.getElementById("album").value;	
	$.post(url,{an:an},function(data)
	{
		document.getElementById("mainbody").innerHTML=data;
	});
}
function updatepro()
{
	un=document.getElementById("username").value;
	pw=document.getElementById("password").value;
	fn=document.getElementById("fname").value;
	ln=document.getElementById("lname").value;
	
	m=document.getElementById("mail").value;
	loc=document.getElementById("loc").value;
	
	$.post("../BL/updatepro.php",{un:un,pw:pw,fn:fn,ln:ln,m:m,loc:loc},function(data)
	{
		
		document.getElementById("mainbody").innerHTML=data;
	});
}
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Functions for Comment>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
var i=0;
function insertComment(un,img){
	
	picN=document.getElementById('bigpic').src ;
	an=document.getElementById('bigpic').value ;
	if(picN=="nomi")
	{
		alert("Select Picture...");
		return ;
	}
	
	
	var cObj = document.getElementById("lis");
	var newElement = document.createElement("li");
	newElement.id = "newChild_"+i;	
	/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Insert Comment In DB>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
	picN=document.getElementById('bigpic').src ;
	an=document.getElementById('bigpic').value ;
	add_comment_indb(picN,an,document.getElementById("df").value,i);
	/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Insert Comment In DB>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
	newElement.innerHTML = "<div id='scomment'><div id='spic'><img src='../images/"+img+"' width='67px' height='67px'/></div><div id='vcomment'><p><u>"+un+"</u><br />"+document.getElementById("df").value+"</p></div>";
	i++;
	document.getElementById("df").value="";
	cObj.insertBefore(newElement, cObj.firstChild);
}
function add_comment_indb(pn,an,comment,did)
{
	
	$.post("../BL/add_comment.php",{an:an,pn:pn,comment:comment,did:did},function(data){
	
	});
}
function del_cm_fromdb(id)
{
	
	$.post("../BL/del_cm_fromdb.php",{id:id},function(data){
	
	});
}
function deleteChild(child){
	
	del_cm_fromdb(child);
	picN=document.getElementById('bigpic').src ;
	an=document.getElementById('bigpic').value ;
	if(picN=="nomi")
	{
		alert("Select Picture...");
		return ;
	}
	
	
	var cObj = document.getElementById("comment2");
	var ch = document.getElementById("del"+child);
	cObj.removeChild(ch);
}
function delcomment(un)
{
	
	picN=document.getElementById('bigpic').src ;
	an=document.getElementById('bigpic').value ;
	$.post("../BL/delcomment.php",{an:an,picN:picN,un:un},function(data)
	{
		document.getElementById("lis").innerHTML=data;
	});
}
function view_comments()
{
	picN=document.getElementById('bigpic').src ;
	an=document.getElementById('bigpic').value ;
	
	if(picN!="nomi")
	{
		$.post("../BL/view_comments.php",{an:an,picN:picN},function(data){
		document.getElementById("lis").innerHTML=data;
		});
	}
	else 
	{
		alert("Select Picture...");
		return ;
	}
}
function loadbigPic(pn,un,img,an)
{

	
	document.getElementById('bigpic').src= "../images/"+pn;
	document.getElementById('bigpic').value= an;
	$('#comment').html("<textarea id='df' rows='' cols='40' name='df'></textarea><br><input type='button' id='button1' value='Add Comment' onclick='insertComment(\""+un+"\",\""+img+"\");' /><input type='button' id='button1' value='Delete Comment' onclick='delcomment(\""+un+"\");' /><input type='button' id='button1' value='View Comments' onclick='view_comments();' /><ul id='lis'></ul>");

}
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Functions for Comment>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Functions for During Multi upload seve in Db Also>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
function upl(fn)
{
	
	$.post("../BL/pic_upload.php",{fn:fn},function(data)
	{
		
	});
}	
	
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Functions for During Multi upload seve in Db Also>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

function create_album()
{
	un=document.getElementById("username").value;
	an=document.getElementById("aname").value;
	ds=document.getElementById("desc").value;
	vc=document.getElementById("vc").value;
	
	$.post("../BL/create_album.php",{un:un,an:an,ds:ds,vc:vc},function(data)
	{
		
		document.getElementById("mainbody").innerHTML=data;
	});
}
