/* * To change this template, choose Tools | Templates * and open the template in the editor. */$(document).ready(function() {	$('.clickedImg').click(function(){              var src = $(this).attr('src');       var Orisrc = src;	   imgTitle = $(this).attr('alt');       src = src.replace("90x60", "305x230");       Orisrc = Orisrc.replace("90x60", "ori");              $('#viewimage').attr("src", src);       $('#viewimage').attr("title", imgTitle);       $('#viewimage').attr("alt", imgTitle);       $('#oriSrc').attr("href", Orisrc);            });	$('#followmem').click(function(){			fl = $('#followTarget').val();				$.getJSON('./../follow/'+fl, function(data) {				});	});	$('#follownonmem').click(function(){//this is the good one			fl = $('#followTarget').val();	//			$.getJSON('./../follow/'+fl, function(data) {	//			});						ft = $('#followTarget').val();			    	    tb_show("You must login before you can follow someone!", public_path + '/login/login/modal?height=320&width=670&following=' + ft + '&action=loginthenfollow&junk/account/view/'+ft);					// Make it available in DOM tree//			$caption.appendTo(".member #ratings");										});	$('#selFavoritemem').click(function(){				fv = $('#item_id').val();				$.getJSON('./../favorite/'+fv, function(data) {				});		});				$('#selFavoritenonmem').click(function(){				fv = $('#item_id').val();	//			$.getJSON('./../favorite/'+fv, function(data) {	//			});	    	    tb_show("You must login before you can have a favorite project!", public_path + '/login/login/modal?height=320&width=670&favorite=' + fv + '&action=loginthenfavorite&junk/project/view/'+fv);	});			$('.comingSoon').click(function(){		alert('Coming soon!');	});			/* select content when on focus for shareurl input box */	$('.urlbg input').focus(function(){		$('.urlbg input').select();	});        	//select all the a tag with name equal to modal and fade in the reply dialog	$('a[name=modal]').click(function(e) {		//alert( 'replying to comment - link = '+$(this).attr('href'))		//Cancel the link behavior		e.preventDefault();		//Get the A tag		var id = $(this).attr('href');		//Get the screen height and width		var maskHeight = $(document).height();		var maskWidth = $(window).width();		//Set height and width to mask to fill up the whole screen		$('#mask').css({'width':maskWidth,'height':maskHeight});		//transition effect		$('#mask').fadeIn(1000);		$('#mask').fadeTo("slow",0.8);		//Get the window height and width		var winH = $(window).height();		var winW = $(window).width();		//Set the popup window to center	//	$(id).css('top',  winH/2-$(id).height()/2);	//	$(id).css('left', winW/2-$(id).width()/2);		//transition effect		$(id).fadeIn(2000);	});	//if close button is clicked, hide the reply dialog and unmask the page	$('.window .close').click(function (e) {		//Cancel the link behavior		e.preventDefault();		$('#mask, .window').hide();	});	//if mask is clicked unmask everything.  The mask is the translucent overlay that give the lightbox effect	$('#mask').click(function () {		$(this).hide();		$('.window').hide();	});});$(function() {	$(".answer .button").click(function() {		var start = $(this).parent().parent().parent().parent().parent().attr("id");		if($('#' +start + ' .answer textarea').val() != ""){			var dataString = '&answer=' + $('#' +start + ' .answer textarea').val() + '&qid=' + $('#' + start + ' .answer input.qid').val() ;			$.ajax({				type: "POST",				url: public_path+'/questions/answer',				data: dataString,				success: function(json) {					var qid ='#'+ start ;					$('#mask, .window').hide();					var div = $('<div></div>').addClass('answer').appendTo(qid).html(json["answer"]);					$('<div></div>').addClass('post-answer-label').appendTo(div).html("By " + json["member_name"]);					$(qid + ' .answer').effect("highlight", {}, 3000);				},				dataType: "json"			});		} else {			alert( "please add your answer" );			return false;			exit;		}		return false;	});}); /*this is for reply-to-comment*/$(function() {	$(".reply-to-comment .button").click(function() {		//alert( 'done with reply dialog' );		var start = $(this).parent().parent().parent().parent().parent().attr("id");		// var start =  form.name;		//         if($(this).closest('textarea').val() != ""){		var dataString = $(this).closest('form').serialize();		//alert( dataString );		$.ajax({			type: "POST",			url: public_path+'/comments/replyToComment/',			data: dataString,			success: function(json) {				if( json.status == 'OK' ) {					try {						//alert( 'status = OK' );						//    var qid ='#'+ start ;						var qid = '#comment_' + json.comment_id + '_main .nameDate';						$('#mask, .window').hide();						var div = $('<div></div>').attr('id', '#answer_' + json.comment_id).addClass('answer').appendTo(qid).html(json.reply);						$('#replyprompt'+json.comment_id).html('');						$(qid + ' .answer').effect("highlight", {}, 3000);					} catch(e) {						alert( "An exception occurred in the script. Error name: [" + e.name + "]. Error message: " + e.message);					}				} else {					alert( 'ERROR: '+json.message );				}			},			dataType: "json"		});		/*       }		else{		  alert("please add your answer");return false;exit;		}*/		return false;	});});/* will clean later */$(function() {	$(".comment .button").click(function() {		if($('.comment textarea').val() != ""){			if($('.comment #member_id').val() == ""){				var data = $("#add_comment").serialize();				tb_show( "You must login before you can post a comment", public_path + "/login/login/modal?height=225&width=650&"+data+'&action=addcomment&junk/project/view/'+$('#item_id').val() );				//    return false;			}			var dataString = $("#add_comment").serialize();			$.ajax({				type: "POST",				url: public_path+'/comments/addComment',				data: dataString,				success: function(json) {					var qid ='#project_comment_area' ;					var cid = '#comment_'+ json["comment_id"]+'_main';					var div = $('<div></div>').addClass('cPostHolder').attr('id', 'comment_'+ json["comment_id"]+'_main').prependTo(qid);					var div2= $('<div></div>').addClass('cPic').appendTo(div).html('<img src="' + json["photo"] +'" alt="' +json["member_name"] +'" width="45" height="60" />');					var div3= $('<div></div>').addClass('cPost').appendTo(div);					var div4 = $('<div></div>').addClass('nameDate').appendTo(div3).html('<a href="' + json['path'] + '">' + json["member_name"] +'</a>' + " " + json["date"]);					var div5 = $('<div></div>').appendTo(div4).html('<p>' + json["comment"] + '</p>');					var d = $('<div></div>').addClass('dividerBrow').prependTo(div);					$('.comment textarea').val('');					$(cid).effect("highlight", {}, 3000);				},				dataType: "json"			});		} else {			alert("please add your comment");			return false;			exit;		}		return false;	});});if($('textarea')){$(document).ready(function() {			// Default                         $('textarea#comment').inputlimiter({				limit: 1000,                                boxId: 'counter',				boxAttach: true			});                        $('textarea#answer').inputlimiter({                            limit: 1000,                            boxId: 'counter',                            boxAttach: true                        });                        $('textarea#status').inputlimiter({                            limit: 150,                            boxId: 'counter',                            boxAttach: true                        });			$('textarea#question').inputlimiter({				limit: 120,                                boxId: 'counter',				boxAttach: true			});                        $('textarea').not('.short_description').not('#question').focus(function(){$('textarea').val('');});			// Make it more personal                        $('textarea#question').val('Ask a question');});}
