//IE png fix

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])


if ((version >= 5.5)  && (version < 7)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}



function laadt_scroll(){
	//Scrolbar
	$('#contentW').jScrollPane({
		
		
		scrollbarWidth: 40
		
		
	});
	
	
}

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "_blank")
     anchor.target = "_blank";
 }
}



	
$(document).ready(function(){
	
	externalLinks();
	
	$('#donatietracker').corner("5px");
	
//$.preloadImages(base_href+"i/contact_o.png", base_href+"i/gastenboek_o.png", base_href+"i/home_o.png", base_href+"i/pm_o.png", base_href+"i/winkel_o.png", base_href+"i/schrijfster_o.png");
    
  
     
    //menu mouseovers maken
    for (i = 1; i <= 6; i++) {
        if (ms != i) {
            $("#menu_" + i).mouseover(function(){
                $(this).attr("class", this.className.replace(/n/gi, 'o'));
            }).mouseout(function(){
                $(this).attr("class", this.className.replace(/o/gi, 'n'));
            });
			
        }
    }
    
	//Scrollbar
	laadt_scroll();
	
    //Tabjes maken als deze er zijn
    if (tabs > 0) {
        for (i = 1; i <= tabs; i++) {
        
            $("#tab_" + i).corner("top");
            
            
            
            $("#tab_" + i).click(function(){
                $('div.tabshow').each(function(){
                    $(this).attr("class", this.className.replace(/show/gi, 'hide'));
                });
                $(this).attr("class", this.className.replace(/hide/gi, 'show'));
                $('div.textshow').each(function(){
                    $(this).attr("class", this.className.replace(/show/gi, 'hide'));    
                });
                $("#text_" + this.id.replace(/tab_/gi, '')).attr("class", this.className.replace(/tabshow/gi, 'textshow'));
				laadt_scroll();
            });
            
        }
        
        //Geselecteerde tab pakken
        $('div.tabshow, div.tabhide').each(function(){
            if (this.id.replace(/tab_/gi, '') == tabsel) {
                $('div.tabshow').each(function(){
                    $(this).attr("class", this.className.replace(/show/gi, 'hide'));
                });
                $('div.textshow').each(function(){
                    $(this).attr("class", this.className.replace(/show/gi, 'hide'));
                });
                $(this).attr("class", this.className.replace(/hide/gi, 'show'));
                $("#text_" + this.id.replace(/tab_/gi, '')).attr("class", this.className.replace(/tabshow/gi, 'textshow'));
            }
            
        });
        
		 $('a.tablink').each(function(){
		 	
		 	$(this).click(  function(){ $("#t" + this.id).trigger("click"); return false;});	
		});
        
    }
	
	//if (!$.browser.msie){
		//Gastenboek corners maken
		$('div.gb_tit').each(function(){
			
			$(this).wrap('<div class="gb_wrap"></div>');
			$(this).corner("3px").parent().corner("round 5px");;
		});
		
	//}
    
    
});

var aantal_checks = 0;

function check_captcha(){
	
	
	aantal_checks ++;
	captcha = document.getElementById('captcha').value;
	
	if(aantal_checks > 4){ 

		$.get(base_href+'/inc/page/bestellen/xml/check_captcha.php',"captcha="+captcha,function(transport){
		      var response = transport;
			  if( response == "true"){
			  		document.getElementById('captcha_c').value = 'ok';
					document.getElementById('captcha').style.color = 'black';
					document.getElementById('captcha').style.background = '#A0FF9B url('+base_href+'/i/bestellen/captcha_ok.png)';
					return true;
				 }
			  else{ 
			 	document.getElementById('captcha_c').value = 'notok';
				document.getElementById('captcha').style.color = 'black';
				document.getElementById('captcha').style.background = '#FF9B9B url('+base_href+'/i/bestellen/captcha_notok.png)';
				return false;
				 }
			  
		    }
		    
		  );
	  }


}

function edit_g(i){
		
		$.get(base_href+'/inc/page/admin/edit_gastenboek.php',"id="+i,function(transport){ document.getElementById('bewerk'+i).innerHTML = transport; laadt_scroll(); return true; });
		
}
