
/* IFixPNG Call */
$(document).ready(function(){ 
		pngFixAll();
		//alert($("html").attr("clientHeight"));
});

function pngFixAll() {
	 	$('img[@src$=.png],li, input, div, form, input[@src$=.png],select, a').ifixpng();
	};
function pngFixSpecific(conteiner) {
		$(conteiner+' img, '+conteiner+' a, '+conteiner+' div, '+conteiner+' li').ifixpng();
	};


/**  Gallery Center  
$(document).ready(function(){ 
		var pageHeight = $('html').attr('clientHeight');
		if (pageHeight >= 664) {
			paddingBlocks = (pageHeight - 664)/2;
			$('.col_2').css('padding-top',(22+paddingBlocks)+'px')
			var naviHeight = $('.ulMain').attr('offsetHeight');
			var marginNavi = ((pageHeight-naviHeight-72)/2)-20;
			$('.ulMain').css('margin-top',marginNavi+'px')
		}
		
});
**/


/*  GaleriePreview  */
$(document).ready(function(){
	$('#Preview').jqGalView({
		title : "Image Galery",
		openTxt:'click to zoom &raquo; '
	});
	
});

function resetIMG(loadIMG) {
					var img_width = $(loadIMG).attr('width');
					var img_height = $(loadIMG).attr('height');
					if (img_height == 59){
						if (img_width > 79){
							var divisor2 = img_width/79;
							img_width = img_width/divisor2;
							img_height = img_height/divisor2;
						}
						else
							img_width = img_width;
							img_height = img_height
					
					}
					else {
						var divisor = img_height/59;
						img_width = img_width/divisor;
						img_height = img_height/divisor;
							if (img_width > 79){
								var divisor2 = img_width/79;
								img_width = img_width/divisor2;
								img_height = img_height/divisor2;
							}
							else
								img_width = img_width;
								img_height = img_height
							
					}
					$(loadIMG).css('width',img_width+'px');
					$(loadIMG).css('height',img_height+'px');
					$(loadIMG).css('margin-left',(94-img_width)/2+'px');
					$(loadIMG).css('margin-top',(71-img_height)/2+'px');

};

function resetButtons() {
		if (($.browser.msie) && ($.browser.version == 6.0)) {
			var buttonMargin = (282-$(".gvFooter .gvLinks").attr("clientWidth"))/4;
			$(".gvFooter .gvLinks").css("margin-left",buttonMargin);
		}
		else {
			var buttonMargin = (282-$(".gvFooter .gvLinks").attr("clientWidth"))/2;
			$(".gvFooter .gvLinks").css("margin-left",buttonMargin);
		}
	};
	
	
