$(document).ready(function(){
	jq_start()
});

function jq_start() {
//	alert('ready');
	$('#fisheye').Fisheye(
		{
		maxWidth: 140,
		items: 'a',
		itemsText: 'span',
		container: '.fisheyeContainter',
		itemWidth: 60,
		proximity: 90,
		halign : 'center'
		}
	)

	getdoc=getget('p')
	if (getdoc) {
//  	   alert(getdoc)
//	     fetchpage(getdoc,1)
    }		 
	else {
    //	$(".menuitem1").each(function() {showmenuitem(this)})
	//   fetchpage(1,1)
	}	
//    setClickable()
}


function setClickable() {
// alert($(obj).html())
	$(".mitem").removeClass('mitem')
	$(".menuitem1").add(".menuitem2").add(".menulink")
	.click(function(e){
	  e.preventDefault()
//	  alert('40 click')
          showmenuitem(this)
          return false
     })

}//end of function setClickable

function showmenuitem(obj) {
		var dfld=$(obj).attr('href');
		var tgt=$(obj).attr('tgt');
alert(dfld)
		$('#content2').html("")
		$('#content'+tgt).append('<img src="bigrotation2.gif">')
		fetchpage(dfld,tgt)
}

function fetchpage(page,tgt) {
$('#fb').html($('#fb').html()+' 56')
return
		$.ajax({
   			type: "GET",
   			url: page,
			dataType: "html",
   			success: function(resultaat){
     			$('#content'+tgt).html(resultaat)
				.find(".menuitem2").add('.menulink')
				.each(function() {
					setClickable(this);
$('#fb').html($('#fb').html()+' 65<br>')
alert('xx')
					})
     			$('.catitem').hover(function(){
     					var im=$(this).attr('rel')
     					if (im!=undefined) $('#contentrel').html('<img src="images/'+im+'">')},
     					function() {$('#contentrel').html('<img src="images/st.png">') }
     					)
$('#fb').html($('#fb').html()+' 72<br>')
/*				$('#fisheye').Fisheye(
					{
					maxWidth: 140,
					items: 'a',
					itemsText: 'span',
					container: '.fisheyeContainter',
					itemWidth: 60,
					proximity: 90,
					halign : 'center'
					}
				)
*/
/*				$.get("sf/token.php",function(txt){
					$(".secure").append('<input type="hidden" name="ts" value="'+txt+'" />');
				});
				$('.warning').remove();
*/

                $('.contentlink').each( function() {
				alert('90 '+$(this).attr('id'))
                    $(this).click(function() { 
					  fetchcontent($(this).attr('id')) 
					  })
                      .addClass('clickable')
                })
   			}
 		});
}//showmenuitem

function ajax_submitnote(formname) {
//	alert($("#"+formname).attr("action"))
		$.ajax({
   			type: "POST",
   			url: $("#"+formname).attr("action"),
			data:$("#"+formname).formSerialize(),
			dataType: "html",
   			success: function(resultaat){$('#content2').html(resultaat)
   			}
 		});

}

function getget(name) {
  var q = document.location.search;
  var i = q.indexOf(name + '=');

  if (i == -1) {
    return false;
  }

  var r = q.substr(i + name.length + 1, q.length - i - name.length - 1);

  i = r.indexOf('&');

  if (i != -1) {
    r = r.substr(0, i);
  }

  return r.replace(/\+/g, ' ');
}

function fetchcontent(srcid) {
//alert(dfld+"\n"+tgt)
   var page  = 'content/'+srcid+".php"
   $.ajax({
            type: "GET",
            url: page,
            dataType: "html",
            success: function(resultaat){
                $('#'+srcid).after(resultaat)
            }
    });
}//showmenuitem

