var usertype = 'student';
var yearbook = '';
var maxpages = 0;
var pag = 0;
// variable to ignore the click after drag in firefox
var click_drag;
var IE = document.all ? true : false;
var downx=0;
var downy=0;
var upx=0;
var upy=0;
function GetMousePosUp(){
	// If NS -- that is, !IE -- then set up for mouse capture
	if (!IE) 
		document.captureEvents(Event.MOUSEUP);
	
	// Set-up to use getMouseXY function onMouseMove
	document.onmouseup = getMouseXYup;
	
	// Temporary variables to hold mouse x-y pos.s
	upx = 0;
	upy = 0;
	
}
// Main function to retrieve mouse x-y pos.s
function getMouseXYup(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    upx = event.clientX + document.body.scrollLeft;
    upy = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    upx = e.pageX;
   	upy = e.pageY;
  }  
  // catch possible negative values in NS4
  if (upx < 0){upx = 0;}
  if (upy < 0){upy = 0;;}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY  
}

function GetMousePosDown(){
	// Detect if the browser is IE or not.
	// If it is not IE, we assume that the browser is NS.
	var IE = document.all ? true : false;
	
	// If NS -- that is, !IE -- then set up for mouse capture
	if (!IE) 
		document.captureEvents(Event.MOUSEDOWN);
	
	// Set-up to use getMouseXY function onMouseMove
	document.onmousedown = getMouseXYdown;
	
	// Temporary variables to hold mouse x-y pos.s
	downx = 0;
	downy = 0;
	
}
// Main function to retrieve mouse x-y pos.s
function getMouseXYdown(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    downx = event.clientX + document.body.scrollLeft;
    downy = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    downx = e.pageX;
    downy = e.pageY;
  }  
  // catch possible negative values in NS4
  if (downx < 0){downx = 0;}
  if (downy < 0){downy = 0;}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY  
}

function IgnoreClick(){
	if ((Math.abs(downx - upx) <= 5) && (Math.abs(downy - upy) <= 5)) {
		//alert(Math.abs(downx - upx));
		return 1;
	}
	else {
		click_drag = 1;
		return 0;
	}
}
function SelectGroup(sel){
	$j('#div_selgroup').html('<img src="_layouts/images/loading.gif">');
	$j('#div_selgroup').load('index.php?select_group='+sel);
}

// ================== Editor functions
function IncludeQuestionEd(index, check, user){
	ob = fieldOb('question_'+index);
	ob2 = fieldOb('check_' + index);
	// get the total chars left;
	maxlimit = $j('#formleftchars').attr('value');
	all_text = '';
	$j('form#formUserQ textarea').filter(filter_textarea).each(function(){
		all_text += $j(this).val();	
	});
	
	remaining_chars = parseInt(maxlimit) - all_text.length;
	
	var  ko = 1;
	if(check == 1) {
		//scad 100 din remaining_chars pt textul intrebarii
		temp = remaining_chars - 100;
		
		if (temp < 0) {
			
			ko = 0;
			alert('You reached the maximum limit of characters on your page. You can\'t include this question.');
			ob2.checked = false;
		}else{// intrebarea incape pe pagina
			
			$j('#formleftchars').attr('value', parseInt(maxlimit) - 100);
			$j('span#charsleft').html(temp);
		}
		
	}
	else if(check == 0) {
		//adun 100 la maxlimit
		temp = remaining_chars + 100;
		ko = 1;
		$j('#formleftchars').attr('value', parseInt(maxlimit) + 100);
		$j('span#charsleft').html(temp);
	}	
	if (ko == 1) {
		$j.post(HTTP + 'index.php?include_question=' + index + '&profile=' + user, 
		{mode: check, valoare: ob.value}, function(response){
			if (response) {
				alert(response);
			}
		})
	}
}

function DeleteQSet(id){
	
	$j.post(HTTP + 'index.php?delete_qset=' + id, 
	{}, function (response) {		
		if(response)
		if(response != 'The question set has been successfully deleted.') alert(response);	
		else location.reload();
	});
	
}
function DeletePoll(id){
	$j.post(HTTP + 'index.php?delete_poll=' + id, 
	{}, function (response) {		
		if(response)
		if(response != 'The poll has been successfully deleted.') alert(response);
		else document.location = HTTP + 'polls.html';
	})	
}
function RemoveSubeditor(id){
	$j.post(HTTP + 'index.php?delete_subeditor=' + id, 
	{}, function (response) {
		if(response) alert(response);
	})
	document.location = HTTP + 'index.php?subeditors';
}
function EnableSubeditor(id){
	$j.post(HTTP + 'index.php?enable_subeditor=' + id, 
	{}, function (response) {		
		if(response == '1') $j('#img_enable'+ id).html('<img src="_layouts/images/symbol_enabled.gif" width="14" alt="" border="0" />');
		else if(response == '0') $j('#img_enable'+ id).html('<img src="_layouts/images/symbol_disabled.gif" width="14" alt="" border="0" />');
		else if(response) alert(response);
	})
	//document.location = HTTP + 'index.php?user_manager#sub';
}

function DisplayHelp(sel){
	$j('#help').load(HTTP + 'index.php?show_help=' + sel);
}
function RestoreHelp(){
	$j('#help').load(HTTP + 'index.php?show_help=restore');
}
function ListSection(index, start, id){
	
	if (index != 0) {
	//	$j('#section_pages').html('<div align="center" style="padding-top: 100px;"><img src="_layouts/images/loading.gif"></div>');
		$j('#item_selected').load(HTTP + 'index.php?section_selected=' + index + '&start=' + start);
	//	$j('#section_pages').load(HTTP + 'index.php?list_section=' + index + '&start=' + start);
	}else{
		$j('#section_pages').html('');
		$j('#item_selected').load(HTTP + 'index.php?page_selected=' + id + '&start=' + start);
	}
}

function ListSelected(index, start){
	if(start == 0) start = '0';
	$j('#item_selected').load(HTTP + 'index.php?page_selected=' + index + '&start=' + start);
}
// ListTemplates - display the list of templates when a new type is selected
function ListTemplates(sel){
	$j('#template_det').html('');
	$j('#sele_template').html('<div align="center" style="width: 230px;"><img src="_layouts/images/loading.gif"></div>');
	$j('#sele_template').load(HTTP + 'index.php?list_templates=' + sel);
}
function AdminListTemplates(sel){
	$j('#sele_template').html('<div align="center" style="width: 230px;"><img src="_layouts/images/loading.gif"></div>');	
	$j('#sele_template').load(''+HTTP + 'admin.php?list_templates=' + sel+'');		
}

function AdminListTemplates_Edit(sel){
	$j('#sele_template').html('<div align="center" style="width: 230px;"><img src="_layouts/images/loading.gif"></div>');	
	$j('#sele_template').load(''+HTTP + 'admin.php?list_templates_edit=' + sel+'');		
}