/**  Return Image to right Place  **/
function PageNum() {
	if ($('.gvImgContainer img').attr('class') != '') {
		var PageNum = ($('.gvImgContainer img').attr('class')-(($('.gvImgContainer img').attr('class'))%9))/9;
		//alert(PageNum);
		if ($('.gvImgContainer img').attr('class')%9 == 0) {
			PageNum = PageNum-1;
		}
		$('.gvHolder').css('margin-top',-213*PageNum+'px')
	}
};


	
/**  Image Big  **/
$(document).ready( function() {

	$('.linkZoom').click( function() {
		var bigImage = '.gvImgContainer img';
		var BigPrev = $(bigImage).attr("src");
		var widthImageB = $(bigImage).attr("width");
		var heightImageB = $(bigImage).attr("height");
		if (heightImageB == 425){
			if (widthImageB > 569){
				var divisor2 = widthImageB/569;
				widthImageB = widthImageB/divisor2;
				heightImageB = heightImageB/divisor2;
			}
			else
				widthImageB = widthImageB;
				heightImageB = heightImageB;
		
		}
		else {
			var divisor = heightImageB/425;
			widthImageB = widthImageB/divisor;
			heightImageB = heightImageB/divisor;
				if (widthImageB > 569){
					var divisor2 = widthImageB/569;
					widthImageB = widthImageB/divisor2;
					heightImageB = heightImageB/divisor2;
				}
				else
					widthImageB = widthImageB;
					heightImageB = heightImageB;
				
		}
		var marginLeftB = (629 - widthImageB)*.5;
		var marginTopB = (609 - heightImageB)*.5;
		$(bigImage).oneTime(10, function() {
			$('.ImageXL').fadeIn(900);
			$('.contentSmall').fadeOut(900);
			$('.contentBig').fadeOut(900);
			$('.breadcrump').fadeOut(900);
			$('.copyright').fadeOut(900);
			$('.ImageXL img.ImageBig').attr('src',BigPrev);
			$('.ImageXL img.ImageBig').css({
				width:widthImageB,
				height:heightImageB,
				marginLeft:marginLeftB,
				marginTop:marginTopB
			});
		});
			
	});
	
	$('.gvImgContainer img').click( function() {
		var bigImage = '.gvImgContainer img';
		var BigPrev = $(bigImage).attr("src");
		var widthImageB = $(bigImage).attr("width");
		var heightImageB = $(bigImage).attr("height");
		if (heightImageB == 425){
			if (widthImageB > 569){
				var divisor2 = widthImageB/569;
				widthImageB = widthImageB/divisor2;
				heightImageB = heightImageB/divisor2;
			}
			else
				widthImageB = widthImageB;
				heightImageB = heightImageB;
		
		}
		else {
			var divisor = heightImageB/425;
			widthImageB = widthImageB/divisor;
			heightImageB = heightImageB/divisor;
				if (widthImageB > 569){
					var divisor2 = widthImageB/569;
					widthImageB = widthImageB/divisor2;
					heightImageB = heightImageB/divisor2;
				}
				else
					widthImageB = widthImageB;
					heightImageB = heightImageB;
				
		}
		var marginLeftB = (629 - widthImageB)*.5;
		var marginTopB = (609 - heightImageB)*.5;
		$(bigImage).oneTime(10, function() {
			$('.ImageXL').fadeIn(900);
			$('.contentSmall').fadeOut(900);
			$('.contentBig').fadeOut(900);
			$('.breadcrump').fadeOut(900);
			$('.copyright').fadeOut(900);
			$('.ImageXL img.ImageBig').attr('src',BigPrev);
			$('.ImageXL img.ImageBig').css({
				width:widthImageB,
				height:heightImageB,
				marginLeft:marginLeftB,
				marginTop:marginTopB
			});
		});
			
	});
	
	$('.ImageXL img').click( function() {
			$('.ImageXL').fadeOut(900);
			$('.contentSmall').fadeIn(900);
			$('.contentBig').fadeIn(900);
			$('.breadcrump').fadeIn(900);
			$('.copyright').fadeIn(900);
	});

});
	

/*  BodyCorrection  */
function contentBigHeight() {
		var middleHeight = $(".contentBig .middle").attr("clientHeight")+"px";
		$(".contentBig .middle .created").css("height",middleHeight);
	};
	
	

/*  Gallery Information  

$(document).ready(function(){
		$(".gvImgContainer img").mouseover( function() {
													 	$(".containerIMG_Switcher").fadeOut(400);
													 	$(".containerInfo_Switcher").fadeIn(400);
													 });
		$(".gvImgContainer img").mouseout( function() {
													 	$(".containerIMG_Switcher").fadeIn(400);
													 	$(".containerInfo_Switcher").fadeOut(400);
													 });
});
*/


/*  Display Hidden  */
$(document).ready(function(){
		$(".info a").click( function() {
									 	$(this).css("display","none");
										$(".info .hidden").fadeIn(300);
										contentBigHeight();
									 }); 
});



/*  IMG Change  */

