// JavaScript Document
function showEditor(ele){
	sel=$(ele).attr('rel');
	//alert($("p"+sel).text());
	$(ele).parent().children("a.save").css({display:'inline-block'});
	$(ele).addClass('cancel').text('cancel');
	$("p"+sel).css({display:'none'});
	$("div"+sel).css({display:'block'});
	tinyMCE.init(tinyOptions);
}

function showBox(clsName){
	$('.'+clsName).slideDown('slow');
}

function hideBox(clsName){
	$('.'+clsName).slideUp('slow');
}

function validateForm(formObj){
	//alert('trig');
	sta=true;
	$(formObj).find("input'[name=image]'").each(function(){ 
		if($(this).val()){
			var ext = $(this).val().split('.').pop().toLowerCase();
			var allow = new Array('gif','png','jpg','jpeg');
			if(jQuery.inArray(ext, allow) == -1) {
				alert('Invalid image format. Only jpg, png and gif images are allowed.');
				sta = false;
			}
		}
	});
	$(formObj).find("input'[type=text]'").each(function(){
		if($(this).hasClass('reqd')){
			if($(this).attr('value')==''){  
				alert("Please enter event "+$(this).attr('name').toUpperCase()); 
				sta = false;  
			}
		}
	});
	
	if(!sta){return false;}else{ return true; }
}

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
}

$(document).ready(function(){ 
	$('a.edit').attr('title','Edit');
	$('a.save').attr('title','Save');
	$('.profile li a.edit').click( function(){
		_parent=$(this).parent().get(0);
		//alert(_parent.tagName); return;
		if($(this).hasClass('save')){
			_fieldName=$(this).attr('id');
			_inputName=$(this).attr('rel')=='' ? 'input' : $(this).attr('rel') ;
			_spanCont=$(_parent).children("span#dyna-cont");
			_fieldValue=$(_spanCont).children(_inputName).val();
			_userID=$('input#userid').val();
			//alert(_fieldName+" - "+_fieldValue+" - "+_inputName+" - "+_userID); return;
			$(_parent).children("img#progress").css({ display:'inline' });
			saveProfileInformation(_userID,_fieldName,_fieldValue,_parent)
		}else{
			if( $(this).hasClass('cancel') ){
				$(_parent).children("span#dyna-cont").css({ display:'none' });
				$(_parent).children("span#sta-cont").css({ display:'inline-block' });
				$(_parent).children("a.save").css({ display:'none' });
				$(this).removeClass('cancel').text('Edit').attr('title','Edit');
			}else{
				$(_parent).children("span#sta-cont").css({ display:'none' });
				$(_parent).children("span#dyna-cont").css({ display:'inline-block' });
				$(_parent).children("a.save").css({ display:'inline-block' });
				$(this).addClass('cancel').text('Cancel').attr('title','Cancel');
			}
		}
	}); 
});

$(document).ready(function(){
	$('.moreinfo h2 a.edit').click(function(){
		//alert('trig'); return;
		sel=$(this).attr('rel');
		//alert(sel); return;
		if($(this).hasClass('save')){
			_parent=$(this).parent().get(0);
			_fieldName=$(this).attr('id');
			var ed = tinyMCE.get('profile');
            //saveContent(id,ed.getContent(),ed);
			_fieldValue=ed.getContent();
			_userID=$('input#userid').val();
			//alert(_fieldName+" - "+_fieldValue+" - "+_userID); return;
			saveProfileInformationTxt(_userID,_fieldName,ed.getContent(),_parent,ed);
		}else{
			if( $(this).hasClass('cancel') ){
				$(this).parent().children("a.save").css({display:'none'});
				$("div#"+sel).css({display:'block'});
				$("div#"+sel+"-editor").css({display:'none'});
				$(this).removeClass('cancel').text('Edit').attr('title','Edit');
			}else{
				$(this).parent().children("a.save").css({display:'inline-block'});
				$(this).addClass('cancel').text('cancel').attr('title','Cancel');
				$("div#"+sel).css({display:'none'});
				$("div#"+sel+"-editor").css({display:'block'});
				editorClass=$("div#"+sel+"-editor textarea").attr('class');
				$.extend(tinyOptions,{editor_selector : editorClass})
				tinyMCE.init(tinyOptions);
			}
		}
	});
});

