var isiPad = navigator.userAgent.match(/iPad/i) != null;
var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
var isiPod = navigator.userAgent.match(/iPod/i ) != null;


if(isiPhone || isiPod){
	window.scrollTo(0, 1);
}
	$(function(){
// png voor IE
		$('body').pngFix();
// warning if using IE6
	if (($.browser.msie) && ($.browser.version == "6.0")){
		$('#wrap').prepend('<div style="position:relative;left:0;top:0;height:54px;width:100%;display:block;background: pink ;font-weight:bold;border-bottom:5px solid red;"><p style="padding:10px;">U bekijkt deze site in Internet Explorer 6. Sommige functies werken niet met deze browser. Daarom adviseren wij u de browser te updaten.<br /><a href="http://www.mozilla-europe.org/nl/firefox/">"Firefox"</a>, <a href="http://www.apple.com/safari/">"Safari"</a>, <a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">"Internet Explorer"</a>, <a href="http://www.google.com/chrome">"Google Chrome"</a> en <a href="http://www.opera.com/">"Opera"</a> zijn allemaal uitstekende opties om uw verouderde en onveilige browser te vervangen.</p></div>');
	}
// enter does submit if IE
	if ($.browser.msie){
		$('input').keydown(function(e){
			if (e.keyCode == 13) {
				$(this).parents('form').submit();
				return false;
			}
		});
	}
// dotted linkline
		$('a').focus(function() {this.blur();});
		$('a img').hover(function(){
			$(this).stop().animate({'opacity':.7}, 100);
		}, function(){
			$(this).stop().animate({'opacity':1}, 400);
		})
// als links niet in markup mogen ivm worst-in-blik.
		$('a.verborgen').each(function(){
			var hiddenLink = $(this).text(),
				splitLink = hiddenLink.split('$'),
				emailLink = splitLink[0]+'@'+splitLink[1]+''+splitLink[2]+'.'+splitLink[3];
			$(this).attr('href', 'mailto:'+emailLink);
			$(this).text(emailLink);
			$(this).removeClass('verborgen');
		});
// form als t-shirt
		$('label.hidden').each(function(){
			var tekst = $(this).text();
			$(this).next('input').val(tekst);
			$(this).hide();
		});

// hide links		
		$('.mailArea').mailProtect({
   		 user: 'info',
    		domain: 'goliathsportswear.com?SUBJECT=Goliath Sportswear information&BODY=...',
   		 link: true
		});

// focus op input
		$('textarea, input[type="text"]').addClass("idleField");
		// textarea
		$('textarea').focus(function() {
			$(this).removeClass("idleField").addClass("focusField");
		});
		$('textarea').blur(function() {
			$(this).removeClass("focusField").addClass("idleField");
		});
		//input type=text
		$('input[type="text"], textarea').live('focus', function() {
			$(this).removeClass("idleField").addClass("focusField");
			var defVal = $(this).prev('label').text();
			if (this.value == this.defaultValue){ 
				this.value = '';
			}
			if(this.value != this.defaultValue){
				this.select();
			}
		});
		$('input[type="text"], textarea').live('blur', function() {
			$(this).removeClass("focusField").addClass("idleField");
			if ($.trim(this.value) == ''){
				this.value = (this.defaultValue ? this.defaultValue : '');
			}
		});
// printbutton
		$('#printwindow').click(function(){
			window.print();
			return false;
		});
// columnize		
		$('.tweekoloms').columnize({ columns: 2 });



// nav slide
		var subH = $('nav #submenu').outerHeight();
		$('nav #submenu').attr('rel',subH);
		
		$('#start nav ul#mainmenu').stop().animate({'height':120}, 600);
		
		$('body:not(#start) nav #mainmenu').live('mouseenter mouseleave', function(navlink){
			if ( navlink.type == "mouseenter" ) {
				$('nav ul#mainmenu').stop().animate({'height':120}, { "duration": 300, "easing": "easeOutExpo" });
				$('nav ul#submenu').css('overflow', 'hidden').stop().animate({'height':0, 'margin-top':120}, { "duration": 300, "easing": "easeOutExpo" });
			} else {
				$('nav ul#mainmenu').stop().animate({'height':70}, { "duration": 300, "easing": "easeOutExpo" });
				$('nav ul#submenu').css('overflow', 'visible').stop().animate({'height':subH, 'margin-top':70}, { "duration": 300, "easing": "easeOutExpo" });
			}
		});
		
// get in touch slide		
		$('#lipje').css('cursor', 'pointer');
		$('#lipje').live('click', function(){
			var intouchoffset = $('#intouchwrap').css('height');
			if(intouchoffset == '0px'){
				$('.ie7 #intouchwrap').css('visibility', 'visible');
				$('#intouchwrap').stop().animate({'height':356}, { "duration": 400, "easing": "easeOutExpo" });
				$('#wrapper').stop().animate({'margin-top':356}, { "duration": 400, "easing": "easeOutExpo" });
				$('.imgcontent').stop().animate({'top':636}, { "duration": 400, "easing": "easeOutExpo" });
				$('#lipje').css('background', '#FFF url(/images/intouch_down.png) no-repeat 62px 8px');
				$('#lipje p').css('color', '#8c8c8c');
			} else {
				$('.ie7 #intouchwrap').css('visibility', 'hidden');
				$('#intouchwrap').stop().animate({'height':0}, { "duration": 400, "easing": "easeOutExpo" });
				$('#wrapper').stop().animate({'margin-top':0}, { "duration": 400, "easing": "easeOutExpo" });
				$('.imgcontent').stop().animate({'top':280}, { "duration": 400, "easing": "easeOutExpo" });
				//$('#lipje').css('background', 'url(/images/intouch_up.png) no-repeat 62px 8px');
				$('#lipje').removeAttr('style');
				$('#lipje p').removeAttr('style');
				$('#lipje').css('cursor', 'pointer');
			}
		});
		
// share slide		
		$('.share a').css('cursor', 'pointer');
		$('.share a').live('click', function(){
			var sharedisplay = $(this).siblings('.sharewrap').css('height');
			if(sharedisplay == '0px'){
				$(this).siblings('.sharewrap').stop().animate({'height':24}, { "duration": 150, "easing": "easeOutExpo" });
				$(this).css('background', '#141E50');
			} else {
				$(this).siblings('.sharewrap').stop().animate({'height':0}, { "duration": 150, "easing": "easeOutExpo" });
				$(this).removeAttr('style');
			}
		});

$('.modal .close').live('click', function(){
		$(this).parent('.modal').css('display', 'none');
});

// homepage hover
		$('.startlink').live('mouseenter mouseleave', function(event){
			if (event.type == 'mouseenter'){
				$('#supersized .activeslide .slideoverlay').stop().animate({'opacity':0}, 200);
			} else {
				$('#supersized .activeslide .slideoverlay').stop().animate({'opacity':1}, 400).removeAttr('filter');
			}
		});
// homepage scroll
if($('#start').size() == 1){
$('#wrap').scroll(function(){
	var mainoffset = $('#start #main').offset();
	var mainoffsettop = mainoffset.top + 10;
	$('.imgcontent').css('top', mainoffsettop);
});
var windowH = parseInt($(window).height()),
	contentH = parseInt($('#content').height()),
	hiddenH = parseInt($('#wrapper').css('margin-top')),
	footerH = 70,
	totalH = contentH+hiddenH+footerH,
	marginT = windowH-totalH;
if (windowH > totalH){
	$('footer').css('margin-top', marginT);
}
}
$('#more').append('<div class="tobottom"><div id="styleswitch"><p><span class="daywrap"><img src="/images/daytime.png" alt="" width="15" height="15" /><span class="day">daytime</span></span><span class="nightwrap"><img src="/images/nighttime.png" alt="" width="15" height="15" /><span class="night">nighttime</span></span></p></div></div>');
$('span.nightwrap').live('click', function(){
	$('#stylesheet').attr('href', '/css/style_n.css?v=2');
	$('span.night').addClass('active');
	$('span.day').removeClass('active');
	var daynight = 'night';
	$.post("/switcher.php", {"style": daynight});
});
$('span.daywrap').live('click', function(){
	$('#stylesheet').attr('href', '/css/style.css?v=2');
	$('span.day').addClass('active');
	$('span.night').removeClass('active');
	var daynight = 'day';
	$.post("/switcher.php", {"style": daynight});
});
// collection slide	
		$('.collection .arrow').live('click', function(){
			var inarticleoffset = $(this).parent('section').find('.article').css('height');
			if(inarticleoffset == '250px'){
				$(this).parent('section').find('.article').css('overflow', 'hidden').stop().animate({'height':0, 'padding-top':0, 'padding-bottom':0}, { "duration": 300, "easing": "jswing" });
				$(this).parent('section').find('.number').animate({'right':65, 'top':30}, { "duration": 300, "easing": "jswing" });
				$(this).css('background', '#FFF url(/images/intouch_down.png) no-repeat center center');
				$(this).die("click");
			} else {
				$(this).parent('section').find('.article').css('overflow', 'visible').stop().animate({'height':250, 'padding-top':20, 'padding-bottom':20}, { "duration": 300, "easing": "jswing" });
				$(this).parent('section').find('.number').stop().animate({'right':170, 'top':14}, { "duration": 300, "easing": "jswing" });
				//$(this).css('background', '#FFF url(/images/intouch_up.png) no-repeat center center');
				$('this').removeAttr('style');
				$(this).die("click");
			}
		});
		
// campaign slide	
		$('.campaign .arrow').live('click', function(){
			var inarticleoffset = $(this).parent('section').find('.article').css('height');
			if(inarticleoffset == '250px'){
				$(this).parent('section').find('.article').css('overflow', 'hidden').stop().animate({'height':0, 'padding-top':0, 'padding-bottom':0}, { "duration": 200, "easing": "jswing" });
				//$(this).parent('section').find('.article h2').addClass("small").appendTo($(this)).stop();
				$(this).parent('section').find('.number').animate({'opacity':0}, 400);
				$(this).css('background', '#FFF url(/images/intouch_down.png) no-repeat center center');
				$(this).die("click");
			} else {
				$(this).parent('section').find('.article').css('overflow', 'visible').stop().animate({'height':250, 'padding-top':20, 'padding-bottom':20}, { "duration": 200, "easing": "jswing" });
				$(this).parent('section').find('.number').animate({'opacity':1}, 400);
				//$(this).css('background', '#FFF url(/images/intouch_up.png) no-repeat center center');
				$('this').removeAttr('style');				
				$(this).die("click");
			}
		});

// lazy		
//	$(".forimg img").lazyload({
//	 placeholder : "images/grey.gif",    
// effect      : "fadeIn"
//	});
 	
	
// fancybox	
 $("a.fancybox").fancybox({
        'titleShow'     : false,
        'transitionIn'  : 'fade',
        'transitionOut' : 'fade',
        'easingIn'      : 'easeOutBack',
        'easingOut'     : 'easeInBack',
        'padding'			: '0',
        'margin'			: '40',
        'autoscale'		: true,
        'overlayColor'	: '#141E50',
        'overlayOpacity': '0.9',
        'opacity'			: true,
        'centerOnScroll': true
        
    });
		
	$('.styledselect').styledSelect();
	$('.tags').each(function(){
		$(this).children('.tag').slice(1).prepend('<span class="sep">|</span>');
	});
	$('.tags span.tag').live('click', function(){
		var value = $(this).attr('rel');
		$('.tagselect').val(value);
		$('.tagselect').change();
	});
});
// na browser resize, afbeelding ook resizen
$(window).bind("resize", function(){
	var windowH = parseInt($(window).height()),
		contentH = parseInt($('#content').height()),
		hiddenH = parseInt($('#wrapper').css('margin-top')),
		footerH = 70,
		totalH = contentH+hiddenH+footerH,
		marginT = windowH-totalH;
	if (windowH > totalH){
		$('footer').css('margin-top', marginT);
	}
});