function TemplateDetails(sel, type){
	// type = 2 - a profile template
	// type = 1 - other template
	$j('#template_det').html('<div align="center" style="padding-top: 45px;"><img src="_layouts/images/loading.gif"></div>');
	if(type == 1)
	$j('#template_det').load(HTTP + 'index.php?template_details=' + sel);
	else
	$j('#template_det').load(HTTP + 'index.php?template_details=' + sel +'&type=2');
}
function DeletePage(id){
	$j('#delete_message').html('');
	$j.post(HTTP + 'index.php?delete_page=' + id, 
	{}, function (response) {		
		if(response) 
			if(response != 'Page successfully deleted.')
				$j('#delete_message').html(response);
			else
				document.location = HTTP + 'index.php?page_manager';
	})
	//document.location = HTTP + 'index.php?page_manager';
}
function DeleteSection(id){
	$j.post(HTTP + 'index.php?delete_section=' + id, 
	{}, function (response) {		
		if(response)
			if(response != 'Section successfully deleted.')
				$j('#delete_message').html(response);
			else
				document.location = HTTP + 'index.php?page_manager';
		
	})
	//document.location = HTTP + 'index.php?page_manager';
}
function DeleteGroup(id){
	$j.post(HTTP + 'index.php?delete_group=' + id, 
	{}, function (response) {		
		if(response)
			if(response != 'The group has been successfully deleted.')
				alert(response);
			else
				location.reload();
		
	})	
}
function DeleteMember(id){
	$j.post(HTTP + 'editor/delete_member/' + id, 
	{}, function (response) {		
		if(response)
			if(response != 'The member has been successfully deleted.')
				alert(response);
			else{
				$j('#um_user_item'+id).remove();
			}
	});
}
function EdSelectPhoto(id, index){
	if (MONTAGE_PHOTO == 'select_user') {
		$j.post(HTTP + 'index.php?insert_user_photo=' + index, 
		{id: id}, function(response){
			if (response) {
				if (response != 'Photo successfully selected.') 
					alert(response);
				else {
					self.parent.tb_remove();
					self.parent.document.location = HTTP + 'edit_user_photos/0' + USERPROFILE_ID + '.html';
				}
			}
		})
	}else{
		$j.post(HTTP + 'index.php?insert_photo=' + index, 
		{id: id}, function (response) {
		if (response) {
			if (response != 'Photo successfully selected.') 
				alert(response);
			else {
				self.parent.tb_remove();
				self.parent.document.location = HTTP + 'user_photos/0' + USERPROFILE_ID + '.html';
			}
		}
	})
	}
	
	/*
	*/
}
// Select Photo for Montage Page
function EdSelectMPhoto(id, index){
	$j.post(HTTP + 'index.php?insert_montage_photo=' + index, 
	{id: id}, function (response) {
		if (response) {
			if (response != 'Photo successfully selected.') 
				alert(response);
			else {
				self.parent.tb_remove();
				self.parent.document.location = HTTP + 'edit_page/0' + PAGE_ID + '.html';
			}
		}
	})
	
}
function LockPage(id){
	sts = $j('#lock_link').html();	
	$j.post(HTTP + 'index.php?lock_page=' + id, 
	{ajaxlock: 1}, function (response) {
	if (response == 'ok') {
		if(sts == 'Lock Page'){
			$j('#lock_link').html('Unlock Page');
			$j('#lock_status').html('<span style="color: #FF0000; font-weight: bold;">Locked</span>');
		}else{
			$j('#lock_link').html('Lock Page');
			$j('#lock_status').html('Unlocked');
		}		
	}	
	})
}
function EnablePolls(){
	sts = $j('#polls_link').html();	
	$j.post(HTTP + 'index.php?enable_polls', 
	{}, function (response) {
	if (response == 'ok') {
		if(sts == 'Turn On'){
			$j('#polls_status').html('<span style="font-size: 13px; font-weight: bold; color: #008000;">On</span>');
			$j('#polls_link').html('Turn Off');
			
		}else{
			$j('#polls_status').html('<span style="font-size: 13px; font-weight: bold; color: #FF0000;">Off</span>');
			$j('#polls_link').html('Turn On');
			
		}
		
	}	
	})
}
function EnableComments(){
	sts = $j('#comments_link').html();
	
	$j.post(HTTP + 'index.php?enable_comments', 
	{}, function (response) {
	if (response == 'ok') {
		if(sts == 'Turn On'){
			$j('#comments_status').html('<span style="font-size: 13px; font-weight: bold; color: #008000;">On</span>');
			$j('#comments_link').html('Turn Off');
			
		}else{
			$j('#comments_status').html('<span style="font-size: 13px; font-weight: bold; color: #FF0000;">Off</span>');
			$j('#comments_link').html('Turn On');
			
		}
		
	}	
	})
}
function EdDeletePhoto(id){
	//alert('asdas');
	$j.post(HTTP + 'index.php?delete_photo=' + id, 
	{}, function (response) {
	if(response)
		if(response != 'The picture has been successfully deleted.')
			alert(response);	
	})
	var nr = parseInt($j('#selected_photos').html());
	clasa = $j('#photo_item' + id).attr('class');
	if (clasa.indexOf('ed_photo_item_over2') >= 0) {
		nr--;
		$j('#photo_item'+id).removeClass('ed_photo_item_over2');
	}
	if(nr == 0) nr = '0';
	$j('#selected_photos').html(nr);

	$j('#all_gallery').html('<div align="center" style="padding-top: 100px;"><img src="_layouts/images/loading.gif"></div>');
	$j('#all_gallery').load(HTTP + 'index.php?photo_gallery=-5&ajax=1&sort=1' + adress + '&pag=' + pag);
}
// ================= User functions
// delete photo
function DeletePhoto(id){
	$j.post(HTTP + 'index.php?delete_photo=' + id, 
	{}, function (response) {
	if(response)
		if(response != 'The picture has been successfully deleted.')
			alert(response);
	})
	$j('#all_gallery').html('<div align="center" style="padding-top: 100px;"><img src="_layouts/images/loading.gif"></div>');
	$j('#all_gallery').load(HTTP + 'index.php?photo_gallery=-1&ajax=1&sort=1' + adress + '&pag=' + pag);
}
function SelectPhoto(id, index){
	$j.post(HTTP + 'index.php?insert_photo=' + index, 
	{id: id}, function (response) {
		if (response) {
			if (response != 'Photo successfully selected.') 
				alert(response);
			else {
				self.parent.tb_remove();
				self.parent.document.location = HTTP + 'my_profile_page/03.html';
			}
		}
	})	
}
function MakePhotoMandatory(index, check){
	$j.post(HTTP + 'index.php?make_photo=' + index, 
	{make: check}, function (response) {
	 if(response) alert(response);
	})
}
function ShowStylePhoto(crt){
	$j.post(HTTP + 'index.php?show_style_photo=' + crt, 
	{}, function (response) {
	 if(response) $j('#current_pic').html(response);
	})
}
function GoToPage(page,address,maxpage){
	if(page < 0) page = 1;
	if(page > maxpage) page = maxpage;
	//alert(HTTP + address + '/pag/' + page);	
	pag = page;
	$j('#div_gallery').html('<div align="center" style="padding-top: 100px;"><img src="'+ HTTP +'_layouts/images/loading.gif"></div>');
	$j.get(HTTP + address + '/pag/' + page, {}, function(response) {
		$j('#div_gallery').html(response);
		SetSWFAddress('pag',page);
	});	
}
function GoToPageClassic(page,address,maxpage){
	if(page < 0) page = 1;
	if(page > maxpage) page = maxpage;
	pag = page;
	$j('#div_gallery').html('<div align="center" style="padding-top: 100px;"><img src="'+ HTTP +'_layouts/images/loading.gif"></div>');
	$j.get(HTTP + address + '&pag=' + page, {}, function(response) {
		$j('#div_gallery').html(response);		
	});	
}
function GetSWFAddress(address){	
	//alert(SWFAddress.getValue());
	var adr = SWFAddress.getValue();
	//alert(HTTP + address + adr);
	if(adr != '/'){
		//alert('mere');
		//alert(HTTP + address + adr);
		$j.get(HTTP + address + adr, {}, function(response) {
			$j('#div_gallery').html(response);		
		});
	}
}