$(document).ready(function(){
	$("a.readmore").click(function(e){
		//alert($(this).attr('href'));
		if($(this).hasClass('down')){
			$($(this).attr('href')).fadeIn(500);
			$(this).addClass('up').removeClass('down');
		}else{
			$($(this).attr('href')).fadeOut(300);
			$(this).addClass('down').removeClass('up');
		}
		e.preventDefault();
	});
	
	$("a.action.edit").click(function(e){
		if($($(this).attr('href')).is(':visible')){
			e.preventDefault(); return;
		}else{
			$($(this).attr('href')).fadeIn(500); 
		}
		
		//$("#datepicker"+$(this).attr('rel')).datepicker({changeMonth: true,changeYear: true,dateFormat: 'dd-mm-yy' });
		
		selector=$(this).attr('href');
		/*INTIALIZE IMAGE UPLOADER*/
		var btnUpload=$("#button"+$(this).attr('rel'));
		var status=$("#upload-status"+$(this).attr('rel'));
		new AjaxUpload(btnUpload, {
			action: 'fileuploader.php',
			name: 'uploadfile',
			data: {
					id:$(this).attr('rel'),
					mode:'event'
				  },
			onSubmit: function(file, ext){
				 if (! (ext && /^(jpg|png|jpeg)$/.test(ext))){ 
					status.text('Only JPG or PNG  files are allowed');
					return false;
				}
				status.html('Uploading...');
			},
			onComplete: function(file, response){
				status.text('');
				alert(response)
				temp=response.split(';');
				if(temp[0]=="1"){
					$(selector+" #i_path").attr('value',temp[1]);
				} else{
					alert('Error Uploading file');
				}
			}
		});
		e.preventDefault();
	});
	
	$("a.action.save").click(function(e){
		eventEdit($(this).attr('href'),$(this).attr('rel'));
		e.preventDefault();
	});
	
	$("a.action.delete").click(function(e){
		e.preventDefault();
		if(confirm("Are you sure you want to delete event?"))
			eventDelete($(this).attr('href'));
		
	});
	
	$("a.action.close").click(function(e){
		$($(this).attr('href')).fadeOut(200);
		e.preventDefault();
	});
});

/*DASHBOARD FUNCTIONS*/
$(document).ready(function(){
	_inputType=$("form#shoutbox input'[name=type]'");
	_inputTextarea=$("form#shoutbox #textarea");
	_login_id=$("form#shoutbox input'[name=login_id]'").val();
	_shareBusy=$(".shoutbox #busy");
	$('.shoutbox .type').click(function(){
		_inputType.val($(this).attr('rel'));
	});
	
	$("form#shoutbox #textarea").click(function(){
		if($(this).val()=='Share your thoughts!!'){
			$(this).val('');
		}
	});
	
	$("form#shoutbox #textarea").blur(function(){
		if($(this).val()=='' || $(this).val()=='Share your thoughts!!'){
			$(this).val('Share your thoughts!!');
		}
	});
	
	$('.shoutbox #share').click(function(){
		/*alert(_inputTextarea.val().length);*/
		if(_inputTextarea.val()!='' && _inputTextarea.val()!='Share your thoughts!!'){
			shareUpdate(_login_id,_inputTextarea.val(),_inputType.val(),_shareBusy);
			_inputTextarea.val('Share your thoughts!!');
		}
		
	});
	
	$('.quicklinks #reply').bind('click',function(){
		$(this).css({display:'none'}).parents('li').children('div.comment.reply').css({display:'block'});
	});
	
	$('.comment #textarea').click(function(){
		if($(this).val()=='Drop a comment..'){ $(this).val(''); }
		$(this).parent().children('a#comment').addClass('show');
	});
	
	$("form#shoutbox #textarea").keypress(function(){
		$("p#shtcount span").text(450-$(this).val().length);
		if($(this).val().length>450){
			$(this).val($(this).val().substring(0,449));
		}
	});
	
	$('.comment #textarea').blur(function(){
		if($(this).val()==''){
			$(this).val('Drop a comment..').parent().children('a#comment').removeClass('show');
		}
	});
	
	$(".comment a#comment").click(function(e){
		_parent=$(this).parent();
		_parentLI=$(this).parents('li');
		_contentArea=$(this).parent().children("#textarea");
		_parentPost=$(this).attr('rel');
		_shareBusy=$(_parent).children('img#busy')
		if(_contentArea.val().length){
			$(_parent).children('img#busy').css({ display:'inline-block' });
			shareUpdateComment(_login_id,_parentPost,_contentArea.val(),_shareBusy,_parentLI);
			_contentArea.val('');
			$(this).removeClass('show');
		}
		e.preventDefault();
	});
	
	$(".update .delete").click(function(){
		if(confirm("Are You Sure??")){
			deleteComments($(this));
		}
	});
	
	$.fn.reverseOrder = function() {
		return this.each(function() {
			$(this).prependTo( $(this).parent() );
		});
	};
	
	$('ul.comments li').reverseOrder();
});

