//generall global pure JS variables
var city;
var country;
var geoname;
var geoname_;
var geo;

//lengt of contentarea
var clen;


//geo stuff
//WRAPPER FÜRS GEOTAGGING
function setGeo()
{
					city = google.loader.ClientLocation.address.city;
    				if(!city)
    				{
    					//city = geoplugin_region();
    					city=google.loader.ClientLocation.address.region;
    				}
    				
    				//country = geoplugin_countryName();
    				country = google.loader.ClientLocation.address.country;
    				if(city&&country)
    				{
    					geoname = city+', '+country +' ('+google.loader.ClientLocation.address.country_code+')';
    					geoname_ = geoname+' - ';
    				}
    				else
    				{
    				  geoname = '';
    				  geoname_ = geoname; 
    				 }
    				 
    				// var geolat=geoplugin_latitude();
    				// var geolon=geoplugin_longitude();
    				var geolat=google.loader.ClientLocation.latitude;
    				var geolon=google.loader.ClientLocation.longitude;
    				 if(geolat&&geolon)
    				 {
    				 	geo=geolat+', '+geolon;
    				 }
    				 else
    				 {
    				 	geo = '';
    				 }
    				 $("#geo").val(geo);
    				 $("#geoname").val(geoname);
}


//start date stuff

/*
 * Date Format 1.2.3
 * (c) 2007-2009 Steven Levithan <stevenlevithan.com>
 * MIT license
 *
 * Includes enhancements by Scott Trenda <scott.trenda.net>
 * and Kris Kowal <cixar.com/~kris.kowal/>
 *
 * Accepts a date, a mask, or a date and a mask.
 * Returns a formatted version of the given date.
 * The date defaults to the current date/time.
 * The mask defaults to dateFormat.masks.default.
 */

var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;

		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date;
		if (isNaN(date)) throw SyntaxError("invalid date");

		mask = String(dF.masks[mask] || mask || dF.masks["default"]);

		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":      "ddd mmm dd yyyy HH:MM:ss",
	shortDate:      "m/d/yy",
	mediumDate:     "mmm d, yyyy",
	longDate:       "mmmm d, yyyy",
	fullDate:       "dddd, mmmm d, yyyy",
	shortTime:      "h:MM TT",
	mediumTime:     "h:MM:ss TT",
	longTime:       "h:MM:ss TT Z",
	isoDate:        "yyyy-mm-dd",
	isoTime:        "HH:MM:ss",
	isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
	isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
	monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};

//end date stuff

//htmlencode and decode stuff
function htmlEncode(value){ 
  return $('<div/>').text(value).html(); 
} 

function htmlDecode(value){ 
  return $('<div/>').html(value).text(); 
}

//helper function stuff 
//SETCURSORPOITION 
new function($) {
  $.fn.setCursorPosition = function(pos) {
    if ($(this).get(0).setSelectionRange) {
      $(this).get(0).setSelectionRange(pos, pos);
    } else if ($(this).get(0).createTextRange) {
      var range = $(this).get(0).createTextRange();
      range.collapse(true);
      range.moveEnd('character', pos);
      range.moveStart('character', pos);
      range.select();
    }
  }
}(jQuery);

