// JavaScript Document
//http://bassistance.de/jquery-plugins/jquery-plugin-validation/
// http://flowplayer.org/tools/demos/overlay/external.html
//$(window).load(function () {




$(document).ready(function(){
					
			Cufon.replace('#typo_link a');	
					
					
					
			var	klenod_object = $("input#klenod_object").val(); 	
					
			if(klenod_object != ""){
						  
					 var wrap = $("#testwappo"); 	
					 var hrefAtttribute = "klenodobjekt1.php?id="+klenod_object;
																			 
					wrap.load(hrefAtttribute,{id:123}, function(data){ 					

								$(".thumbs").bind('click', function(event){											
										var newsrc = 'klenoder/images/' + this.alt;
										$("#mainImage").fadeOut().attr("src",newsrc).fadeIn();										
								});
								
								showOverlay();
														 
					 });
					
					
												
						
					//alert("hejson");
					 
				
			}
						   
	
	function showOverlay(){
					
				$(".overlay").overlay({ 					 
				//		// custom top position 
//						top: 272, 
//						expose: {  
//						// you might also consider a "transparent" color for the mask 
//						color: '#fff', 							 
//						// load mask a little faster 
//						loadSpeed: 200, 							 
//						// highly transparent 
//						opacity: 0.5 
//					}, 
//						// disable this for modal dialog-type of overlays 
//						closeOnClick: false, 					 
//						// we want to use the programming API 
//						api: true 					 
//					// load it immediately after the construction 
					});
					
					
					$(".overlay").overlay().load();	
	}
									




   
	$("a[rel]").overlay(function() { 
       
        // grab wrapper element inside content 
        var wrap = this.getContent().find("div.wrap"); 
		//get the id of the database record!!!!!
		
		//var linkButton = this.getContent().find("a[rel]"); 
		
		//var atttribute = this.attr('id');
		//alert("from overlay: " + $("a[rel]").attr('href') );
		
		//alert(this.getTrigger().attr('href') );
		var hrefAtttribute = this.getTrigger().attr('href');
		
          wrap.load(hrefAtttribute,{id:123}, 
				function(data){ 
						//$("#mainImage").replaceWith("eres loco!");	
						//$("#mainImage").attr("alt","DETTA ÄR MAIN IMGAGEE!");
						//$("#mainImage").attr("src","klenoder/thumbs/klenod1.jpg");
						
						//alert("main");
						
						//Laddat in nya objekten
						//lägg till click funktion som byter ut huvudbilden
						/*$(".thumbs").each(
							
							function(n){
								alert(this.alt);
								//	this.bind('click', function(event){	alert('in thumbs function');});
								
							}
							
						);*/
						
							Cufon.replace('h4');
						
						$(".thumbs").bind('click', function(event){	
								//alert('in thumbs function ' + this.alt);
								//alert(this.alt);
								var newsrc = 'klenoder/images/' + this.alt;
								//$("#mainImage").fadeOut().hide().attr("src",newsrc).fadeIn();
								$("#mainImage").fadeOut().attr("src",newsrc).fadeIn();
								
								//$("#mainImage").fadeIn();
						});
						
				} ); 
     
		
    });    
	
	
	
	 
	

	
	
}); 
                 

	