/*ALBUM FUNCTIONS*/
$(document).ready(function(){
	$("input#button'[value=Create]'").click(function(){
		_loginId=$("input#userid'[type=hidden]'").val();
		$("#albuminfo input'[type=text]'").each(function(){
			if($(this).val()==''){ alert("Please Enter "+$(this).attr('name')); return; }
		});
		_busyObj=$("#albuminfo #busy");
		_busyObj.css({ visibility:'visible' });
		createAlbum(_loginId,$("#albuminfo input#album_name").val(),$("#albuminfo input#album_description").val(),_busyObj);
	});
	
	$('.qamenu a#dp').click(function(e){
		_albumId=$("input#album_id'[type=hidden]'").val();
		_imageId=$(this).attr('rel');
		markON(_albumId,_imageId,this);
		e.preventDefault();
	});
	
	$('table.media #image-del').click(function(e){
		if(confirm("Are You Sure?"))
		{	deleteImage(this);	}
		e.preventDefault();
	});
	
	$('.media #sta-cont').click(function(){
		_parent=$(this).parent();
		$(this).css({ display:'none' });
		$(_parent).children("span#dyn-cont").css({ display:'inline' });
	});
	
	$('.media #dyn-cont #dyn-input').keypress(function(){
		$(this).css({ borderColor:'#656565' });
	});
	
	$('table.media #dyn-cont a#action').click(function(e){
		e.preventDefault();
		_parent=$(this).parent();
		if($(this).hasClass("save")){
			_inputEle=$(_parent).children("input#dyn-input");
			if($(_inputEle).val().length<1){
				$(_inputEle).css({ borderColor:'red' });
				return;
			}
			$(_inputEle).addClass('block').attr('readonly','true');
			saveImageCaption($(_inputEle).val(),$(this).attr("rel"),$(this).parents("td"));
		}
	});
	
	$('div.media #dyn-cont a#action').click(function(e){
		e.preventDefault();
		_parent=$(this).parent();
		if($(this).hasClass("title")){
			_inputEle=$(_parent).children("input#dyn-input");
			if($(_inputEle).val().length<1){
				$(_inputEle).css({ borderColor:'red' });
				return;
			}
			$(_inputEle).addClass('block').attr('readonly','true');
			changeAlbumInfo($(_inputEle).val(),$(this).attr("rel"),$(this).parents("p"),"title");
		}
		if($(this).hasClass("desc")){
			_inputEle=$(_parent).children("input#dyn-input");
			if($(_inputEle).val().length<1){
				$(_inputEle).css({ borderColor:'red' });
				return;
			}
			$(_inputEle).addClass('block').attr('readonly','true');
			changeAlbumInfo($(_inputEle).val(),$(this).attr("rel"),$(this).parents("p"),"desc");
		}
	});
	
	$('.media #dyn-cont a#cancel').click(function(e){
		e.preventDefault();
		//_parent=$(this).parents("td");
		if($(this).parents("td").size())
		{ _parent=$(this).parents("td"); }else{ _parent=$(this).parents("p"); }
		$(_parent).children("span#sta-cont").css({ display:'inline' });
		$(_parent).children("span#dyn-cont").css({ display:'none' });
	});
	
	$('.album #deletealbum').click(function(e){
		e.preventDefault();
		if(confirm("Are You Sure?")){
			deleteAlbum($(this));
		}
	});
	
});