///***************************************************
//start own code
// ONLOAD
//aller document onload crap
$(function()
{

 if($('#messagebox').length!=0)
 {
 	//$('#messageboxcontent').hide();
 }
 //wenn ein webcam objekt auf der seit ist
 if($('#cam').length!=0)
 {
 	//onload wird das formular disable
 	$('#commentform').submit(function(){ return false;});
 	$('#submitbutton').click(function(){return false;});
 	$('#submitbutton').css('color', 'lightgray');
	//document.getElementById('commenttxt').value='';document.getElementById('commenttxt').focus();
 	$('#commenttxt').val('');
 	$('#commenttxt').focus();
 	$('#uid').val('');
 	
 	$('#commenttxt').bind('keyup', function() { commenttxtLimit(); });
 	
 		//geo sachen setzen
	setGeo();
 }
 
 // WENN EINE PICAREA EXISTIERT
 if($('#picarea').length!=0)
 {
 	
 	$('#replybutton').click(
 	function() { $(location).attr('href',replyurl+uid); }
 	);
 	
 	checkReply(uid);
 	/*var intervalID = window.setInterval(function()
     {
		checkReply(uid);
	},20000);*/
	
	checkImageStat();
 	
 }
 
 //wenn die share links existieren
  if($('#shareit').length!=0)
 {
 		$('#shareit').click(function(event){
 		event.preventDefault();
 		//$('#shareitbox').toggle();
 		//visible
 		if($('#shareitbox').css('visibility')=='hidden')
 		{
 			$('#shareitbox').css('visibility', 'visible'); 
 			//alert('hi');
 			changeShareitBox();
 		}
 		else
 		{
 			$('#shareitbox').css('visibility', 'hidden'); 
 		}
 		});
 }
 //googlebuzzlink
  if($('#googlebuzzlink').length!=0)
 {
 	$('#googlebuzzlink').mousedown(function(event){event.preventDefault();
 		$('#googlebuzzlink').attr('href', 'http://www.google.com/reader/link?url='+encodeURIComponent(pagebase+uid)+'&title='+encodeURIComponent($('title').text())+'&snippet='+encodeURIComponent('<a href="'+pagebase+uid+'">'+pagebase+uid+'</a> - '+$('#pictext cite').text()+'<img src="'+optbase+uid+'.jpg"><br><a href="'+replyurl+uid+'">Reply to this picture.</a>')+'&srcTitle='+encodeURIComponent("Replycam.com - super social webcam booth")+'&srcUrl='+encodeURIComponent(domain));
 		$('#googlebuzzlink').attr('target','_blank');
 		});
 }
 
 //'javascript:var%20b=document.body;var%20GR________bookmarklet_domain=&quot;http://www.google.com&quot;;if(b&amp;&amp;!document.xmlVersion){void(z=document.createElement(&quot;script&quot;));void(z.src=&quot;http://www.google.com/reader/ui/link-bookmarklet.js&quot;);void(b.appendChild(z));}else{}'
 
 //twitterlink
 //http://twitter.com/?status=
   if($('#twitterlink').length!=0)
   {
   		$('#twitterlink').mousedown(function(event){event.preventDefault();
 		$('#twitterlink').attr('href', 'http://twitter.com/?status='+encodeURIComponent(pagebase+uid+' ')+$('#pictext cite').text());
 		$('#twitterlink').attr('target','_blank');
 		});
   }
 
 //facebooklink
// http://www.facebook.com/sharer.php?u=<url to share>&t=<title of content>
  if($('#facebooklink').length!=0)
 {
 	$('#facebooklink').mousedown(function(event){event.preventDefault();
 	$('#facebooklink').attr('href', 'http://www.facebook.com/sharer.php?u='+encodeURIComponent(pagebase+uid)+'&t='+encodeURIComponent("Reply to this picture "+$('title').text()));
 		$('#facebooklink').attr('target','_blank');
 	});
 }
 
 //WENN EIN RETHUMB EXISITERT
 if($('#rethumb').length!=0)
 	{
 		//alert('rethumb');
 		//alert('rethumb');
 		
 		$('#rethumb').css('margin', '-2 0 0 0').css('border', '2px solid #FFCC33');
 		window.setTimeout(function(){$('#rethumb').css('margin', '0 0 0 0').css('border', 'none');window.setTimeout(function(){$('#rethumb').css('margin', '-2 0 0 0').css('border', '2px solid #FFCC33');window.setTimeout(function(){$('#rethumb').css('margin', '0 0 0 0').css('border', 'none');}, 1000);}, 1000);}, 500);
 		
 		$('#rethumb').hover(
 		function()
 		{
 			$(this).css('margin', '-2 0 0 0');
 			$(this).css('border', '2px solid #FFCC33');
 			//alert('over');
 		},
 		function()
 		{
 			$(this).css('margin', '0 0 0 0');
 			$(this).css('border', 'none');
 			//alert('out');
 		}
 		);
 		
 		$('#rethumb').parent('a').click(function(event)
 		{
 			event.preventDefault();
 			var request_uid=$('#rethumb').attr('src');
 			//alert(request_uid);
 			request_uid=request_uid.substr(request_uid.lastIndexOf('/')+1,request_uid.length-(request_uid.lastIndexOf('.')-1));
 			//alert(request_uid);
 			$.getJSON(jsongeturl+request_uid, '', function(data){
 				//alert(data.timestamp);
 				uid=data.uid;
 				ruid=data.re;
 				setImage(uid, data.txt, ruid);
 				
 			});
 			
 		
 		});
 	}
 
 //WENN EIN PICVIEW EXISTIERT
 if($('.rowthumb').length!=0)
 {
 	//alert('hi');
 	if($('#currentpic_bg').length!=0)
 	{
 		//CLICK AUF EIN PICVIEW
 		$('.rowthumb').parent('a').click(function(event){event.preventDefault();
 		uid=$(this).attr('uid');
 		ruid=$(this).attr('ruid');
 		var txt = decodeURIComponent($(this).attr('txt').replace(/\+/g, '%20'));
 		setImage(uid, txt, ruid);
 		});
 		
 	}
 	else
 	{
 		//alert('mach link stuff');
 	}
 	//alert('hi');
 }
 

	
/*	$.getJSON(jsongeturl+'bd3f0'+'&since=true',
        function(data){ alert(item);
          $.each(data.items, function(i,item){
            alert(item.uid);
          });
        });*/
        var intervalID = window.setInterval(function()
        {
        	
        	if(latestUid==''|latestUid=='false'|latestUid==undefined)
        	{
        		latestUid=$('.liveupdate').eq(0).attr('uid');
        		if(debug==1)
        		{
        		alert(latestUid+' new');
        		}
        	}
        	else
        	{
        		//	alert(latestUid+' set');
        		if(debug==1)
        		{
        		alert(' no latestUid');
        		}
        	}
        	//alert(latestUid);
        	//if(preLatestUid!=latestUid)
        	if(latestUid!=''&&latestUid!=false&&latestUid!=undefined)
        	{
        		//alert('hi');
        	//	alert('latestUid:'+latestUid+' preLatestuid:'+preLatestUid);
        		$.getJSON(jsongeturl+latestUid+'&since=true',
       			 function(data)
        			{	 
        				//alert(data[0]+' test ');
        				//$('#picin').scrollLeft(0);

        			     showdynimage(data, 0, 'liveupdate', justshotUid);
        			
 				});
        	
        		
        	}
        }, 5000);  
        

})
//onload crap ende