function SetSWFAddress(item,value){
	var adr = SWFAddress.getValue();
	if(adr != '/'){		
		var vars = adr.split('/');
		var count;
		var count1;
		var flag=0;
		var flag1=0;
		
		if(item =='ord'){
			for (count = 0; count < vars.length; count++){
				if(vars[count] == 'pag'){
					count1 = count+1;
					vars[count1] = 1;
					flag1=1;
				}else if(vars[count] == 'user'){
					count1 = count+1;
					vars[count1] = 'all';
					flag1=1;
				}else if(vars[count] == 'ord'){
					count1 = count+1;
					vars[count1] = value;
					flag=1;	
				}
			}
		}else if(item =='user'){
			for (count = 0; count < vars.length; count++){
				if(vars[count] == 'pag'){
					count1 = count+1;
					vars[count1] = 1;
					flag1=1;
				}else if(vars[count] == 'ord'){
					count1 = count+1;
					vars[count1] = 1;
					flag1=1;
				}else if(vars[count] == 'user'){
					count1 = count+1;
					vars[count1] = value;
					flag=1;	
				}
			}
		}else if(item =='pag'){
			for (count = 0; count < vars.length; count++){
				if(vars[count] == 'pag'){
					count1 = count+1;
					vars[count1] = value;
					flag=1;	
				}
			}
		}		
		if(flag == 1){
			var new_adr = vars.join('/');
			SWFAddress.setValue(new_adr);
		}else if(flag1==1){
			var new_adr = vars.join('/');
			SWFAddress.setValue(new_adr+'/'+item+'/'+value);
		}else SWFAddress.setValue(adr+'/'+item+'/'+value);
	}else SWFAddress.setValue(item+'/'+value);
}
var adress = '';
var order = '';
function ComboAddedSelected(sel,album){
	if (sel != ''){
		adress = 'user/'+sel+'/'+order;
		$j('#div_gallery').html('<div align="center" style="padding-top: 100px;"><img src="'+ HTTP +'_layouts/images/loading.gif"></div>');
		$j.get(HTTP + 'photos/ajax_photo_gallery/'+album + '/ajax/1/sort/1/' + adress, {}, function(response){
			$j('#div_gallery').html(response);
			SetSWFAddress('user',sel);
		});
	}
}
function ComboUserSelected(sel, index){
	if (sel != '') {
		if (sel == 'all_users') 
			adress = adress + '&user=all';
		else 
			adress = adress + '&user=' + sel;
		$j('#all_gallery').html('<div align="center" style="padding-top: 100px;"><img src="_layouts/images/loading.gif"></div>');
		if (index == -1) {
			$j('#all_gallery').load(HTTP + 'index.php?photo_gallery=' + index + '&ajax=1&sort=1' + adress);
		}
		else if(index == -5){
			$j('#all_gallery').load(HTTP + 'index.php?photo_gallery=' + index + '&ajax=1&sort=1' + adress);
		}
		else if(index == -3){
			//$j('#admins').html('adafakfhjshgksgfg');
			//$j('#admins').load(HTTP + 'index.php?subeditor_admins=' + sel);
		}
		else {
			if(MONTAGE_PHOTO == 'montage')
			$j('#all_gallery').load(HTTP + 'index.php?montage_photo=' + index + '&ajax=1&sort=1' + adress);
			else if(MONTAGE_PHOTO == 'select_user')
			$j('#all_gallery').load(HTTP + 'index.php?select_user_photo=' + index + '&ajax=1&sort=1' + adress);
			else
			$j('#all_gallery').load(HTTP + 'index.php?select_photo=' + index + '&ajax=1&sort=1' + adress);
		}
	}else if(index == -3){
		alert('Please select a person!');
	}
}
var selected = '';
function OrderBy(sel, index){
	if (sel!=''){
		selected = sel;		
		order = '/ord/' + sel;
		$j('#div_gallery').html('<div align="center" style="padding-top: 100px;"><img src="'+ HTTP +'_layouts/images/loading.gif"></div>');
		
		if (index == -1) {
			$j('#div_gallery').load(HTTP + 'photos/ajax_photo_gallery/' + index + '/ajax/sort/1' + order);
		}else if(index == -5){
			$j('#div_gallery').load(HTTP + 'photos/ajax_photo_gallery/' + index + '/ajax/sort/1' + order);
		}
		else {			
			if(MONTAGE_PHOTO == 'montage')
			$j('#all_gallery').load(HTTP + 'index.php?montage_photo=' + index + '&ajax=1&sort=1' + adress);
			else if(MONTAGE_PHOTO == 'select_user')
			$j('#all_gallery').load(HTTP + 'index.php?select_user_photo=' + index + '&ajax=1&sort=1' + adress);
			else
			$j('#all_gallery').load(HTTP + 'index.php?select_photo=' + index + '&ajax=1&sort=1' + adress);
		}
	}
}
function DisplayUsedPhotos(usedphotos, index){
	
	$j('#all_gallery').html('<div align="center" style="padding-top: 100px;"><img src="_layouts/images/loading.gif"></div>');
	if(usedphotos == 1){
		adress = adress + '&unused=1';
		
	}else {
		adress = adress + '&unused=0';
	}	
	
	if(MONTAGE_PHOTO == 'montage')
		$j('#all_gallery').load(HTTP + 'index.php?montage_photo=' + index + '&ajax=1&sort=1' + adress);
	else if(MONTAGE_PHOTO == 'select_user')
		$j('#all_gallery').load(HTTP + 'index.php?select_user_photo=' + index + '&ajax=1&sort=1' + adress);
	else{
		
		$j('#all_gallery').load(HTTP + 'index.php?select_photo=' + index + '&ajax=1&sort=1' + adress);
	}
		
}
function votePhoto(id,rate){
	$j('#picture_' + id).load('index.php?vote=' + id + '&rate=' + rate);
}
function voteDetPhoto(id,rate){	
	$j('#picdetails2').load(HTTP + 'index.php?vote_details=' + id + '&rate=' + rate);
}
function VotePoll(id){
	$j('div.poll_voted_').html('');
	ob = fieldOb('combo_sel_'+id);
	if(ob.value == '') return;	
	$j.post(HTTP + 'polls/vote_poll/' + id,
	{choice: ob.value}, function (response) {
		if(response && response == 'Success!'){
			window.location.reload();
			$j('#butvoteclown_' + id).attr('value', 'Change Vote');
			$j('#poll_voted' + id).html('Vote cast!');
			$j('#poll_results' + id).load(HTTP+'polls/polls_top/' + id);
		}
	})
}
function UsePollChoices(sel){
	
	$j('form#formPoll input[@type=radio]').each(function(){
		if(this.value == sel)
			this.checked = true;
		else
			this.checked = false;
	});
}
function ImportCsv(sel){	
	$j('form#formAddMembers input[@type=radio]').each(function(){
		if(this.value == sel)
			this.checked = true;
		else
			this.checked = false;
	});
}
function AdminTotalChars(sel){
	$j('form#formTemplates input.totalchs').each(function(){
		if(this.value == sel)
			this.checked = true;
		else
			this.checked = false;
	});
}
function MessageEditor(subject,message){
	$j('#right_side').html('<img src="../_layouts/images/loading.gif" />');
	if(subject == ''){
		$j('#right_side').html('Write a subject!');
		return;
	}
	if(message == ''){
		$j('#right_side').html('Write a message!');
		return;
	}
	
	$j.post(HTTP + 'index.php?message_to_editor', 
	{message: message, subject: subject}, function (response) {
		if(response)
		if(response != 'Message sent!') $j('#right_side').html(response);
		else{
			$j('#right_side').html('<span style="color: #008000;">' + response + '</span>');
			$j('#subject').val('');
			$j('#message').val('');
		}
	})	
}
function EditComment(id){
	$j('#comment_content' + id).attr('style', 'border: 1px solid #333; width: 380px; float: left;');
	$j('#comment_link' + id).html('<a class="editor_link" onclick="saveComment('+ id +');" href="javascript:void(0);">save</a>&nbsp;&nbsp;');
	text = $j('#comment_text' + id).html();
	text = replaceChars(text, '<br>', '\n');
	text = replaceChars(text, '<BR>', '\n');
	$j('#comment_container' + id).html('<textarea class="text_area" name="commentcontent" id="commentcontent" style=" background: #fff; font-weight: normal;width: 300px; height: 45px;" >' + text + '</textarea>');
}
function saveComment(id){
	$j('#comment_content' + id).attr('style', 'width: 380px; float: left;');
	$j('#comment_link' + id).html('<a class="editor_link" onclick="EditComment('+ id +');" href="javascript:void(0);">edit</a>&nbsp;&nbsp;');
	text = $j('#commentcontent').val();
	text = replaceChars(text, '\n', '<br />');
	$j.post(HTTP + 'index.php?save_comment=' + id, 
	{message: text}, function (response) {		
		if(response)
		$j('#comment_container' + id).html(response);
	})	
	
}

function IncludeComment(id, mode){
	chars = parseInt($j('#comm_chars_left').html());
	text = $j('#comment_text' + id).html();
	author = $j('#comment_author' + id).html();
	text = replaceChars(text, '<br>', '\n');
	text = replaceChars(text, '<BR>', '\n');
	nr_chars = 0;
	
	$j.post(HTTP + 'index.php?include_comment=' + id, 
	{mode: mode}, function (response) {
		if(response)
			nr_chars = response;
			//alert(nr_chars);
			
			ob = fieldOb('includecomment'+id);
			
			
			if (mode == 1) {
				chars = chars - text.length;
				chars = chars - author.length;
				if(nr_chars == 1)
					chars = chars - 100;
				if (chars < 0) {
					alert('You don\'t have enough space on your page!');
					ob.checked = false;
					$j.post(HTTP + 'index.php?include_comment=' + id, 
					{mode: 0}, function (response) {
						
					})
					return;
				}
				
				if(chars == 0) chars = '0';
				$j('#comm_chars_left').html(chars);
			
			}else if(mode == 0){
				chars = chars + text.length;
				chars = chars + author.length;
				if(nr_chars == -1)
					chars = chars + 100;
				$j('#comm_chars_left').html(chars);
			}
	
	})
	
	
}
function EditorIncludeComment(id, mode, theuser){
	chars = parseInt($j('#comm_chars_left').html());
	text = $j('#comment_text' + id).html();
	author = $j('#comment_author' + id).html();
	text = replaceChars(text, '<br>', '\n');
	text = replaceChars(text, '<BR>', '\n');
	nr_chars = 0;
	$j.post(HTTP + 'index.php?include_comment=' + id, 
	{mode: mode, theuser: theuser}, function (response) {
		if(response)
			nr_chars = response;
			//alert(nr_chars);
			ob = fieldOb('includecomment'+id);
			if (mode == 1) {
				chars = chars - text.length;
				chars = chars - author.length;
				if(nr_chars == 1)
					chars = chars - 100;
				if (chars < 0) {
					alert('You don\'t have enough space on your page!');
					ob.checked = false;
					$j.post(HTTP + 'index.php?include_comment=' + id, 
					{mode: 0, theuser: theuser}, function (response) {
					})
					return;
				}
				if(chars == 0) chars = '0';
				$j('#comm_chars_left').html(chars);
			
			}else if(mode == 0){
				chars = chars + text.length;
				chars = chars + author.length;
				if(nr_chars == -1)
					chars = chars + 100;
				$j('#comm_chars_left').html(chars);
			}
	})
}
//function LogoutF(){
//	FB.ensureInit( function () { FB.Connect.logoutAndRedirect("?logout"); }); return false;
//}
function FinishCategory(sel){
	$j('#to_do_list').html('<div align="center" style="padding-top: 100px;"><img src="_layouts/images/loading.gif"></div>');
	$j('#to_do_list').load(HTTP + 'index.php?finish_category=' + sel);
/*	$j.post(HTTP + 'index.php?finish_category=' + sel, 
		{}, function (response) {
			
		})*/
}
function MoveToSection(sel, thepage){
	$j.post(HTTP + 'index.php?move_to_category=' + sel, 
		{pageid: thepage}, function (response) {
			if (response) 
				if (response != 'success') 
					alert(response);
				else {
					if(sel != 0)
					document.location = 'index.php?page_manager&section=' + sel +'&selected_page=' + thepage;
					else
					document.location = 'index.php?page_manager&section=' + sel +'&page=' + thepage;
				}
		});
}
function SelectFacebookDiv(pid){
	ob = fieldOb('select_'+pid);
	if (ob.checked) {
		SelectFacebookPhoto(pid, 0);
		ob.checked = false;
		$j('#photo_item'+pid).removeClass('ed_photo_item_over2');
	}else{
		SelectFacebookPhoto(pid, 1);
		$j('#photo_item'+pid).addClass('ed_photo_item_over2');
		ob.checked = true;
	}
}
function SelectFacebookPhoto(pid, mode){
	//alert(pid);
	ob = fieldOb('select_'+pid);
	nr_pics = parseInt($j('#nr_sel_pics').html());
	
	if (mode == 1) {
		nr_pics = nr_pics + 1;
	}
	else {
		nr_pics = nr_pics - 1;
	}
	if(nr_pics == 0 || nr_pics < 0)
		nr_pics = '0';
	$j('#nr_sel_pics').html(nr_pics);
	$j.post(HTTP + 'photos/?select_facebook_photo=' + pid, 
		{mode: mode}, function (response) {
			if (response)
				alert(response);
		});
}
function PhotoClicked(id){	
	clasa = $j('#but_batch').attr('class');	
	if(clasa == 'inputButton120_over'){
		var nr = parseInt($j('#selected_photos').html());
		if(nr>19) alert('You can select maxim 20 photos');
		else{ 
			$j.post(HTTP + 'photos/photo_clicked/' + id,
				{}, function (response) {
				if (response) 
					if (response == 'selected'){
						$j('#photo_item'+id).addClass('ed_photo_item_over2');
						nr++;
						if(nr == 0) nr = '0';
						$j('#selected_photos').html(nr);
					}else if (response == 'unselected'){
						$j('#photo_item'+id).removeClass('ed_photo_item_over2');
						nr--;
						if(nr == 0) nr = '0';
						$j('#selected_photos').html(nr);
					}else alert(response);
			});
		}
	}else{
		document.location=HTTP+'photos/view_photo/'+id;
	}
}
function SelectAllPhotos(){
	ob = fieldOb('photo_ids');
	
	//var ids = $j('#photo_ids').value;
	//alert(ob.value);
	ids = ob.value.split(',');
	//alert(ids.length);
	var nr = parseInt($j('#selected_photos').html());
	for (i = 0; i < ids.length; i++) {
		clasa = $j('#photo_item' + ids[i]).attr('class');
		if (clasa.indexOf('ed_photo_item_over2') < 0) {
			nr++;
			if(nr<20)
				$j('#photo_item'+ids[i]).addClass('ed_photo_item_over2');
			else{ 
				alert('You can select maxim 20 photos'); break;}
		}
	}
	if(nr == 0) nr = '0';
	$j('#selected_photos').html(nr);	
	$j.post(HTTP + 'photos/photo_clicked_all/' + ob.value, {}, function (response) {});
	
}
function SelectNoPhoto(){
	ob = fieldOb('photo_ids');	
	ids = ob.value.split(',');	
	var nr = parseInt($j('#selected_photos').html());	
	for (i = 0; i < ids.length; i++) {
		clasa = $j('#photo_item' + ids[i]).attr('class');
		if (clasa && clasa.indexOf('ed_photo_item_over2') >= 0) {
			nr--;
			$j('#photo_item'+ids[i]).removeClass('ed_photo_item_over2');
		}
	}
	if(nr == 0) nr = '0';
	$j('#selected_photos').html(nr);
	$j.post(HTTP + 'photos/photo_clicked_none/' + ob.value, 
		{}, function (response) {

		});
	
}
function ClearSelection(address){
	ob = fieldOb('photo_total_ids');	
	ids = ob.value.split(',');	
	var nr = parseInt($j('#selected_photos').html());	
	for (i = 0; i < ids.length; i++) {
		clasa = $j('#photo_item' + ids[i]).attr('class');
		if (clasa && clasa.indexOf('ed_photo_item_over2') >= 0) {
			nr--;
			$j('#photo_item'+ids[i]).removeClass('ed_photo_item_over2');
		}
	}
	if(nr == 0) nr = '0';
	$j('#selected_photos').html(nr);
	$j.post(HTTP + 'photos/photo_clicked_none/' + ob.value, 
		{}, function (response) {

		});
//	//alert(address);
//	$j('#selected_photos').html('0');
//	$j.post(HTTP + 'photos/photo_clicked_clear/', 
//		{}, function (response) {
//
//		});
//
//	window.location=HTTP + address;
	
//	$j('#div_gallery').html('<div align="center" style="padding-top: 100px;"><img src="'+ HTTP +'_layouts/images/loading.gif"></div>');
//	
//	$j.get(HTTP + address, {}, function(response) {
//		$j('#div_gallery').html(response);		
//	});
	
}