$(document).ready(function(){
		wContainerCar = parseInt($(".gvImgContainer").css("width"));
		hContainerCar = parseInt($(".gvImgContainer").css("height"));
		$(".gvImgContainer img").attr("height","200");
						   			   
		$('.gvHolder .gvItem').click(function(){
						ImageNr = $(this).attr("title");
						
						if (ImageNr == 0) {
							$('.rlLinks .lLinks').addClass("InAktive");
							};		
						if (ImageNr == elemento) {
							$('.rlLinks .rLinks').addClass("InAktive");
							};
		});
		
		$('.rlLinks .lLinks').click(function(){
						if (ImageNr != 0) {
							if (parseInt(ImageNr)-1 == 0) {
								$('.rlLinks .lLinks').addClass("InAktive");
								};
							var PrevImage = ".gvHolder #gvID"+(parseInt(ImageNr)-1)+" img";
							var Prev = $(PrevImage).attr("src");
							var widthImage = $(PrevImage).attr("width");
							var heightImage = $(PrevImage).attr("height");
										if (heightImage == 200){
											if (widthImage > 263){
												var divisor2 = widthImage/263;
												widthImage = widthImage/divisor2;
												heightImage = heightImage/divisor2;
											}
											else
												widthImage = widthImage;
												heightImage = heightImage
										
										}
										else {
											var divisor = heightImage/200;
											widthImage = widthImage/divisor;
											heightImage = heightImage/divisor;
												if (widthImage > 263){
													var divisor2 = widthImage/263;
													widthImage = widthImage/divisor2;
													heightImage = heightImage/divisor2;
												}
												else
													widthImage = widthImage;
													heightImage = heightImage
												
										}
							var marginLeft = (wContainerCar - widthImage)*.5;
							var marginTop = (hContainerCar - heightImage)*.5;
							$(".gvImgContainer img").fadeOut(100);
							$(".gvImgContainer img").attr("src",Prev);
							$(".gvImgContainer img").attr("width",widthImage);
							$(".gvImgContainer img").attr("height",heightImage);
							$(".gvImgContainer img").attr("style","margin: "+marginTop+"px 0px 0px "+marginLeft+"px");
							$(".gvImgContainer img").fadeIn(100);
							$(".gvImgContainer img").attr('class',parseInt(ImageNr));
							$(".description_gvID"+parseInt(ImageNr)).fadeOut(200);
							$(".description_gvID"+(parseInt(ImageNr)-1)).fadeIn(200);
							$(".header_gvID"+parseInt(ImageNr)).fadeOut(200);
							$(".header_gvID"+(parseInt(ImageNr)-1)).fadeIn(200);
							if (($('.rlLinks .rLinks').attr("class") == "rLinks InAktive") && (elemento>1)) {
								$('.rlLinks .rLinks').removeClass("InAktive");
								};
							ImageNr = parseInt(ImageNr)-1;
						}
		});
		
		$('.rlLinks .rLinks').click(function(){
						if (ImageNr != elemento) {
							if (parseInt(ImageNr)+1 == elemento) {
								$('.rlLinks .rLinks').addClass("InAktive");
								};
							var PrevImage = ".gvHolder #gvID"+(parseInt(ImageNr)+1)+" img";
							var Prev = $(PrevImage).attr("src");
							var widthImage = $(PrevImage).attr("width");
							var heightImage = $(PrevImage).attr("height");
										if (heightImage == 200){
											if (widthImage > 263){
												var divisor2 = widthImage/263;
												widthImage = widthImage/divisor2;
												heightImage = heightImage/divisor2;
											}
											else
												widthImage = widthImage;
												heightImage = heightImage
										
										}
										else {
											var divisor = heightImage/200;
											widthImage = widthImage/divisor;
											heightImage = heightImage/divisor;
												if (widthImage > 263){
													var divisor2 = widthImage/263;
													widthImage = widthImage/divisor2;
													heightImage = heightImage/divisor2;
												}
												else
													widthImage = widthImage;
													heightImage = heightImage
												
										}
							var marginLeft = (wContainerCar - widthImage)*.5;
							var marginTop = (hContainerCar - heightImage)*.5;
							$(".gvImgContainer img").fadeOut(100);
							$(".gvImgContainer img").attr("src",Prev);
							$(".gvImgContainer img").attr("width",widthImage);
							$(".gvImgContainer img").attr("height",heightImage);
							$(".gvImgContainer img").attr("style","margin: "+marginTop+"px 0px 0px "+marginLeft+"px");
							$(".gvImgContainer img").fadeIn(100);
							$(".gvImgContainer img").attr('class',parseInt(ImageNr)+2);
							$(".description_gvID"+parseInt(ImageNr)).fadeOut(200);
							$(".description_gvID"+(parseInt(ImageNr)+1)).fadeIn(200);
							$(".header_gvID"+parseInt(ImageNr)).fadeOut(200);
							$(".header_gvID"+(parseInt(ImageNr)+1)).fadeIn(200);
							if (($('.rlLinks .lLinks').attr("class") == "lLinks InAktive") && (elemento>1)) {
								$('.rlLinks .lLinks').removeClass("InAktive");
								};
							ImageNr = parseInt(ImageNr)+1;
						}
		});
		
});

/*  Take the Right Information  */
$(document).ready(function(){
		$('.gvItem').click( function() {
			var rightInfo = $(this).attr("id");
			$(".description_"+rightInfo).css("display","block");
			$(".titleMain").fadeOut(200);
			$(".header_"+rightInfo).fadeIn(200);
		});
});



/*  Navi Hover  */
$(document).ready(function(){
		$(".col_1 ul a.aMain").each( function() {
			$(this).mouseover( function() {
										$(this).animate({ 
											fontSize: "14px"
										  }, 200 );	
										$(this).css('font-weight','700');
										 }); 
			
			$(this).mouseout( function() {
										$(this).animate({ 
											fontSize: "12px"
										  }, 200 );			
										$(this).css('font-weight','400');							
										 });
			});
});