//FLASH FUNCTIONS
function messageUpload(message){     
		    // alert('test');
    			if(message.indexOf("http://") != -1)
    			{
    				//alert('test');
    				$('#commentform').unbind().submit(function(){ /*alert('hi');*/ });
 					$('#submitbutton').unbind().submit(function(){ alert('ho');});
 					$('#submitbutton').css('color', 'black');
    				uid=message.substr(message.lastIndexOf('/')+1, message.length-(message.lastIndexOf('.')-1));

    				//$('#picin').prepend();
    				
    				$("<a href='"+pagebase+uid+"' uid='"+uid+"' '><img src='"+message+"' class='rowthumb justshot' ></a>").prependTo('#picin').show();
    				//an uid for not loading the same pic with the next live update
					justshotUid=uid;
					$('#picin').scrollLeft(0);
					
					var m2=$("#commenttxt").val();
					
					if((m2.indexOf(geoname_))==-1)
					{
						/*var now = new Date();
						var nowdate = dateFormat(Date(), "dddd, mmmm dS, yyyy, h:MM:ss TT");*/

    					//$("#commenttxt").val(geoname_+dateFormat(Date(), "dddd, mmmm dS, yyyy, h:MM:ss TT")+' - '+m2);
    					var stuffstring=geoname_+''+' '+m2;
    					if((geoname_!='')&&(stuffstring!=undefined))
    					{
    						$("#commenttxt").val(geoname_+''+' '+m2);
    					}
    					commenttxtLimit();
    					
    				}
    				else
    				{
    					
    				}
    				
    				var len=$("#commenttxt").val().length;
    				//FF bug
    				//$("#commenttxt").focus().setCursorPosition(len);
					//alert('test');
    				
    				
    				$("#uid").val(uid);
    				
    				//alert($("#uid").val());
    				//$("#commenttxt").setSelectionRange(len,len);
    				
    				if($('#commentform').length==1)
    				{
    					$('#commentform').submit();
    					
    				}
    				else
    				{
    					document.location=pagebase+uid;
    							
    				}
    						
    				
    				
    			}
    			else
    			{
    				window.alert("error");
    			}
 				return;
			}
			
			//FLASH FUNCTION TAG FEEDBACK
			
			function getTag(message){        
    			//window.alert(message);   
    			
 				return;
			}
			
			//FLASH FUNCTION NO WEBCAM FOUND
			function noWebcamError(message) {
				$('#messagebox').attr('class', 'notice');
    			$('#messagebox').css('text-align', 'left');
    			$('#messagebox').html('Uh oh, we could not find <a href="/about/faq.php#nowebcam">your webcam</a>! Please see our <a href="/about/faq.php#nowebcam">FAQ</a>.');
				return;
			}
			
			