// admin jscript ================
function SetAddPhotos(){
	ob = fieldOb('add_pics');
	if (ob.value != '' && ob.value != 0) {
		$j('#div_set_photos').html('<div align="center" style="width: 250px;"><img src="_layouts/images/loading.gif" /></div>');
		$j('#div_set_photos').load(HTTP + 'admin.php?show_add_fields=' + ob.value);
		
	}else {
		alert('Enter the amount of additional pictures!');
	}
}
function HideComboTemplate(type){
	div = eval("document.getElementById('combo_template')");	
		if(type ==  'photo') div.className = 'hidden';
		if(type ==  'special') div.className = 'visibile';
		if(type ==  'profile') div.className = 'hidden';
}
function HideContentSubtypeTemplate(type){
	div_custom = eval("document.getElementById('content_custom')");
	div_polls = eval("document.getElementById('content_polls')");
	div_photo = eval("document.getElementById('content_photo')");
	div_profile = eval("document.getElementById('content_profile')");
	
	div_custom.className = 'hidden';
	div_polls.className = 'hidden';
	div_photo.className = 'hidden';
	div_profile.className = 'hidden';
	
	$j('#content_'+type).removeClass('hidden');
}
function RotatePhoto(){	
	$j.post(HTTP + 'photos/rotate_photo/' + page, {}, function(response) {
		$j('#div_gallery').html(response);		
	});
	$j('#div_gallery').html('<div align="center" style="padding-top: 100px;"><img src="'+ HTTP +'_layouts/images/loading.gif"></div>');
	$j.get(HTTP + address + '/pag/' + page, {}, function(response) {
		$j('#div_gallery').html(response);
	});
}
var selected = '';
function OrderAlbumsBy(sel){
	if (sel!=''){
		$j('#div_gallery').html('<div align="center" style="padding-top: 100px;"><img src="'+ HTTP +'_layouts/images/loading.gif"></div>');
		$j('#div_gallery').load(HTTP + 'photos/ajax_albums/ajax/1/ord/' + sel);
		SetSWFAddress('ord',sel);	
	}
}
function OrderPhotosBy(sel,album){
	if (sel!=''){		
		$j('#div_gallery').html('<div align="center" style="padding-top: 100px;"><img src="'+ HTTP +'_layouts/images/loading.gif"></div>');
		$j('#div_gallery').load(HTTP + 'photos/ajax_photo_gallery/'+album+'/ajax/1/ord/' + sel);
		SetSWFAddress('ord',sel);		
	}
}
function TimeOut(func){	
	 t = setTimeout(""+func+"", 100);		
}
function ChangePhoto(photo,album){
	if (photo!=''){
		$j('#album_photo').html('<div align="center" style="padding-top: 100px;"><img src="'+ HTTP +'_layouts/images/loading.gif"/></div>');
		$j('#album_photo').html('<img src="'+ HTTP +'upload/Yearbook_'+album+'/photos_small/'+photo+'"/>');
	}
}
function ButBatch(){
	clasa = $j('#but_batch').attr('class');	
	if(clasa == 'inputButton120_over'){
		ClearSelection();
		$j('#div_batch_photos').hide();
		$j('#but_batch').removeClass('inputButton120_over'); 
		$j('#but_batch').addClass('inputButton120');
		$j('#batch_text').removeClass(''); 
		$j('#batch_text').addClass('ascuns');
		$j('#batch_buttons').removeClass(''); 
		$j('#batch_buttons').addClass('ascuns');
	}else{		
		$j('#div_batch_photos').show();
		$j('#but_batch').removeClass('inputButton120'); 
		$j('#but_batch').addClass('inputButton120_over');
		$j('#batch_text').removeClass('ascuns'); 
		$j('#batch_text').addClass('');
		$j('#batch_buttons').removeClass('ascuns'); 
		$j('#batch_buttons').addClass('');
	}
}
function ButUpload(type){
	$j('#div_add_simple').addClass('ascuns');
	$j('#div_add_multiple').addClass('ascuns');
	$j('#div_add_facebook').addClass('ascuns');
	$j('#title_add1').addClass('ascuns');
	$j('#title_add2').addClass('ascuns');
	$j('#title_add3').addClass('ascuns');
	
	if(type==3){
		$j('#but_add1').removeClass('inputButton100_over'); 
		$j('#but_add1').addClass('inputButton100');
		$j('#but_add2').removeClass('inputButton120_over'); 
		$j('#but_add2').addClass('inputButton120');
		$j('#but_add3').removeClass('inputButton120'); 
		$j('#but_add3').addClass('inputButton120_over');
		
		$j('#div_add_facebook').removeClass('ascuns'); 
		$j('#div_add_facebook').addClass('');
		
		$j('#title_add3').removeClass('ascuns'); 
		$j('#title_add3').addClass('');
		
	}else if(type==2){
		$j('#but_add1').removeClass('inputButton100_over'); 
		$j('#but_add1').addClass('inputButton100');
		
		$j('#but_add2').removeClass('inputButton120'); 
		$j('#but_add2').addClass('inputButton120_over');
		
		$j('#but_add3').removeClass('inputButton120_over'); 
		$j('#but_add3').addClass('inputButton120');
		
		$j('#div_add_multiple').removeClass('ascuns'); 
		$j('#div_add_multiple').addClass('');
		
		$j('#title_add2').removeClass('ascuns'); 
		$j('#title_add2').addClass('');
		
	}else{
		$j('#but_add1').removeClass('inputButton100'); 
		$j('#but_add1').addClass('inputButton100_over');
		$j('#but_add2').removeClass('inputButton120_over'); 
		$j('#but_add2').addClass('inputButton120');
		$j('#but_add3').removeClass('inputButton120_over'); 
		$j('#but_add3').addClass('inputButton120');
		
		$j('#div_add_simple').removeClass('ascuns'); 
		$j('#div_add_simple').addClass('');
		
		$j('#title_add1').removeClass('ascuns'); 
		$j('#title_add1').addClass('');
	}
}
function CheckEditPhotos(frm){
	//alert(document.frmRotate.rotate.value);
	if(document.frmRotate.rotate.value == 6){
		if(window.confirm('Are you sure you want to delete this photo? This action cannot be undone!')) 
			if(window.confirm('ARE YOU SURE?')){
				return true;}
			else{
			return false;
			}
		else return false;
	}
	if(document.frmRotate.rotate.value == 5){
		tb_show('Select Album',HTTP+'photos/?confirm_move_photos&height=90&width=200',false);
		return false;
	}	
	if(document.frmRotate.rotate.value == 7){
		tb_show('Select Album',HTTP+'photos/?confirm_assign_photos&height=90&width=200',false);
		return false;
	}	
}
function CheckMovePhotos(){
	//alert(document.frmMove.album.value);
	var album = document.frmMove.album.value;	
	if(album){
		document.location=HTTP+'photos/move_photos/'+album;
	}
	return false;
	tb_remove();
}
function CheckAssignPhotos(){
	//alert(document.frmMove.to_user.value);
	var album = document.frmMove.to_user.value;	
	if(album){
		document.location=HTTP+'photos/assign_photos/'+album;
	}
	return false;
	tb_remove();
}
function PostComment(photo){	
	//alert(photo);
	var comment = document.frmComment.comment.value;	
	 $j.post(HTTP+'photos/post_comment/' + photo, {step: 2,comment: comment}, function(response){
		if(response == 'Please write a comment!')
			alert('Please write a comment!');
		else{
			$j.get(HTTP+'photos/load_comment/' + response, {}, function(resp){				
				if($j('#list_comments').length && $j('#list_comments').html() == 'No comments...') $j('#list_comments').html('');
				$j('#div_comments').append(resp);
				$j('#comment').attr('value', 'Write a comment...');				
				
			 });
		} 
	 });
	return false;
}
function CheckBoxEdit(id){
	if(id==5) $j('#name_photo').attr('class', '');
	else $j('#name_photo').attr('class', 'ascuns');	
}
function CheckEditPhoto(){
	alert(document.frmRotate.rotate.value);
	if(document.frmRotate.rotate.value == 6){
		if(window.confirm('Are you sure you want to delete this photo? This action cannot be undone!')) 
			if(window.confirm('ARE YOU SURE?')){
				return true;}
			else{
			return false;
			}
		else return false;
	}
	if(document.frmRotate.rotate.value == 5){
		tb_show('Select Album',HTTP+'photos/?confirm_move_photos&height=90&width=200',false);
		return false;
	}	
}
function DetailsPhoto(){
	if ($j('img.photo_details').length > 0)
		$j('img.photo_details').cluetip({
			tracking:true
			,width:150
			,positionBy:'mouse'
			,dropShadow:false
			,attribute:'alt'
			,cluetipClass: 'jtip'
		});
}
function GoToPhoto(photo){
	document.location=HTTP + 'photos/view_photo/' + photo;
}
function drawGraph(id,val1,val2,val3,val4,val5,val6,options) {
    var layout = new PlotKit.Layout("pie", options);
    layout.addDataset("sqrt", [[0, 0], val1, val2, val3, val4, val5, val6]);
    layout.evaluate();
    var canvas = MochiKit.DOM.getElement("graph_"+id);
    var plotter = new PlotKit.SweetCanvasRenderer(canvas, layout, options);
    plotter.render();
}
function TemplateStyles(value){
	  $j.post('?show_styles='+value, {}, function(response){
		  $j("#div_styles").html(response);
		});	
	  $j.post('?show_book_type=0', {}, function(response){
		  $j("#div_book_type").html(response);
		});	  
}
function TemplateBookType(value){
	if(value>0){
	  $j.post('?show_book_type='+value, {}, function(response){
		  $j("#div_book_type").html(response);
		});	
	}
}
function ShowTemplateType(value){
	if(value==1){
		$j('#template_type').removeClass('ascuns'); 
		$j('#template_type').addClass('field_row');
	}else {
		$j('#template_type').removeClass('field_row'); 
		$j('#template_type').addClass('ascuns');
	} 
}
function TemplateType(value){
  $j.post('?show_template_type_'+value, {}, function(response){
	  $j("#div_template_type").html(response);
	});
}
var nr_caption = 0 ;
if ($j("#nr_caption").length > 0)
var nr_caption = $j('#nr_caption').val();
function ShowCaption(id,val){
	if(val==1){
		nr_caption++;
		$j('#div_caption').removeClass('ascuns');		
		$j('#div_caption').addClass('field_row');
		
		$j('#div_caption_'+id).removeClass('ascuns'); 
		$j('#div_caption_'+id).addClass('view');		
	}else{
		nr_caption--;
		$j('#div_caption_'+id).removeClass('view'); 
		$j('#div_caption_'+id).addClass('ascuns');
		if(nr_caption==0){
			$j('#div_caption').removeClass('field_row'); 
			$j('#div_caption').addClass('ascuns');
		}
	} 
}
function TemplateAddTextfield11(id){
	var val = $j('#nr_textfield').val();
	if(val<6){		
		$j.get('?show_template_textfield='+val, {id:id}, function(response){
			$j("#div_textfield").html(response);
		});
	}else alert("You can add a maximum of 5 Textfield");
}
function TemplateAddTextarea111(id){
	var val = $j('#nr_textarea').val();
	if(val<4){		
		$j.get('?show_template_textarea='+val, {id:id}, function(response){
			$j("#div_textarea").html(response);
		});
	}else alert("You can add a maximum of 3 Textarea");
}
function TemplateAddPhotos(id){
	var val = $j('#nr_pictures').val();
	if(val<4){		
		$j.get('?show_template_photos='+val, {id:id}, function(response){
			$j("#div_pictures").html(response);
		});
		
	}
}
function ShowLineCounting(val){
	if(val==1){
		$j('#div_count_total').removeClass('ascuns'); 
		$j('#div_count_total').addClass('');
		$j('#div_count_user').removeClass(''); 
		$j('#div_count_user').addClass('ascuns');
		$j('#div_count_friends').removeClass(''); 
		$j('#div_count_friends').addClass('ascuns');
	}else{
		$j('#div_count_total').removeClass(''); 
		$j('#div_count_total').addClass('ascuns');
		$j('#div_count_user').removeClass('ascuns'); 
		$j('#div_count_user').addClass('');
		$j('#div_count_friends').removeClass('ascuns'); 
		$j('#div_count_friends').addClass('');
	}	
}
function ShowLinkAddPict(){
	$j('#link_add_pict').removeClass('ascuns'); 
	$j('#link_add_pict').addClass('');
}
function ShowLink(value){
	$j('#link_'+value).removeClass('ascuns'); 
	$j('#link_'+value).addClass('');
}
//profile
function TemplateProfileAddPictures(){
	var pict = $j('#nr_pictures').val();
	var pict1 = $j('#nr_pictures1').val();
	var id_div = parseInt(pict)+1;
	var id_div1 = parseInt(pict1)+1;
	$j('#nr_pictures').val(id_div);
	$j('#nr_pictures1').val(id_div1);	
	$j.post('?show_template_add_picture',{id_div:id_div1,nr_div:id_div},function(response){
		//alert(id_div1);
		//alert(id_div);
		$j('#div_pictures').append(response);
	});
}
function DeletePicture(val){
	$j('#delete_picture_'+val).attr('checked', true);
	$j('#picture_'+val).html('');
	var pict = $j('#nr_pictures').val();
	var pict1 = $j('#nr_pictures1').val();
	pict = parseInt(pict);
	pict1 = parseInt(pict1);
	//alert('pict: '+pict);
	var x=1;	
	for(i=1;i<=pict1;i++){
		//alert('i: '+i);
		if($j('#delete_picture_'+i).val() != 1){
			//alert('da');
		}else{
			//alert('nu');
			$j('#nr_pict_'+i).html(x);
			x++;
		}
	}
	var y=pict-1;
	$j('#nr_pictures').val(y);
}
function TemplateCheckProfile(){
	var value = $j('#profiles').val();
	if(value == 0.5 || value == 1 || value == 2 || value == 3 || value == 4 || value == 5 || value == 6 || value == 7 || value == 8 || value == 9 || value == 10 || value == 11 || value == 12 || value == 13 || value == 14 || value == 15 || value == 16 || value == 17 || value == 18 || value == 19 || value == 20){		
		var x=1;
	}else{
		alert('Error: Number of profile per page must be 0.5 or contained between 1 and 20'); 
		$j('#profiles').val('');
	}
}
function TemplateAddLine(id){
	var l_name = $j('#line_name').val();
	var l_limit = $j('#line_limit').val();
	var c_about = 0;
	var c_questions = 0;
	var c_say = 0;
	var c_comments = 0;
	var c_details = 0;
	if(l_name == ''){
		alert('Please select the name');
		return false;
	}
	if(l_limit == ''){
		alert('Please select the limit');
		return false;
	}
	if($j('#count_about').attr('checked')){
		c_about = 1;
		$j('#line_about').removeClass('field_row'); 
		$j('#line_about').addClass('ascuns');
	}
	if($j('#count_questions').attr('checked')){
		c_questions = 1;
		$j('#line_questions').removeClass('field_row'); 
		$j('#line_questions').addClass('ascuns');
	}
	if($j('#count_say').attr('checked')){
		c_say = 1;
		$j('#line_say').removeClass('field_row'); 
		$j('#line_say').addClass('ascuns');
	}
	if($j('#count_comments').attr('checked')){
		c_comments = 1;
		$j('#line_comments').removeClass('field_row'); 
		$j('#line_comments').addClass('ascuns');
	}
	if($j('#count_details').attr('checked')){
		c_details = 1;
		$j('#line_details').removeClass('field_row'); 
		$j('#line_details').addClass('ascuns');
	}
	
	if(c_about == 0 && c_questions == 0 && c_say == 0 && c_comments == 0 && c_details == 0){
		alert('Please select at least one component');
		return false;
	}
	var lines = $j('#nr_lines').val();
	$j.post('?show_template_add_line',{template_id:id,name:l_name,limit:l_limit,about:c_about,questions:c_questions,say:c_say,comments:c_comments,details:c_details},function(response){		
		if(lines==0) $j('#div_counting').html(response);
		else $j('#div_counting').append(response);
		lines++;
		$j('#nr_lines').val(lines);
		$j('#count_about').attr('checked',false);
		$j('#count_questions').attr('checked',false);
		$j('#count_say').attr('checked',false);
		$j('#count_comments').attr('checked',false);
		$j('#count_details').attr('checked',false);
		$j('#line_name').val('');
		$j('#line_limit').val('');
	});
}
function DeleteLine(id){
	$j.post('?show_template_delete_line='+id,{},function(response){
		//alert(response);
		if(response!='error'){
			$j('#line_'+id).addClass('ascuns');
			$j('#line_name').val('');
			$j('#line_limit').val('');
			var lines = $j('#nr_lines').val();
			lines--;
			$j('#nr_lines').val(lines);
			if(lines==0) $j('#div_counting').html('<span style="font-style: italic">Add line counts below</span>');
			var str = response;
			if(str.substr(0,1) == 1){				
				$j('#line_about').removeClass('ascuns'); 
				$j('#line_about').addClass('field_row');
			}
			if(str.substr(1,1) == 1){
				$j('#line_questions').removeClass('ascuns'); 
				$j('#line_questions').addClass('field_row');
			} 
			if(str.substr(2,1) == 1){
				$j('#line_say').removeClass('ascuns'); 
				$j('#line_say').addClass('field_row');
			} 
			if(str.substr(3,1) == 1){
				$j('#line_comments').removeClass('ascuns'); 
				$j('#line_comments').addClass('field_row');
			} 
			if(str.substr(4,1) == 1){
				$j('#line_details').removeClass('ascuns'); 
				$j('#line_details').addClass('field_row');
			} 
		}
	});
}
function CheckLineCounting(){	
	if($j('#about_me').attr('checked')){
		$j('#line_about').removeClass('ascuns'); 
		$j('#line_about').addClass('field_row');	
	}else{
		$j('#line_about').removeClass('field_row'); 
		$j('#line_about').addClass('ascuns');
	}
	
	if($j('#questions').attr('checked')){
		$j('#line_questions').removeClass('ascuns'); 
		$j('#line_questions').addClass('field_row');	
	}else{
		$j('#line_questions').removeClass('field_row'); 
		$j('#line_questions').addClass('ascuns');
	}
	if($j('#friends_say').attr('checked')){
		$j('#line_say').removeClass('ascuns'); 
		$j('#line_say').addClass('field_row');	
	}else{
		$j('#line_say').removeClass('field_row'); 
		$j('#line_say').addClass('ascuns');
	}
	if($j('#friends_comments').attr('checked')){
		$j('#line_comments').removeClass('ascuns'); 
		$j('#line_comments').addClass('field_row');	
	}else{
		$j('#line_comments').removeClass('field_row'); 
		$j('#line_comments').addClass('ascuns');
	}
}
function TemplateProfileAddPictures1(value){
	var pict = $j('#nr_pictures').val();
	$j.post('?show_template_add_pictures='+value,{pict:pict},function(response){	
		$j('#div_pictures').html(response);
	});	
}
function TemplateProfileAddPhotos(){
	var pict = $j('#nr_pictures').val();
	$j.post('?show_template_add_photos='+pict,{},function(response){
		$j('#div_pictures').html(response);
	});
}
function ShowCaptionPhoto(id,val){
	if(val==1){
		$j('#div_caption_'+id).removeClass('ascuns');		
		$j('#div_caption_'+id).addClass('field_row');	
	}else{		
		$j('#div_caption_'+id).removeClass('field_row'); 
		$j('#div_caption_'+id).addClass('ascuns');		
	} 
}
function TemplatePollsAddAwards(){
	var award = $j('#nr_awards').val();
	if(award>0){
		$j('#div_award').removeClass('ascuns'); 
		$j('#div_award').addClass('field_row');
	}
}
function ShowAward(sel,val){
	if(val==1){		
		$j('#div_award_'+sel).removeClass('ascuns');		
		$j('#div_award_'+sel).addClass('field_row');
		
		if(sel=='photo'){
			$j('#div_ratio_'+sel).removeClass('ascuns');		
			$j('#div_ratio_'+sel).addClass('field_row');			
		}		
	}else{		
		$j('#div_award_'+sel).removeClass('field_row'); 
		$j('#div_award_'+sel).addClass('ascuns');		
	} 
}
function TemplateOthersAdd(sel,type){
	$j('#div_'+sel).removeClass('ascuns');		
	$j('#div_'+sel).addClass('view');
	$j('#link_'+sel).removeClass('view');		
	$j('#link_'+sel).addClass('ascuns');
	
	if(sel=='photos'){
		var pict = $j('#nr_photos').val();
		if(pict>0){
			$j.post('?show_template_add_photos='+pict,{},function(response){
				$j('#div_'+sel).html(response);
			});
		}
	}
	if(sel=='textarea'){
		var text = $j('#nr_textarea').val();
		if(type==1 && text>3) alert("You can add a maximum of 3 Textarea");
		else if(text>0 && text<4){
			$j.post('?show_template_add_textarea='+text, {}, function(response){
				$j("#div_"+sel).html(response);
			});	
		}
	}
	if(sel=='textfield'){
		var text = $j('#nr_textfield').val();
		if(type==1 && text>5) alert("You can add a maximum of 5 Textfield");
		else if(text>0 && text<6){
			$j.post('?show_template_add_textfield='+text, {}, function(response){
				$j("#div_"+sel).html(response);
			});
		}
	}
}
function ShowCaptionPhotoOther(val){
	if(val==1){
		$j('#div_caption').removeClass('ascuns');		
		$j('#div_caption').addClass('field_row');	
	}else{		
		$j('#div_caption').removeClass('field_row'); 
		$j('#div_caption').addClass('ascuns');		
	} 
}
function ShowLinkOthers(val){
	$j('#link_'+val).removeClass('ascuns'); 
	$j('#link_'+val).addClass('');
}
function SetPreference(val){
	if(val==1){
		var books = $j('#books').val();
		var comments = $j('#comments').val();
		if(books!=''){
			$j.post(HTTP+'set_preference/1', {books:books,comments:comments}, function(response){
				if(response=='success'){
					$j('#preference2').removeClass('ascuns');		
					$j('#preference2').addClass('');
					$j('#preference1').removeClass('');		
					$j('#preference1').addClass('ascuns');	
					if(books>1) books = books+' yearbooks ';
					else books = books+' yearbook ';
					$j('#nr_books').html(books);
				} 
			});
		}
	}else{
		$j('#preference1').removeClass('ascuns');		
		$j('#preference1').addClass('');
		$j('#preference2').removeClass('');		
		$j('#preference2').addClass('ascuns');
	}
}
//montage
function TemplateAddPhoto(){
	//alert('mere');
	var pict = $j('#nr_photos').val();
	var pict1 = $j('#nr_photos1').val();
	var id_div = parseInt(pict)+1;
	var id_div1 = parseInt(pict1)+1;
	$j('#nr_photos').val(id_div);
	$j('#nr_photos1').val(id_div1);	
	$j.post('?show_template_add_photo',{id_div:id_div1,nr_div:id_div},function(response){
		//alert(id_div1);
		//alert(id_div);
		$j('#div_photos').append(response);
	});
}
function DeletePhoto(val){
	$j('#delete_picture_'+val).attr('checked', true);
	$j('#picture_'+val).html('');
	var pict = $j('#nr_photos').val();
	var pict1 = $j('#nr_photos1').val();
	pict = parseInt(pict);
	pict1 = parseInt(pict1);
	//alert('pict: '+pict);
	var x=1;	
	for(i=1;i<=pict1;i++){
		//alert('i: '+i);
		if($j('#delete_picture_'+i).val() != 1){
			//alert('da');
		}else{
			//alert('nu');
			$j('#nr_pict_'+i).html(x);
			x++;
		}
	}
	var y=pict-1;
	//alert('new pict: '+y);
	$j('#nr_photos').val(y);
}
function TemplateAddTextfield(){
	var pict = $j('#nr_textfield').val();
	var pict1 = $j('#nr_textfield1').val();	
	if(pict>4)alert("You can add a maximum of 5 Textfield");
	else{
		var pict = $j('#nr_textfield').val();
		var pict1 = $j('#nr_textfield1').val();
		var id_div = parseInt(pict)+1;
		var id_div1 = parseInt(pict1)+1;
		$j('#nr_textfield').val(id_div);
		$j('#nr_textfield1').val(id_div1);	
		$j.post('?show_template_textfield',{id_div:id_div1,nr_div:id_div},function(response){
			//alert(id_div1);
			//alert(id_div);
			$j('#div_textfield').append(response);
		});
	}
}
function DeleteTextfield(val){
	$j('#delete_textfield_'+val).attr('checked', true);
	$j('#textfield_'+val).html('');
	var pict = $j('#nr_textfield').val();
	var pict1 = $j('#nr_textfield1').val();
	pict = parseInt(pict);
	pict1 = parseInt(pict1);
	//alert('pict: '+pict);
	var x=1;	
	for(i=1;i<=pict1;i++){
		//alert('i: '+i);
		if($j('#delete_textfield_'+i).val() != 1){
			//alert('da');
		}else{
			//alert('nu');
			$j('#nr_field_'+i).html(x);
			x++;
		}
	}
	var y=pict-1;
	//alert('new pict: '+y);
	$j('#nr_textfield').val(y);
}
function TemplateAddTextarea(){
	var pict = $j('#nr_textarea').val();
	var pict1 = $j('#nr_textarea1').val();
	if(pict>2) alert("You can add a maximum of 3 Textarea");
	else{
		var pict = $j('#nr_textarea').val();
		var pict1 = $j('#nr_textarea1').val();
		var id_div = parseInt(pict)+1;
		var id_div1 = parseInt(pict1)+1;
		$j('#nr_textarea').val(id_div);
		$j('#nr_textarea1').val(id_div1);	
		$j.post('?show_template_textarea',{id_div:id_div1,nr_div:id_div},function(response){
			 //alert(id_div1);
			//alert(id_div);
			$j('#div_textarea').append(response);
		});
	}
}
function DeleteTextarea(val){
	$j('#delete_textarea_'+val).attr('checked', true);
	$j('#textarea_'+val).html('');
	var pict = $j('#nr_textarea').val();
	var pict1 = $j('#nr_textarea1').val();
	pict = parseInt(pict);
	pict1 = parseInt(pict1);
	//alert('pict: '+pict);
	var x=1;	
	for(i=1;i<=pict1;i++){
		//alert('i: '+i);
		if($j('#delete_textarea_'+i).val() != 1){
			//alert('da');
		}else{
			//alert('nu');
			$j('#nr_field_'+i).html(x);
			x++;
		}
	}
	var y=pict-1;
	$j('#nr_textarea').val(y);
}
function Step2CheckSize(value){
	$j('#div_styles').load(HTTP + 'admin.php?setup&style='+value);	
}
function Step2ActivateColorPicker(){
	if($j('#color').length>0)
	$j('#color').ColorPicker({
		onSubmit: function(hsb, hex, rgb, el) {
			$j(el).val(hex);
			$j(el).ColorPickerHide();
		},
		onBeforeShow: function () {
			$j(this).ColorPickerSetColor(this.value);
		}
	})
	.bind('keyup', function(){
		$j(this).ColorPickerSetColor(this.value);
	});
}
function Step3GroupAdd(){
	if ($j('#formStep3Add').length > 0) {
		$j('#formStep3Add').ajaxForm( {
			success : function(response) {
				if (response){	
					alert(response);
					if(response == 'success'){
						tb_show('',HTTP+'admin.php?setup&add_group_step2&resize=true&height=530&width=700&modal=true',false);
					}else{						
						alert(response);
					}
				}
			}
		});
	}
}
function Step3GroupEdit(){
	if ($j('#formStep3Add').length > 0) {
		$j('#formStep3Add').ajaxForm( {
			success : function(response) {
				if (response){	
					var value = $j('#group_id').val();	
					if(response == 'success'){
						tb_show('',HTTP+'admin.php?setup&edit_group_step2='+value+'&resize=true&height=530&width=700&modal=true',false);
					}else{						
						alert(response);
					}
				}
			}
		});
	}
}
function Step3GroupAddStep2(){
	if ($j('#formStep3Add').length > 0) {
		$j('#formStep3Add').ajaxForm( {
			success : function(response) {
				if (response){	
					//alert(response);
					if(response == 'success'){						
						tb_show('',HTTP+'admin.php?setup&add_group_step3&resize=true&height=430&width=450&modal=true',false);
					}else{						
						alert(response);
					}
				}
			}
		});
	}
}