$(document).ready(function(){
	$("#send_messages #message_type").change(function(){
		if($(this).val()=='GM' || $(this).val()=='HD' ){
			$("#send_messages #hideName").css({ display:'none' });
		}else{
			$("#send_messages #hideName").css({ display:'block' });
		}
	});
	
	$("#send_messages #subject").keypress(function(){
		$("p#substatus span").text(120-$(this).val().length);
		if($(this).val().length>120){
			$(this).val($(this).val().substring(0,118));
		}
	});
	
	$('.send_message input#send').click(function(e){
		_from=$("#send_messages #userid").val();
		_messageType=$("#send_messages #message_type").val();
		
		_mode=$("#send_messages #message_mode").val();
		
		if(_messageType=='GM' || _messageType=='HD'){
			_to=0;
		}else{
			
			/*if($("#send_messages #from").val()==''){
				$("#send_messages #name").css({ borderColor:'red' }).focus();
				return false;
			}
			_to=$("#send_messages #from").val();*/
			
			if(!$("#send_messages ul#result_id li").size()){
				//alert($("#send_messages ul#results_id li").size());
				$("#send_messages #name").css({ borderColor:'red' }).focus();
				return false;
			}
			//alert($("#send_messages ul#result_id li").size());
			_to=$("#send_messages ul#result_id li");
			
		}
		
		if($("#send_messages #subject").val().length){
			_subject=$("#send_messages #subject").val();
		}else{
			$("#send_messages #subject").css({ borderColor:'red' }).focus();
			return false;
		}
		
		if($("#send_messages #message").val().length){
			_msgContent=$("#send_messages #message").val();
		}else{
			$("#send_messages #message").css({ borderColor:'red' }).focus();
			 return false;
		}
		
		$("#send_messages #busy").css({visibility:'visible'});
		
		sendMessage(_from,_to,_subject,_msgContent,$("#send_messages #message_type").val(),$("#send_messages #busy"));
		
		e.preventDefault();
	});
	
	$("#send_messages input'[type=text]', #send_message textarea").click(function(){
		$(this).css({borderColor:'#CCCCCC'});
	});
	
	$("#send_messages input'[type=text]', #send_message textarea").change(function(){
		$(this).css({borderColor:'#CCCCCC'});
	});
	
	$("#send_messages #message_type").change(function(){
		switch($(this).val()){
			case "PM": $("#send_messages span#msgtype").text("Message can be sent to 1 or more member"); break;
			case "MR": $("#send_messages span#msgtype").text("Meeting request can be sent to 1 or more member"); break;
			case "GM": $("#send_messages span#msgtype").text("Message will be sent to all registered members as a general message"); break;
			case "HD": $("#send_messages span#msgtype").text("Message will be sent to all registered members in Help Desk block seeking help"); break;
		}
	});
	
	$("#send_messages textarea, .MessageComposer textarea").keyup(function(){
		//alert($(this).val().length);
		if($(this).val().length<=500){
			$("p#tot_char span").text((500-$(this).val().length));
		}else{
			$(this).val($(this).val().substring(0,500));
		}
	});
	
	$('.MessageComposer .reply_button').click(function(e){
		_from=$("input#msg_from").val();
		_to=$("<li>").attr('id',$("input#msg_to").val());
		_subject=$("input#subject").val();
		_message_type=$("input#message_type").val();
		
		//alert(_from+" - "+_to+" - "+_subject);
		
		if($(".MessageComposer textarea").val().length){
			_msgContent=$(".MessageComposer textarea").val();
		}else{
			$(".MessageComposer .UIComposer_InputArea_Base").css({ borderColor:'red' }).focus();
			return false;
		}		
		
		$(".MessageComposer #busy").css({visibility:'visible'});
		replyMessage(_from,_to,_subject,_msgContent,_message_type,$(".MessageComposer #busy"));
		e.preventDefault();
	});
	
	$(".MessageComposer textarea").click(function(){
		$(".MessageComposer .UIComposer_InputArea").css({borderColor:'#8496BA'});
	});
	
	$(".msg_board .delete_button").click(function(){
		if(confirm("Are you sure you want to delete the message??\r\n This will delete mail permanently")){
			deleteMessage($(this));
		}
	});
	
	$(".msgSelectList a").click(function(e){
		e.preventDefault();
	});
	
	$(".msgSelectList #all").click(function(){
		$(".msgThreadRow input'[type=checkbox]'").attr('checked','true');
	});
	
	$(".msgSelectList #none").click(function(){
		$(".msgThreadRow input'[type=checkbox]'").attr('checked','');
	});
	
	$(".msgSelectList #unread").click(function(){
		$(".msgThreadRow input'[type=checkbox]'").attr('checked','');
		$(".msgThreadRow.unread input'[type=checkbox]'").attr('checked','true');
	});
	
	$(".msgSelectList #checkDelete").click(function(){
		if(confirm("Are you sure you want to delete the message??\r\nThis will delete mail permanently")){
			$(".msgThreadRow input'[type=checkbox]'").each(function(){
				if($(this).is(':checked')){
					$newObj=$("<a></a>").attr("href","#msgThreadRow_"+$(this).val()).attr('rel',$(this).val());
					deleteMessage($newObj);
				}
			});
		}
	});
	
});
/*REGISTER PAGE DESIGN*/
$(document).ready(function(){
						   
	$('.tell_friend #membership_type').change(function(){
		if($(this).val()=="IND-SP" || $(this).val()=="COR-SP"  ){
			$('div#spouse').css({ display:'block' });
			$('div#company').css({ display:'none' });
		}else if($(this).val()=="IND"){
			$('div#spouse').css({ display:'none' });
			$('div#company').css({ display:'none' });
		}else{
			$('div#spouse').css({ display:'none' });
			$('div#company').css({ display:'block' });
		}
		if($(".tell_friend #terms").is(":visible")){
			$(".tell_friend #terms").slideUp('slow');
			$(".tell_friend #terms").text('Show');
		}
	});
	$('.terms a').click(function(e){
		e.preventDefault();
		if(!$("#"+$(this).attr('rel')).is(":visible")){
			$("#"+$(this).attr('rel')).slideDown();
			$(this).text('Hide')
		}else{
			$("#"+$(this).attr('rel')).slideUp();
			$(this).text('Show')
		}
		
	});
	
	$('.tell_friend #send').click(function(e){
		e.preventDefault();
		userInfo=[];
		
		if($(".tell_friend #f_name").val().length){
			userInfo._fname=$(".tell_friend #f_name").val();
		}else{
			$(".tell_friend #f_name").css({ borderColor:'red' }).focus();
			return false;
		}
		
		if($(".tell_friend #l_name").val().length){
			userInfo._lname=$(".tell_friend #l_name").val();
		}else{
			$(".tell_friend #l_name").css({ borderColor:'red' }).focus();
			return false;
		}
		
		if($(".tell_friend #dob").val().length){
			userInfo._extraInfo = "Date of Birth: "+$(".tell_friend #dob").val()+"<br><br>";
		}else{
			$(".tell_friend #dob").css({ borderColor:'red' }).focus();
			return false;
		} 
		
		if($(".tell_friend #email").val().length){
			userInfo._email=$(".tell_friend #email").val();
		}else{
			$(".tell_friend #email").css({ borderColor:'red' }).focus();
			return false;
		}
		
		if($(".tell_friend #spouse").is(":visible")){
			if($(".tell_friend #spouse_name").val().length){
				userInfo._extraInfo +="Spouse Name: "+$(".tell_friend #spouse_name").val();
			}else{
				$(".tell_friend #spouse_name").css({ borderColor:'red' }).focus();
				return false;
			}
		}
		
		if($(".tell_friend #company").is(":visible")){
			if($(".tell_friend #company_name").val().length){
				userInfo._extraInfo +="Company Name: "+$(".tell_friend #company_name").val();
			}else{
				$(".tell_friend #company_name").css({ borderColor:'red' }).focus();
				return false;
			}
		}
		
		if($(".tell_friend #qualification").is(":visible")){
			if($(".tell_friend #qualification").val().length){
				userInfo._extraInfo +="Qualification: "+$(".tell_friend #qualification").val();
			}else{
				$(".tell_friend #qualification").css({ borderColor:'red' }).focus();
				return false;
			}
		}
		
		userInfo._memtype=$('.tell_friend #membership_type').val();
		userInfo._regtype=$(".tell_friend #reg_type").val();
		
		if(!$('.tell_friend #terms_agree').is(":checked")){
			alert("Please agree terms and conditions before submitting the registration request.");
			return;
		}		
		
		get_email = $(".tell_friend #email").val();

		$.ajax({
		  type: 'POST',
		  url:'common/ajax.php',
			data: ({action:'check-login_id', email:get_email }),
			success:function(response){ 	//alert(response); //return;
				if(response=="1"){
					alert("An email is alerady present. Please use different email address. ");
					return false;
				}else{
					$("img#busy").css({ visible:'visible'});
					sendRegReq(userInfo,$("img#busy"));	
				}
		   }
		});
		
	});
	
	$(".tell_friend #email").focusout(function() {
		//get_email = $(".tell_friend #email").val();
	});
	
	$(".tell_friend #f_name, .tell_friend #l_name, .tell_friend #dob, .tell_friend #email, .tell_friend #spouse_name, .tell_friend #company_name").click(function(){
		$(this).css({ borderColor:'#CCCCCC' });
	});
	
});