//COMMENT TXT LIMIT 140
function commenttxtLimit()
{
	
	clen = $('#commenttxt').val().length;
	if(clen>=140)
	{
		$('#commenttxt').val($('#commenttxt').val().substr(0,140));
		$('#charlimit').html(140);
		$('#charlimit').attr('style', 'color:black;font-weight:bold;');
	}
	else if(clen>=130)
	{
		$('#charlimit').html(clen);
		$('#charlimit').attr('style', 'color:red;font-weight:normal;');
	}
	else if(clen>=100)
	{
		$('#charlimit').html(clen);
		$('#charlimit').attr('style', 'color:black;font-weight:normal;');
	}
	else
	{
		if($('#charlimit').html()!='&nbsp;')
		{
			$('#charlimit').html('&nbsp;');
		}
	};
}

function changeShareitBox()
{
	$('#shareit_pagelink').attr('href', pagebase+uid);
	$('#shareit_pagelink').text(pagebase+uid);
	
	$('#shareit_imagelink').attr('href', pagebase+uid+'.jpg');
	$('#shareit_imagelink').text(pagebase+uid+'.jpg');
}

//PICVIEW SCHNELLERES IMAGE WECHSELN
function setImage(muid, txt, ruid)
{

	if($('#picarea').length==0)
 	{
 		$(location).attr('href',pagebase+muid);
 	}
 	else if($('#currentpic_bg').lenghth!=0)
	{
		uid=muid;
		//$('#currentpic_bg')
		//alert(uid);
		$('#currentpic_bg').css('background-image', "url('"+optbase+uid+".jpg')");
		makeAjaxUrl(muid);
		//alert(txt);
		if(txt!='')
		{
			$('#pictext').children('cite').text(txt);
		}
		else
		{
			$('#pictext').children('cite').text(' - no comment - ');
		}
		
		if(ruid&&ruid!='ruid')
		{
			if($('#rethumb'))
			{
				$('#rethumb').show();
				$('#rethumb').attr('src', minithumb+ruid+'.jpg');
				$('#rethumb').parent('a').attr('href', pagebase+ruid);
					$('#rethumb').css('margin', '-2 0 0 0').css('border', '2px solid #FFCC33');
 		window.setTimeout(function(){$('#rethumb').css('margin', '0 0 0 0').css('border', 'none');}, 1000);
			}
		}
		else
		{
			if($('#rethumb'))
			{
				$('#rethumb').hide();
			}
		}
		//alert(ruid);
		window.clearTimeout(replyloop);
		//wir ziehen den check image stat vor
		checkImageStat();
		//jetzt schaune wir nach replies
		checkReply(muid);
		
		if($('#shareitbox').css('visibility')!='hidden')
		{
			changeShareitBox();
		}
		
	}
	else
	{
		
	}
	
	if(uid!=muid&&muid!=false)
	{
		uid=muid;
	}
	pageTracker._trackPageview("/v/"+muid);
	//alert("/v/"+muid);
}