function Step3GroupAddStep3(){
	if ($j('#formStep3Add').length > 0) {
		$j('#formStep3Add').ajaxForm( {
			success : function(response) {
				if (response){	
					//alert(response);
					if(response == 'success'){
						document.location=HTTP+'admin.php?setup&step3';
						//tb_show('',HTTP+'setup/add_group_step3?resize=true&height=430&width=450&modal=true',false);
					}else{						
						alert(response);
					}
				}
			}
		});
	}
}
function Step3GroupEditStep3(){
	if ($j('#formStep3Add').length > 0) {
		$j('#formStep3Add').ajaxForm( {
			success : function(response) {
				if (response){	
					if(response == 'success'){
						document.location=HTTP+'admin.php?setup&step3';
						//tb_show('',HTTP+'setup/add_group_step3?resize=true&height=430&width=450&modal=true',false);
					}else{						
						alert(response);
					}
				}
			}
		});
	}
}
function Step3GroupAddNew(){
	if ($j('#formStep3Addg').length > 0) {
		$j('#formStep3Addg').ajaxForm( {
			success : function(response) {
				if (response){alert(response);
					if(response =='1' || response =='2'){
						if(response == '1')
							document.location=HTTP+'admin.php?setup&step3';
						else if(response == '2')
							tb_show('',HTTP+'admin.php?setup&add_group_step2&resize=true&height=530&width=700&modal=true',false);
					}else{
						alert(response);					
					}
				}
			}
		});
	}
}
function AddGroupAddComponent(){
	var nr_comp = $j('#nr_comp').val();
	nr_comp++;
	$j('#nr_comp').val(nr_comp);
	var value = $j('#add_name').val();	
	if(value!=''){		
		$j('#div_comp').append('<div class="group_add_comp6"><div id="comp_'+nr_comp+'" class="group_add_comp6_title">'+value+'</div><div class="group_add_comp6_opt"><input type="checkbox" id="include_'+nr_comp+'" name="include_'+nr_comp+'" onclick="AddGroupIncludeComponent('+nr_comp+');" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id="index_'+nr_comp+'" name="index_'+nr_comp+'" onclick="AddGroupIndexComponent('+nr_comp+');"/></div></div>');
		$j('#add_name').val('');	
	}		
}
function AddGroupIncludeComponent(value){
	var content = $j('#comp_'+value).html();	
	$j.post(HTTP+'admin.php?setup&add_component',{component:content,type:1},function(response){
		if(response != 'success') alert(response);		
	});
}
function AddGroupIndexComponent(value){	
	var content = $j('#comp_'+value).html();	
	$j.post(HTTP+'admin.php?setup&add_component',{component:content,type:2},function(response){
		if(response != 'success') alert(response);		
	});
}
function GroupAddShowTab(value){
	for(i=1;i<4;i++){
		$j('#tab'+i).removeClass('group_add_tab_over');		
		$j('#tab'+i).addClass('group_add_tab');
		$j('#content'+i).removeClass('');		
		$j('#content'+i).addClass('ascuns');
	}
	$j('#tab'+value).removeClass('group_add_tab');		
	$j('#tab'+value).addClass('group_add_tab_over');
	$j('#content'+value).removeClass('ascuns');		
	$j('#content'+value).addClass('');	
}
function AddGroupAddQuestionRecom(value){
	var nr_quest_recom = $j('#nr_quest_recom').val();
	nr_quest_recom++;
	$j('#nr_quest_recom').val(nr_quest_recom);
	$j('#nr_recom_question').html(nr_quest_recom);
	var content = $j('#quest_'+value+'_cont').html();
	$j('#quest_'+value).remove();
	$j('#div_quest_recom').append('<div id="quest_recom_'+value+'" class="group_add_comp10_line"><div id="quest_recom_'+value+'_cont" class="group_add_comp10_title">'+content+'</div><div class="group_add_comp10_opt"><strong><a href="#" onclick="AddGroupDeleteQuestionRecom('+value+')">remove</a></strong></div></div>');
	$j.post(HTTP+'admin.php?setup&add_question',{question:content,mandatory:1},function(response){
		if(response != 'success') alert(response);		
	});
}
function AddGroupAddQuestionOpt(value){	
	var nr_quest_opt = $j('#nr_quest_opt').val();
	nr_quest_opt++;
	$j('#nr_quest_opt').val(nr_quest_opt);
	$j('#nr_opt_question').html(nr_quest_opt);
	var content = $j('#quest_'+value+'_cont').html();
	$j('#quest_'+value).remove();
	$j('#div_quest_opt').append('<div id="quest_opt_'+value+'" class="group_add_comp10_line"><div id="quest_opt_'+value+'_cont" class="group_add_comp10_title">'+content+'</div><div class="group_add_comp10_opt"><strong><a href="#" onclick="AddGroupDeleteQuestionOpt('+value+')">remove</a></strong></div></div>');
	$j.post(HTTP+'admin.php?setup&add_question',{question:content,mandatory:0},function(response){
		if(response != 'success') alert(response);
	});
}
function AddGroupAddNewQeustion(value){
	var content = $j('#add_question').val();
	$j('#add_question').val('');
	var nr_quest = $j('#nr_quest').val();
	if(content!=''){		
		if(value == 1){
			var nr_quest_recom = $j('#nr_quest_recom').val();
			nr_quest_recom++;
			$j('#nr_quest_recom').val(nr_quest_recom);
			var nr_quest = $j('#nr_quest').val();
			nr_quest++;
			$j('#nr_quest').val(nr_quest);
			$j('#nr_recom_question').html(nr_quest_recom);
			$j('#div_quest_recom').append('<div id="quest_recom_'+nr_quest+'" class="group_add_comp10_line"><div id="quest_recom_'+nr_quest+'_cont" class="group_add_comp10_title">'+content+'</div><div class="group_add_comp10_opt"><strong><a href="#" onclick="AddGroupDeleteQuestionRecom('+nr_quest+')">remove</a></strong></div></div>');
			$j.post(HTTP+'admin.php?setup&add_question',{question:content,mandatory:1},function(response){
				if(response != 'success') alert(response);
			});
		}else if(value == 2){
			var nr_quest_opt = $j('#nr_quest_opt').val();
			nr_quest_opt++;
			$j('#nr_quest_opt').val(nr_quest_opt);
			var nr_quest = $j('#nr_quest').val();
			nr_quest++;
			$j('#nr_quest').val(nr_quest);
			$j('#nr_opt_question').html(nr_quest_opt);
			$j('#div_quest_opt').append('<div id="quest_opt_'+nr_quest+'" class="group_add_comp10_line"><div id="quest_opt_'+nr_quest+'_cont" class="group_add_comp10_title">'+content+'</div><div class="group_add_comp10_opt"><strong><a href="#" onclick="AddGroupDeleteQuestionOpt('+nr_quest+')">remove</a></strong></div></div>');
			$j.post(HTTP+'admin.php?setup&add_question',{question:content,mandatory:0},function(response){
				if(response != 'success') alert(response);
			});
		}	
	}
}
function AddGroupDeleteQuestionRecom(value){
	var nr_quest_recom = $j('#nr_quest_recom').val();
	nr_quest_recom--;
	$j('#nr_quest_recom').val(nr_quest_recom);
	$j('#nr_recom_question').html(nr_quest_recom);		
	var content = $j('#quest_recom_'+value+'_cont').html();
	$j('#quest_recom_'+value).remove();
	$j('#div_quest').append('<div id="quest_'+value+'" class="group_add_comp11_line"><div id="quest_'+value+'_cont" class="group_add_comp11_title">'+content+'</div><div class="group_add_comp11_opt"><strong><img src="'+HTTP+'_layouts/images/icon_r.png" border="0" alt="" onclick="AddGroupAddQuestionRecom('+value+')"/><img src="'+HTTP+'_layouts/images/icon_o.png" border="0" alt="" onclick="AddGroupAddQuestionOpt('+value+')"/></strong></div></div>');
	$j.post(HTTP+'admin.php?setup&delete_question',{question:content,mandatory:1},function(response){
		if(response != 'success') alert(response);		
	});
}
function AddGroupDeleteQuestionOpt(value){	
	var nr_quest_opt = $j('#nr_quest_opt').val();
	nr_quest_opt--;
	$j('#nr_quest_opt').val(nr_quest_opt);
	$j('#nr_opt_question').html(nr_quest_opt);	
	var content = $j('#quest_opt_'+value+'_cont').html();
	$j('#quest_opt_'+value).remove();
	$j('#div_quest').append('<div id="quest_'+value+'" class="group_add_comp11_line"><div id="quest_'+value+'_cont" class="group_add_comp11_title">'+content+'</div><div class="group_add_comp11_opt"><strong><img src="'+HTTP+'_layouts/images/icon_r.png" border="0" alt="" onclick="AddGroupAddQuestionRecom('+value+')"/><img src="'+HTTP+'_layouts/images/icon_o.png" border="0" alt="" onclick="AddGroupAddQuestionOpt('+value+')"/></strong></div></div>');
	$j.post(HTTP+'admin.php?setup&delete_question',{question:content,mandatory:0},function(response){
		if(response != 'success') alert(response);		
	});
}
function AddGroupAddTopicRecom(value){
	var nr_topic_recom = $j('#nr_topic_recom').val();
	nr_topic_recom++;
	$j('#nr_topic_recom').val(nr_topic_recom);
	$j('#nr_recom_topic').html(nr_topic_recom);
	var content = $j('#topic_'+value+'_cont').html();
	$j('#topic_'+value).remove();
	$j('#div_topic_recom').append('<div id="topic_recom_'+value+'" class="group_add_comp10_line"><div id="topic_recom_'+value+'_cont" class="group_add_comp10_title">'+content+'</div><div class="group_add_comp10_opt"><strong><a href="#" onclick="AddGroupDeleteTopicRecom('+value+')">remove</a></strong></div></div>');
	$j.post(HTTP+'admin.php?setup&add_topic',{topic:content,mandatory:1},function(response){
		if(response != 'success') alert(response);		
	});
}
function AddGroupAddTopicOpt(value){	
	var nr_topic_opt = $j('#nr_topic_opt').val();
	nr_topic_opt++;
	$j('#nr_topic_opt').val(nr_topic_opt);
	$j('#nr_opt_topic').html(nr_topic_opt);
	var content = $j('#topic_'+value+'_cont').html();
	$j('#topic_'+value).remove();
	$j('#div_topic_opt').append('<div id="topic_opt_'+value+'" class="group_add_comp10_line"><div id="topic_opt_'+value+'_cont" class="group_add_comp10_title">'+content+'</div><div class="group_add_comp10_opt"><strong><a href="#" onclick="AddGroupDeleteTopicOpt('+value+')">remove</a></strong></div></div>');
	$j.post(HTTP+'admin.php?setup&add_topic',{topic:content,mandatory:0},function(response){
		if(response != 'success') alert(response);
	});
}
function AddGroupAddNewTopic(value){
	var content = $j('#add_topic').val();
	$j('#add_topic').val('');
	var nr_topic = $j('#nr_topic').val();
	if(content!=''){		
		if(value == 1){
			var nr_topic_recom = $j('#nr_topic_recom').val();
			nr_topic_recom++;
			$j('#nr_topic_recom').val(nr_topic_recom);
			var nr_topic = $j('#nr_topic').val();
			nr_topic++;
			$j('#nr_topic').val(nr_topic);
			$j('#nr_recom_topic').html(nr_topic_recom);
			$j('#div_topic_recom').append('<div id="topic_recom_'+nr_topic+'" class="group_add_comp10_line"><div id="topic_recom_'+nr_topic+'_cont" class="group_add_comp10_title">'+content+'</div><div class="group_add_comp10_opt"><strong><a href="#" onclick="AddGroupDeleteTopicRecom('+nr_topic+')">remove</a></strong></div></div>');
			$j.post(HTTP+'admin.php?setup&add_topic',{topic:content,mandatory:1},function(response){
				if(response != 'success') alert(response);
			});
		}else if(value == 2){
			var nr_topic_opt = $j('#nr_topic_opt').val();
			nr_topic_opt++;
			$j('#nr_topic_opt').val(nr_topic_opt);
			var nr_topict = $j('#nr_topic').val();
			nr_topic++;
			$j('#nr_topic').val(nr_topic);
			$j('#nr_opt_topic').html(nr_topic_opt);
			$j('#div_topic_opt').append('<div id="topic_opt_'+nr_topic+'" class="group_add_comp10_line"><div id="topic_opt_'+nr_topic+'_cont" class="group_add_comp10_title">'+content+'</div><div class="group_add_comp10_opt"><strong><a href="#" onclick="AddGroupDeleteTopicOpt('+nr_topic+')">remove</a></strong></div></div>');
			$j.post(HTTP+'admin.php?setup&add_topic',{topic:content,mandatory:0},function(response){
				if(response != 'success') alert(response);
			});
		}	
	}
}
function AddGroupDeleteTopicRecom(value){
	var nr_topic_recom = $j('#nr_topic_recom').val();
	nr_topic_recom--;
	$j('#nr_topic_recom').val(nr_topic_recom);
	$j('#nr_recom_topic').html(nr_topic_recom);		
	var content = $j('#topic_recom_'+value+'_cont').html();
	$j('#topic_recom_'+value).remove();
	$j('#div_topic').append('<div id="topic_'+value+'" class="group_add_comp11_line"><div id="topic_'+value+'_cont" class="group_add_comp11_title">'+content+'</div><div class="group_add_comp11_opt"><strong><img src="'+HTTP+'_layouts/images/icon_r.png" border="0" alt="" onclick="AddGroupAddTopicRecom('+value+')"/><img src="'+HTTP+'_layouts/images/icon_o.png" border="0" alt="" onclick="AddGroupAddTopicOpt('+value+')"/></strong></div></div>');
	$j.post(HTTP+'admin.php?setup&delete_topic',{topic:content,mandatory:1},function(response){
		if(response != 'success') alert(response);		
	});
}
function AddGroupDeleteTopicOpt(value){	
	var nr_topic_opt = $j('#nr_topic_opt').val();
	nr_topic_opt--;
	$j('#nr_topic_opt').val(nr_topic_opt);
	$j('#nr_opt_topic').html(nr_topic_opt);	
	var content = $j('#topic_opt_'+value+'_cont').html();
	$j('#topic_opt_'+value).remove();
	$j('#div_topic').append('<div id="topic_'+value+'" class="group_add_comp11_line"><div id="topic_'+value+'_cont" class="group_add_comp11_title">'+content+'</div><div class="group_add_comp11_opt"><strong><img src="'+HTTP+'_layouts/images/icon_r.png" border="0" alt="" onclick="AddGroupAddTopicRecom('+value+')"/><img src="'+HTTP+'_layouts/images/icon_o.png" border="0" alt="" onclick="AddGroupAddTopicOpt('+value+')"/></strong></div></div>');
	$j.post(HTTP+'admin.php?setup&delete_topic',{topic:content,mandatory:0},function(response){
		if(response != 'success') alert(response);		
	});
}
function ChangeDeadline(){
	if ($j('#frmEdit').length > 0) {
		$j('#frmEdit').ajaxForm({
			success : function(response) {
				if (response){	
					$j('#div_deadline').html(response);
					tb_remove();
				}else tb_remove();
			}
		});
	}
	if ($j("#deadline").length > 0) {
		$j("#deadline").datepicker({
					changeFirstDay: false,
					dateFormat: 'dd/mm/yy',
					showOn: 'both',
					buttonImage: HTTP+'_layouts/images/calendar1.gif',
					buttonImageOnly: true,
					yearRange: '1930:2030',
					defaultDate: new Date ()
				});
	}
}