//CHANGE PASSWORD
$(document).ready(function(){
	$("#changepassword #submit").click(function(){
		if(!$("#changepassword #curr_pass").val().length){
			$("#changepassword #curr_pass").css({ borderColor:'red' });
			return false
		}
		
		if(!$("#changepassword #new_pass").val().length){
			$("#changepassword #new_pass").css({ borderColor:'red' });
			return false
		}
		
		if(!$("#changepassword #re_pass").val().length){
			$("#changepassword #re_pass").css({ borderColor:'red' });
			return false
		}
		
		if($("#changepassword #new_pass").val()!=$("#changepassword #re_pass").val()){
			$(".err #re_pass").text("Password Dont Match").css({ fontWeight:"bold" }).show("slow");
			$("#changepassword #re_pass,#changepassword #new_pass").css({ borderColor:'red' });
			return false
		}
		
		changePass($("#changepassword #curr_pass").val(),$("#changepassword #new_pass").val(),$("#changepassword #user_id").val());
		
	});
	
	$("#changepassword #curr_pass").keypress(function(){
		$("#changepassword #curr_pass").css({ borderColor:'#CCCCCC' });
		if($(".err #curr_pass").is(":visible")){
			$(".err #curr_pass").hide();
		}
	});
	
	$("#changepassword #new_pass").keypress(function(){
		$("#changepassword #new_pass").css({ borderColor:'#CCCCCC' });
		if($(".err #re_pass").is(":visible")){
			$(".err #re_pass").hide();
		}
	});
	
	$("#changepassword #re_pass").keypress(function(){
		$("#changepassword #re_pass").css({ borderColor:'#CCCCCC' });
		if($(".err #re_pass").is(":visible")){
			$(".err #re_pass").hide();
		}
	});
	
});

