function toCamelCase(str) { return str.replace(/(?:^|\s)\w/g, function(match) { return match.toUpperCase(); }); }
(function($){
		
  $.fn.toQueryString = function() { var str = this.serialize(); var sep = (str != '') ? '&' : ''; $.each($('section[contenteditable=true]'), function() { str += sep + $(this).attr('id') + '=' + encodeURIComponent($(this).text()); sep = '&'; }); return str; };
  $.fn.kkCheck = function() { this.each(function() { $(this).addClass('hidden'); var id = $(this).attr('id'); var chkId = 'kk-chk-'+id; var checked = ($('#'+id).attr('checked') == 'checked') ? 'checked' : ''; $('<div class="kk-chk '+checked+'" id="'+chkId+'"></span></div>').insertAfter($(this)); $('#'+chkId).bind('click', function(e) { $('#'+chkId).toggleClass('checked'); if ($('#'+chkId).hasClass('checked')) $('#'+id).attr('checked', 'checked'); else $('#'+id).removeAttr('checked', '') }); $('label[for="'+id+'"]').bind('click', function(e) { e.preventDefault(); $('#'+chkId).toggleClass('checked'); if ($('#'+chkId).hasClass('checked')) $('#'+id).attr('checked', 'checked'); else $('#'+id).removeAttr('checked', '') }); }); };
  $.fn.kkChosen = function() { this.each(function() { $(this).addClass('hidden'); var selectId = $(this).attr('id'); var selectedValue = $(this).val(); var selectedText = $("#"+selectId+" option:selected").text(); var chosenId = 'kk-'+selectId; var chosenBoxId = chosenId + '-box'; $('#'+chosenId).remove(); $('#'+chosenBoxId).remove(); $('<div class="kk-chosen" id="'+chosenId+'"><span class="kk-chosen-text">'+selectedText+'</span><span class="kk-chosen-arrow"></span></div>').insertAfter($(this)); var opt = ''; $('#'+selectId+' option').each(function () { opt += selectedValue == $(this).val() ? '<li class="selected" role="'+$(this).val()+'">'+$(this).text() + '</li>' : '<li role="'+$(this).val()+'">'+$(this).text() + '</li>'; }); $('<ul class="kk-chosen-box" id="'+chosenBoxId+'" style="display: none;">'+opt+'</ul>').insertAfter($(this)); $('#'+chosenId).bind('click', function(e) { $('#'+chosenBoxId).toggle().css('top', (parseInt($(this).position().top)+parseInt($(this).outerHeight(true)))).css('left',$(this).position().left); }); $('#'+chosenBoxId+' li').die(); $('#'+chosenBoxId+' li').live('click', function(e) { $('#'+chosenBoxId+' li').removeClass('selected'); $(this).addClass('selected'); $('#'+chosenBoxId).hide(); $('#'+chosenId+' .kk-chosen-text').text($(this).text()); $('#'+selectId).val($(this).attr('role')); if ($('#'+selectId).attr('onchange') != 'undefined') $('#'+selectId).change(); }); $(document).mouseup(function(e) {if($(e.target).parent('#'+chosenBoxId).length==0) { $('#'+chosenBoxId).hide(); } }); }); };
    
})(jQuery);

	function nav(url)
	{
		window.location = url;
	}
	function popup(url)
	{
		var win  = window.open(url,'name','height=600,width=500,left=300,top=150,resizable=no,scrollbars=yes,toolbar=no,status=no');
		if (window.focus)
		{
			win.focus();
		}
	}
	
	function text2clipboard(el, text, flashpath)
	{
		if(window.clipboardData && clipboardData.setData)
		{
			clipboardData.setData("text", text);
		}
		else
		{
			ffcopy(el, flashpath);
		}
	}
	
	function ffcopy(el, flashpath)
	{
		if (el.createTextRange)
		{
			var range = el.createTextRange();
			if (range && BodyLoaded==1)
				range.execCommand('Copy');
		}
		else
		{
			var flashcopier = new Element("div");
			document.body.appendChild(flashcopier);
			
			var flashobject = '<embed src="'+flashpath+'_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(el.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
			flashcopier.set('html', flashobject);
		}
	}
	
	$(function() {
		
		var _search = true;
		$('.search').bind('click', function() {
			$('#content').animate({ opacity: ((_search) ? 0.1 : 1) }, 100);
			$('#sidebar').animate({ opacity: ((_search) ? 0.1 : 1) }, 100);
			$('#search-wrap').fadeToggle("fast", "linear");
			_search = !_search;
		});
		
		$('#search-form').submit(function() {
		  window.location = $('#search-form').attr('action')+$('#search-input').val();
		  return false;
		});
		$('#search-form2').submit(function() {
		  window.location = $('#search-form2').attr('action')+$('#search-input2').val();
		  return false;
		});
		
		$('#categoryselect').change(function() {
		  var x1 = (p2 == 'popular' || p2 == 'latest') ? p2 : 'popular'
		  window.location = c_web + 'browse/photos/' + x1 + '/' + $('#categoryselect').val();
		  return false;
		});
		
		$('#report-image').click(function() {
		  $('.report-wrap').fadeToggle();
		  return false;
		});
		
		
		if (document.body.scrollHeight - document.body.clientHeight > 10 ) $('#footer').css('position', 'relative');
	});
	