/*  Navi Main Click  */
$(document).ready(function(){
		$(".col_1 ul .aMain").each( function() {
			$(this).click( function() {
					var aID = $(this).attr("id");
					//alert(aID);
					if ($(".col_1 ul .Mainl"+aID).hasClass('active')) {
										$(".col_1 ul .Mainl"+aID).removeClass('active');
										$(".col_1 ul .Mainl"+aID).find("a.aMain").animate({ 
											fontSize: "14px"
										  }, 200 );
										$(".col_1 ul .Mainl"+aID).find(".ulSecond").animate({ 
											height: "0px"
										  }, 200 );
										$(".col_1 ul .Mainl"+aID).find(".ulSecond").oneTime(190, function() {
											$(this).css("position","absolute");
										});
										$(".col_1 ul .Mainl"+aID).find(".ulSecond li").animate({ 
											height: "0px"
										  }, 200 );
										$(".col_1 ul .Mainl"+aID).find(".ulSecond li .created").css("display","none");
										$(".col_1 ul .Mainl"+aID).find(".ulSecond a").css("display","none");
								}
					else {				
										$('.liMain').removeClass('active');
										$(".col_1 ul .Mainl"+aID).find("a.aMain").animate({ 
											fontSize: "14px"
										  }, 200 );	
										$('.liMain .ulSecond').animate({ 
											height: "0px"
										  }, 200 );
										$('.liMain .ulSecond').oneTime(190, function() {
											$(this).css("position","absolute");
										});
										$('.liMain .ulSecond li').animate({ 
											height: "0px"
										  }, 200 );
										$('.liMain .ulSecond li .created').css("display","none");
										$('.liMain .ulSecond a').css("display","none");
										
										$(".col_1 ul .Mainl"+aID).oneTime(201, function() {
											$(this).addClass('active');
										$(".col_1 ul .Mainl"+aID).find("a.aMain").animate({ 
											fontSize: "16px"
										  }, 200 );	
											$(".col_1 ul .Mainl"+aID).find(".ulSecond").animate({ 
												height: "25px"
											  }, 200 );
											$(".col_1 ul .Mainl"+aID).find("ul").css("position","static");
											$(".col_1 ul .Mainl"+aID).find(".ulSecond li").animate({ 
												height: "25px"
											  }, 200 );
											$(".col_1 ul .Mainl"+aID).find(".ulSecond li .created").css("display","block");
											$(".col_1 ul .Mainl"+aID).find(".ulSecond a").css("display","block");
										});
											
										 
								}
						}); 
								 
			});
});



/**  Navi Margin IEProblem  **/

$(document).ready(function(){
		if (($.browser.msie) && ($(".ulSecond li").length > 0)){
			$(".ulSecond li").each( function() {
				var value = $(this).attr("class");
				$('.ulMain .Main'+value).attr('style','margin-bottom:-1px;')
			});
			}
});


/**  Href Only if Level_1 doesn't have level_3 ***** Breadcrump too  **/

$(document).ready( function(){
		$(".ulSecond").each( function() {
			$(this).parent('.liMain').find("a.aMain").removeAttr("href");
		});
		
		if ($(".ulSecond li.active").length > 0){
				$('.ref_2').removeAttr("href");
				$('.ref_2').attr('style','text-decoration:none !important;');
			}
});

/**  Home Page Opacity  **/

$(document).ready( function() {
	$('.containerIMG_Opacity').each( function() { 
		$(this).find('img').mouseover( function() {
			$(this).animate({
				opacity: 1
			},300);
		}); 
		$(this).find('img').mouseout( function() {
			$(this).animate({
				opacity: 0.5
			},300);
		});
	});
});

/* blur Input e-mail*/

$(document).ready( function() {
	$(".inputEmail").focus(function () {
         $(this).attr('value','');
         //alert('si');
    });

});


/* hide nodescription*/
function HNDPrepare() {
	$('.containerInfo_Switcher .descriptionSmall').each( function() {
		var lengthP = $(this).find('p').html().length;
		if (lengthP < 42) {
			//alert($(this).attr('class')+','+lengthP);
			var elemClass = $(this).attr('class');
			$(this).attr('class','nodesc '+elemClass);
		}
	});
}
function hideNoDesc() {
	var varImage = $('.containerIMG_Switcher').html();
	$('.containerInfo_Switcher .descriptionSmall').each( function() {
		if ($(this).hasClass('nodesc')) {
			var ImageInd = $(this).attr('class').substring(40,45);
			$(this).replaceWith('<div class="NDImage description_gvID'+ImageInd+'">'+varImage+'</div>')
		}
	});
}


/* editTop Position*/
$(document).ready( function() {
	rePosition();
	$(window).resize( function() {
		rePosition();
	});
});

function rePosition() {
	var linkLeft = $('.contentRight').attr('offsetLeft')-340;
	$('.editTop').css('marginLeft',linkLeft+'px');
	//alert(linkLeft);
}