function makeAjaxUrl(uid)
{

	var cleanUrl=document.location+'';
	if(cleanUrl.indexOf('#!')!=-1)
	{
		cleanUrl=cleanUrl.substr(0,cleanUrl.indexOf('#!'));
	}
	document.location=cleanUrl+'#!'+uid;
	return true;
}

function checkImageStat()
{
	deleteGenderDom();
	deleteSmileDom();
 	$.getJSON('http://replycam.com/api/gendersmileimages.php?uid='+uid, function(data)
 	{
  		if(data['smile'])
  		{
  			createSmileDom(data['smile']);
  		}
  		else
  		{
  		   deleteSmileDom();
  		}
  		
  		if(data['gender'])
  		{
  			createGenderDom(data['gender']);
  		}
  		else
  		{
  		   deleteGenderDom();
  		}
	});

}

function createGenderDom(anUrl)
{
	//alert('gender');
	//alert(anUrl);
	$('#socialbox').append('<a href="/docs/faq.php#gender" id="genderstat" class="genderclass" ><img src="'+anUrl+'"  style="display:block;" border="0" title="Gender-O-Meter"></a>').hide().fadeIn(200);
	//alert(anUrl);
}

function deleteGenderDom()
{
	//alert('gender false');
	if($('#genderstat').length>0)
		{
			//$('#genderstat').hide(500, function(){$('#genderstat').remove();});
			//$('#genderstat').remove();
			$('.genderclass').remove();
		}
}

function createSmileDom(anUrl)
{
	//alert('smile');
	//alert(anUrl);
	$('#socialbox').append('<a href="/docs/faq.php#smile" id="smilestat" class="smileclass" ><img src="'+anUrl+'"  style="display:block;" border="0" title="Smile-O-Meter" ></a>').hide().fadeIn(200);
}

function deleteSmileDom()
{
		//alert('smile false');
		if($('#smilestat').length>0)
		{
			//$('#smilestat').hide(500, function(){$('#smilestat').remove();});
			//$('#smilestat').remove();
			$('.smileclass').remove();
		}
}

function checkReply(thisuid)
{
 	$.getJSON('http://replycam.com/api/count.php?uid='+thisuid,
    function(data)
    {	 
    	$('#replycount').unbind('click');
        //alert(data[0]);
        if(data[0]==1)
        {
        	$('#replycount').unbind('click');
        	$('#messageboxcontent').html('This pic has <a href="http://replycam.com/" id="replycount" class="replieslink" >'+data[0]+' Reply</a>');
        	$('#messageboxcontent');
        }
        else if(data[0]>1)
        {
        	$('#replycount').unbind('click');
        	/*$('#messageboxcontent').fadeOut('slow', function() {
        		$('#messageboxcontent').html('This pic has <a href="http://replycam.com/" id="replycount" class="replieslink" >'+data[0]+' Replies</a>');}).fadeIn('slow');*/
        		$('#messageboxcontent').html('This pic has <a href="http://replycam.com/" id="replycount" class="replieslink" >'+data[0]+' Replies</a>');
        	$('#messageboxcontent').fadeIn('slow');
        }
        else
        {
        	//$('#replycount').remove();
        	$('#replycount').unbind('click');
            $('#messageboxcontent').html('<a href="http://replycam.com/" id="replyaction" class="replieslink" >Reply</a>');
            $('#replyaction').click(function(event){event.preventDefault(); $(location).attr('href',replyurl+uid);});
        }
        
        if($('#replycount').length!=0)
        {
        	$('#replycount').unbind('click');
        	//alert(uid);
        	$('#replycount').click(function(event){event.preventDefault();
 				$.getJSON(jsongeturl+uid+'&replyof=true',
       			 function(data)
        			{	 
        				//alert(data[1]);
        				$('#picin').scrollLeft(0);

        			     showdynimage(data, 0, 'reply');
        			
 				});
        	});
        }
    });
     replyloop = window.setTimeout(function()
     {
		checkReply(uid);
	},15000);
}

