﻿$(function(){
	var myMenu;
	$('a[rel=blank]').click(function(){ window.open(this.href); return false; });
	$('#master').pngFix({ domain: 'http://www.hidroser.com.tr/' });
	$('a[rel=lightbox]').fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'easingIn'		: 'easeOutBack',
		'easingOut'		: 'easeInBack'
	});
	
	$('a[rel=flash]').fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'none',
		'easingIn'		: 'easeOutBack',
		'easingOut'		: 'easeInBack',
		'width'			: '95%',
		'height'		: '90%',
		'type'			: 'iframe',
		'showNavArrows'	: false,
		'cyclic'		: false
	});
	
	$('#ebulten').fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'none',
		'easingIn'		: 'easeOutBack',
		'easingOut'		: 'easeInBack',
		'width'			: '100%',
		'height'		: '90%',
		'href'			: 'flash/e-bulten/e-bulten.html',
		'type'			: 'iframe'
	});
	
	$('#newsletter').fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'none',
		'easingIn'		: 'easeOutBack',
		'easingOut'		: 'easeInBack',
		'width'			: '100%',
		'height'		: '90%',
		'href'			: 'flash/newsletter/index.html',
		'type'			: 'iframe'
	});
	
	$('#referans').fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'none',
		'easingIn'		: 'easeOutBack',
		'easingOut'		: 'easeInBack',
		'width'			: '95%',
		'height'		: '90%',
		'href'			: 'flash/referans/referans.html',
		'type'			: 'iframe'
	});
	
	$('#kroki').fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'easingIn'		: 'easeOutBack',
		'easingOut'		: 'easeInBack',
		'width'			: '95%',
		'height'		: '90%',
		'href'			: 'http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;t=h&amp;msid=102691361429162312754.00049347230cd53a09221&amp;ll=41.046864,28.631616&amp;spn=0.015535,0.027466&amp;z=15&amp;output=embed',
		'type'			: 'iframe'
	});
	
	$('#spot div').jCarouselLite({
		auto	: false,
		speed	: 1000,
		scroll	: 1,
		visible	: 1,
		start	: 0,
		mouseWheel: true,
		btnGo	: ['.spotTexts:eq(0)', '.spotTexts:eq(1)', '.spotTexts:eq(2)']
	});
	
	sliderChange();
	$(window).bind('resize', function(){ sliderChange(); });
	
	$('#menu a').hover(function(){
		myMenu = $(this);
		
		if (document.getElementById('subMenu_' + myMenu.index()))
		{
			myMenu.addClass('active');
			$('#subMenu_' + myMenu.index()).css('display', 'block');
		}
	}, function(){
		if (document.getElementById('subMenu_' + $(this).index()))
		{
			myMenu.removeClass('active');
			$('#subMenu_' + $(this).index()).css('display', 'none');
			$('#subMenu_' + $(this).index()).hover(function(){
				myMenu.addClass('active');
				$(this).css('display', 'block');
			}, function(){
				myMenu.removeClass('active');
				Cufon.refresh();
				$(this).css('display', 'none');
			});
		}
	});
	
	$('#subMenu_2 a').click(function(){
		myMenu.removeClass('active');
		Cufon.refresh();
		$('#subMenu_2').css('display', 'none');
	});
	
	$('#homeBlock_3 a img').bind('mouseover', function(){
		var myImage	= $('#homeBlock_3 .image img');
		
		switch ($(this).attr('alt'))
		{
			case 'E-Bülten':
				myImage.attr('src', 'Resimler/wp28rlet.jpg');
				break;
			case 'E-Bulletin':
				myImage.attr('src', 'Resimler/wp28rlet.jpg');
				break;
			case 'Parker Store':
				myImage.attr('src', 'Resimler/wpb2ieso.jpg');
				break;
			case 'Duyurular':
				myImage.attr('src', 'Resimler/duyuru_alan_tr.jpg');
				break;
			case 'Announcements':
				myImage.attr('src', 'Resimler/duyuru_alan_eng.jpg');
				break;
		}
	});
	
	$('#fmContact').validate({
		rules: {
			isim	: { required: true },
			telefon	: { required: true },
			eposta	: { required: true, email: true },
			mesaj	: { required: true }
		},
		messages : {
			isim	: { required: '' },
			telefon	: { required: '' },
			eposta	: { required: '', email: '' },
			mesaj	: { required: '' }
		}
	});
	
	$('#fmHumanResources').validate({
		rules: {
			isim	: { required: true },
			soyisim	: { required: true },
			telefon	: { required: true },
			eposta	: { required: true, email: true },
			pozisyon: { required: true },
			mesaj	: { required: true }
		},
		messages : {
			isim	: { required: '' },
			soyisim	: { required: '' },
			telefon	: { required: '' },
			eposta	: { required: '', email: '' },
			pozisyon: { required: '' },
			mesaj	: { required: '' }
		}
	});
});

Cufon.replace('#menu a', { fontFamily: 'Myriad Pro', hover: true });
Cufon.replace('.spotTexts h2', { fontFamily: 'Myriad Condensed Web', textShadow: '0px 1px rgba(0, 0, 0, 0.3)' });
//Cufon.replace('.spotTexts span', { fontFamily: 'Myriad Pro' });
Cufon.replace('#homeBlock_1 h3', { fontFamily: 'Myriad Condensed Web' });
Cufon.replace('#subMenu h2', { fontFamily: 'Myriad Condensed Web', textShadow: '#FFFFFF 1px 1px' });
Cufon.replace('#content h3', { fontFamily: 'Myriad Condensed Web', textShadow: '#FFFFFF 1px 1px' });
Cufon.replace('#content h4', { fontFamily: 'Myriad Condensed Web' });
Cufon.replace('#content h5', { fontFamily: 'Myriad Condensed Web' });

function getHomeBanner(imageUrl)
{
	$('<div id="homeBanner"><img src="'+ imageUrl +'" /></div>')
		.appendTo('body')
		//.css('height', $('body').height());
	$('#homeBanner').bind('click', function(){ closeHomeBanner() })
	
	interval = setTimeout('closeHomeBanner()', 10000);
}

function closeHomeBanner()
{
	$("#homeBanner").fadeOut('slow');
	clearTimeout(interval);
}

function sliderChange()
{
	$('#slider').css('left', $('#master').offset().left + 'px');
}