//FORGOT PASSWORD
$(document).ready(function(){
	$("#forgotpassword #submit").click(function(){
		if(!$("#forgotpassword #email_id").val().length){
			$("#forgotpassword #email_id").css({ borderColor:'red' });
			return false
		}
		
		if($("#forgotpassword #new_pass").val()!=$("#changepassword #re_pass").val()){
			$(".err #re_pass").text("Password Dont Match").css({ fontWeight:"bold" }).show("slow");
			$("#changepassword #re_pass,#changepassword #new_pass").css({ borderColor:'red' });
			return false
		}
		
		if(!isValidEmailAddress($("#forgotpassword #email_id").val())){
			$(".err #email_id").text("Not a valid address").css({ fontWeight:"bold" }).show("slow");
			$("#changepassword #re_pass,#changepassword #new_pass").css({ borderColor:'red' });
			return false
		}
		
		forgotPass($("#forgotpassword #email_id").val());
	});
	
	$("#forgotpassword #email_id").keypress(function(){
		$("#forgotpassword #email_id").css({ borderColor:'#CCCCCC' });
		if($(".err #email_id").is(":visible")){
			$(".err #email_id").hide();
		}
	});
	
});

//ARTICLE PAGE
$(document).ready(function(){
	$(".article #button").click(function(){
		$(this).parents(".editor").size() ?_selectorId=$(this).parents(".editor").attr('id') :  _selectorId="albuminfo";
		//return false;
		if(!$("#"+_selectorId+" #art_name").val().length){
			$("#"+_selectorId+" #art_name").css({ borderColor:'red' });
			return false;
		}
		
		$("#"+_selectorId+" select").each(function(){
			if($(this).val()==-1){
				$(this).css({ borderColor:'red' });
				return false;
			}
		});
		
		$("#"+_selectorId+" .article img#busy").css({ visibility:'visible' });
		
		addArticle($("#"+_selectorId+" #article_id").val(),$("#"+_selectorId+" #art_name").val(),$("#"+_selectorId+" select"));
	});
	
	/*$(".editor #button").click(function(){
		_boxSelector=$(this).parents(".editor").attr('id');
		alert(_boxSelector);
		/*if(!$("#albuminfo #art_name").val().length){
			$("#albuminfo #art_name").css({ borderColor:'red' });
			return false
		}
		
		$("#albuminfo select").each(function(){
			if($(this).val()==-1){
				$(this).css({ borderColor:'red' });
				return false
			}
		});
		
		addArticle($("#albuminfo #article_id").val(),$("#albuminfo #art_name").val(),$("#albuminfo select"));
	}); */
	
	$("#albuminfo #art_name").keypress(function(){
		$(this).css({ borderColor:'#999999' });
	});
	
	$("#albuminfo select").change(function(){
		$(this).css({ borderColor:'#999999' });	
	});
	
	$(".bullet_list #edit a.edit").click(function(){
		_link=$(this);
		_parentLI=$(this).parents("li"+$(this).attr("href"));	//alert($(_parentLI).size());
		//alert($(_parentLI).children("div"+$(this).attr("href")).size());
		$(_parentLI).children("div"+$(this).attr("href")).is(":visible") ? $(_parentLI).children("div"+$(this).attr("href")).slideUp("slow",function(){ $(_link).text("Edit") }) : $(_parentLI).children("div"+$(this).attr("href")).slideDown("slow",function(){ $(_link).text("Cancel") });
		//$(_parentLI).children("div"+$(this).attr("href")).slideDown("slow");
		return false;
	});
	
	$(".bullet_list #edit a.delete").click(function(){
		_link=$(this);
		_parentLI=$(this).parents("li"+$(this).attr("href"));	//alert($(_parentLI).size());
		if(confirm("Delete article?")){ deteleArticle($(this)); }
		//alert($(_parentLI).children("div"+$(this).attr("href")).size());
		//$(_parentLI).children("div"+$(this).attr("href")).is(":visible") ? $(_parentLI).children("div"+$(this).attr("href")).slideUp("slow",function(){ $(_link).text("Edit") }) : $(_parentLI).children("div"+$(this).attr("href")).slideDown("slow",function(){ $(_link).text("Cancel") });
		//$(_parentLI).children("div"+$(this).attr("href")).slideDown("slow");
		return false;
	});
})