//dynamisches image einblenden
 function showdynimage(wholedata, z, whatcase, justshotUid)
        				{
        					var data=wholedata[z];
        					//alert(data.uid+' testcase');
        					if(data==false|data==undefined|data==-1)
        					{
        						//alert(z);
        						return false;
        					}
        					else
        					{
        						//alert('workit '+z);
        					}
        					//alert(z);
        					var imageborder='';
        					var aclass='';
        					if(whatcase=='reply')
        					{
        						imageborder='reborder';
        					}
        					else if(whatcase=='liveupdate')
        					{
        						//imageborder='';
        						aclass='liveupdate';
        						latestUid=data.uid;
        					}
        					else
        					{
        						whatcase='';
        					}
        					
        					if(data.re==uid)
        					{
        						imageborder='reborder';
        					}
        					
        				
        					z=z+1;
        					//alert(z+' after the next one');
        					if(justshotUid==data.uid)
        					{
        						showdynimage(wholedata, z, whatcase);
        					}
        					else
        					{
        					var dynimg=$("<a class='"+aclass+"' style='display:inline;' href='"+pagebase+data.uid+" ' uid='"+data.uid+"' ruid='"+data.re+"' txt=\""+data.txt+"\"  ></a>").click(function(event){event.preventDefault();setImage(data.uid, data.txt, data.re);}).hide().prependTo('#picin').prepend($("<img id='dym"+data.uid+"' src='"+thumbbase+data.uid+".jpg' class='rowthumb "+imageborder+"' style='display:inline'>")).hide().fadeIn('slow', function() {showdynimage(wholedata, z, whatcase);});
        					}
        			     }
        			     
        			     /*
        			          //, showdynimage(wholedata, z)
        			/*	$.each(data, function(i, data)
        				{
        					//alert(data['uid']);
        					//alert(jsongeturl+uid+'&replyof=true');
        					var dynimg=$("<a style='display:inline;' href='"+pagebase+data.uid+" ' uid='"+data.uid+"' ruid='"+data.re+"' txt=\""+data.txt+"\"  ></a>").click(function(event){event.preventDefault();setImage(data.uid, data.txt, data.re);}).hide().prependTo('#picin').prepend($("<img id='dym"+data.uid+"' src='"+thumbbase+data.uid+".jpg' class='rowthumb reborder' style='display:inline'>")).hide().fadeIn('slow');
 						}); */
 						
 						//alert('stop');
 						
 						/* $.getJSON(jsongeturl+latestUid+'&since=true',
       			 function(data)
        			{	 
        				//alert(data[0]);
        				$.each(data, function(i, data)
        				{
            			//alert(data[0].uid);
            			if(data.uid!=justshotUid)
            			{
            			var dynimg=$("<a class='liveupdate' style='display:inline;' href='"+pagebase+data.uid+" ' uid='"+data.uid+"' ruid='"+data.re+"' txt=\""+data.txt+"\"  ></a>").click(function(event){event.preventDefault();setImage(data.uid, data.txt, data.re);}).hide().prependTo('#picin').prepend($("<img id='dym"+data.uid+"' src='"+thumbbase+data.uid+".jpg' class='rowthumb' style='display:inline'>")).hide().fadeIn('slow');
            			}
							latestUid=data.uid;
          				});

        			});*/
        		//prelatestUid=latestUid;
        			     
        			    
