$(document).ready(function(){
	
	$(".tooltip").simpletooltip(); 
	
	
	$('a').each(function(){
		$(this).bind('focus', function(){
			$(this).blur();	})
	});
	

	/*$('.item.photographer .photographerDetails .title h2').bind('click',function() {*/
	$('.item.photographer .photographerDetails .title h2').each(function(i){
		var clickurl = $(this).find('a').attr('href');
		$(this).parent().parent().parent().bind('click',function() {
			/*window.location = ''+clickurl+'';*/
		});
			
	});
		
	
	$(".imagebox").fancybox();
	
	
	
	tooltip('.ImageContainer','additionalInfo');
	clearInputFields();
	lensesTableHover();
        cameras_questionteaser_item();

	$('.glossars_rootItem').each(function(){
		 $(this).bind('click', function(){ ElementDropdown(this); })
	});	
});

function ElementDropdown(element){
 if ($(element).next().css("display") == "block"){
 	$(element).next().slideUp(100);
 } else {
 	$(element).next().slideDown(100);
 }
}



function clearInputFields() {
 $('input[type=text]:not(.no-auto-clear)').each(function(){
 var startText = $(this).val();
 $(this).bind('focus', function(){
 startText = $(this).val();
 $(this).val('');
 });
 });
}

function tooltip(target_items, contentData){ 
$(target_items).each(function(i){
	var htmlData = $(this).parent().find("."+contentData).html();
 if(htmlData !=null) {	
	 $("body").append("<div class='"+contentData+"' id='"+contentData+i+"'>"+htmlData+"</div>");
	 var tooltip = $("#"+contentData+i);
	
	 $(this).hover(function(kmouse){
		 tooltip.css({left:kmouse.pageX+10, top:kmouse.pageY+5});
		 tooltip.show();
		  $(this).mousemove(function(kmouse){
			 tooltip.css({left:kmouse.pageX+10, top:kmouse.pageY+5});
			 tooltip.show();
		  });
	 },function(){
	 tooltip.hide();
	 });
 }
 });
}

var htmlcontainer = null;
var quantity = 1;
function rpc_single_camera(ajaxurl, htmlcontainer, quantity) {
  $.ajax({
    type: 'POST',
    dataType: 'html',
    cache: false,
    data: "limit="+quantity+"",
    url: ajaxurl,
    beforeSend: function() {
      $(htmlcontainer).fadeOut('slow');
      $(htmlcontainer).fadeIn('fast').html('<div class="ajax_loading">&nbsp;</div>');
    },
    success: function(htmlData) {
     $(htmlcontainer).fadeIn('slow').html(htmlData);
      window.setTimeout("rpc_single_camera('"+ajaxurl+"', '"+htmlcontainer+"', "+quantity+")",8000);
    },
    complete: function(){
    }
  });
}



function lensesTableHover() {
	$('.objektiveTable tbody tr').each(function(i) {
		$(this).hover(function () {			
	        $(this).css({'background':'#edf0e8'});
	      }, 
	      function () {	      	
	        $(this).css({'background':'none'});
	     }
	    );
	});
}

function cameras_questionteaser_item() {
	$('.cameras_questionteaser_item').each(function(i) {
		$(this).hover(function () {
	        $(this).addClass('cameras_questionteaser_item_active');
	      },
	      function () {
	        $(this).removeClass('cameras_questionteaser_item_active');
	     }
	    );
	});
}





/* ---- START TMCC Tracking ---- */
function tm_tracker() {
	var pageTitle = document.title;
	var pageUrl = document.URL;

	var page="http"+(document.URL.indexOf('https:')==0?'s':'')+'://s3.trafficmaxx.de/thx.php?sid='+tm_sid+"\x26java=y";
	var tm_ref = escape(parent==self?document.referrer:top.document.referrer);
	tm_ref = (typeof(top.document)=="object")?top.document.referrer:tm_ref;
	var tm_lang = navigator.userLanguage?navigator.userLanguage:navigator.language;

	if (typeof(tm_pageCategory)=="undefined") tm_pageCategory = "";
	if (typeof(tm_conversionName)=="undefined") tm_conversionName = "";

	tm="\x26swidth="+swidth;
	tm+="\x26sheight="+sheight;
	tm+="\x26scolor="+scolor;
	tm+="\x26la="+escape(tm_lang.toLowerCase());
	tm+="\x26pageTitle="+escape(pageTitle);
	tm+="\x26pageUrl="+escape(pageUrl.toLowerCase());
	tm+="\x26pageCategory="+escape(tm_pageCategory);
	tm+="\x26ref="+escape(tm_ref.toLowerCase());
	tm+="\x26conversionName="+escape(tm_conversionName);
	pq = new Image();
	pq.src = page+tm;
}

var swidth="na";
var sheight="na";
var scolor="na";
var swidth=screen.width;
var sheight=screen.height;
var scolor=navigator.appName!='Netscape'? screen.colorDepth : screen.pixelDepth;

var tm_sid = "cdf4edef5ae91aa6409b88704d4b2c45";
var tm_pageCategory = "0";
var tm_conversionName = "0";
//tm_tracker();
/* ---- STOP TMCC Tracking ---- */