var main = {
	siteURL: 'http://localhost/Works/Arneses/www',
	init: function(){
		$(".loading").css({"text-align":"center"}).hide();
		$(".message").hide();
		$(".loading_2").css({"text-align":"center", 'padding-top':'7px'}).hide();
		$(".message_2").hide();
		
		$(".videolink").colorbox({width:"900px", height:"90%", iframe:true});
		$(".webcamlink").colorbox({width:"90%", height:"90%", iframe:true});
		//$(".mapslink").colorbox({width:"210px", height:"240px", iframe:true});
		$(".mapslink").colorbox({width:"210px", inline:true, href:"#inline_maps"});
		
		$(".mapsintern1").colorbox({width:"900px", height:"910px", iframe:true});
		$(".mapsintern2").colorbox({width:"850px", height:"650px", iframe:true});
		
		$(".theicon").mouseover(function(){
			if ( $(this).attr('class') == "theicon one" ) {
				$(this).attr({'src':main.siteURL+"/front/images/body/nav-icon4-on.png"});
				return;
			}
			if ( $(this).attr('class') == "theicon two" ) {
				$(this).attr({'src':main.siteURL+"/front/images/body/nav-icon3-on.png"});
				return;
			}
			if ( $(this).attr('class') == "theicon three" ) {
				$(this).attr({'src':main.siteURL+"/front/images/body/nav-icon2-on.png"});
				return;
			}
			if ( $(this).attr('class') == "theicon four" ) {
				$(this).attr({'src':main.siteURL+"/front/images/body/nav-icon1-on.png"});
				return;
			}
			if ( $(this).attr('class') == "theicon five" ) {
				$(this).attr({'src':main.siteURL+"/front/images/body/nav-icon5-on.png"});
				return;
			}
		}).mouseout(function(){
			if ( $(this).attr('class') == "theicon one" ) {
				$(this).attr({'src':main.siteURL+"/front/images/body/nav-icon4.png"});
				return;
			}
			if ( $(this).attr('class') == "theicon two" ) {
				$(this).attr({'src':main.siteURL+"/front/images/body/nav-icon3.png"});
				return;
			}
			if ( $(this).attr('class') == "theicon three" ) {
				$(this).attr({'src':main.siteURL+"/front/images/body/nav-icon2.png"});
				return;
			}
			if ( $(this).attr('class') == "theicon four" ) {
				$(this).attr({'src':main.siteURL+"/front/images/body/nav-icon1.png"});
				return;
			}	
			if ( $(this).attr('class') == "theicon five" ) {
				$(this).attr({'src':main.siteURL+"/front/images/body/nav-icon5.png"});
				return;
			}	
		})
		
		
	},
	openGallery: function(id){
		$('.first_'+id).click();	
	},
	contact: function(){
		$(".message").hide();
		$(".form").fadeOut(500, function(){
			$(".loading").show();								 
		});
		params = "name="+$('input[name="name"]').val()+"&email="+$('input[name="email"]').val()+"&message="+$('textarea[name="message"]').val();
		params += "&action=contact";
		file = main.siteURL + "/front/ajax/post.php";
		$.ajax({
			type: 'POST',
			url: file,
			dataType: 'script',
			data: params,
			success: function(r){
				var hide = function(){
					$(".loading").hide();
					if ( r == "ok" ) {
						$(".message").html("Thank you for contacting us, we will be contacting your shortly.").show();
					} else {
						$(".message").html(r).show();
						$(".form").fadeIn(500);
					}
					
				}
				setTimeout(hide, 3000);
			}
		})
	},
	newsletter: function(){
		$(".message_2").hide();
		$(".form_2").fadeOut(500, function(){
			$(".loading_2").show();								 
		});
		params = "email="+$('input[name="newslettertxt"]').val();
		params += "&action=newsletter";
		file = main.siteURL + "/front/ajax/post.php";
		$.ajax({
			type: 'POST',
			url: file,
			dataType: 'script',
			data: params,
			success: function(r){
				var hide = function(){
					$(".loading_2").hide();
					if ( r == "ok" ) {
						$(".message_2").html("Thanks your email has been saved!").show();
					} else {
						alert(r);
						$(".form_2").fadeIn(500);
					}
				}
				setTimeout(hide, 3000);
			}
		})
	},
	fishing: function(i){
		for ( init = 1; init <= 3;	init++) {
			if ( init != i ) {
				$("#fishing-0"+init).fadeOut(1000);
			}	
		}
		var complete = function(){
			$("#fishing-0"+i).fadeIn(500);		
		}
		setTimeout(complete, 1000);
	}
};
