$(document).ready(function(){
	var sitehome = 'http://www.meagleymachinery.com';
	
	$('.icon-display li:nth-child(5n)').css('margin-right','0');
	$('.video-icons li:last').css('margin-right','0');
	$('.content').find('p:last').css('margin-bottom','0');
	$('.content').append('<img src="images/content-barbtm.png" alt="" />');
	
	function popup(url){
		params = 'width'+screen.width;
		params += ', height='+screen.height;
		params += ', top=0, left=0';
		params += ', fullscreen=yes';
		params += ', menubar=1, toolbar=1, location=1, resizable=1, scrollbars=1';
		
		newwin=window.open(url, 'windowname', params);
		if (window.focus) {newwin.focus()}
		return false;
	}
	
	$('a.nw').click(function(){
		var original_href = $(this).attr('href');
		var winref = popup(sitehome+'/iframe?u='+original_href,'Meagley_Machinery');
		return false;
	});
	$('a.nw-noframe').click(function(){
		var original_href = $(this).attr('href');
		var winref = popup(original_href,'Meagley_Machinery');
		return false;
	});
	$('a.homelink').click(function(){
		parent.opener.location.href = sitehome;
		parent.self.close();
		return false;
	});
	$('a.requestlink').click(function(){
		parent.opener.location.href = sitehome + '/request-info';
		parent.self.close();
		return false;
	});
	$('a.cw').click(function(){
		parent.self.close();
		return false;
	});
	
	if(navigator.userAgent.match(/iPad/i) != null){
		$('.icon-container').jSlideTouch({
			direction:'H'
		});
	} else {
		$('.icon-container').anythingSlider({
			buildArrows: true,
			buildNavigation: false,
			autoPlay: false,
			startStopped: false
		});
	}
	$('.nyroModal').nyroModal({
		showCloseButton: true,
		closeOnClick: true,
		callbacks: {
			beforeShowCont: function(nm){
				window.location.hash = '#';
			}
		},
		sizes: {
			initH: 'auto',
			h: 'auto',
			minH: 'auto'
		}
	});
});

function writeurl(){
	alert('it worked!');
}
