	$(document).ready(function() {

		var userAgent = navigator.userAgent.toLowerCase();
		var seacrhstring = userAgent.search(/msie/i);
		if(seacrhstring>0) {
			browser	= 0;
		} else {
			browser	= 1;
		}
		
		if($(document).width() < 810) {
			$('#content').css({
				'left': 0,
				'margin-left': 0
			});	
		}
		
//		var doc_height	= $(document).height();
//		$('#content').height(doc_height);
		
		$('.bottom_corner').corner('bottom');
		$('.left_corner').corner('left');
		$('.right_corner').corner('right');
		$('.top_corner').corner('top');
		$('.corner').corner();
		
		if (typeof $('#packages_slide') == 'object' && $('#packages_slide').length != 0) {
//			$('#packages_slide').show();
//			$('#packages_slide').easyAccordion({ 
//				autoStart	: false,
//				slideNum	: false
//			});
//			$('#packages_slide .packages_content').show();
		}
		
		if (typeof $('.btn_quote') == 'object' && $('.btn_quote').length != 0) {
			$('.btn_quote').click(function() {
				//$('.btn_quote').each(function() {
					//alert($(this).parent('form').attr('action'));
					Shadowbox.open({
						content:    $(this).parent('form').attr('action'),
						player:     "iframe",
						title:      "Request Form",
						height:     400,
						width:      810
					});					
					return false;	
				//});
			});
		}
		
		if (typeof $('#best_porto') == 'object' && $('#best_porto').length != 0) {
			$("#best_porto").CloudCarousel({			
				xPos: 250,
				yPos: 25,
				reflHeight: 20,
				buttonLeft: $("#left_but"),
				buttonRight: $("#right_but"),
				titleBox: $("#title-text"),
				bringToFront: true,
				mouseWheel: true
			});
		}

		if (typeof $('.trigger') == 'object' && $('.trigger').length != 0) {
			$("h1.trigger").click(function(){
				$(".toggle_container").slideUp("normal");
				$(this).toggleClass("active").next().slideDown("normal");
				return false;
			}).eq(0).click();
		}
		
//		if (typeof $('.portofolio_wrapper') == 'object' && $('.portofolio_wrapper').length != 0) {
//			$('.portofolio_wrapper').each(function() {
//				var img_width	= 0;
//				if($(this).children('span').length != 0) {
//					var span_text	= $(this).children('span').text();
//					var split_span	= span_text.split('|');
//					var src	= split_span[0];
//					$(this).children('span').empty();
//					//$(this).children('img').hide();
//					
//					img = new Image();
//					$(img).load(function() {
//						//$(this).hide();
//						//$(this).fadeIn('normal');
//					})
//					.error(function() {
//						alert('error');	
//					})
//					.attr('src', src);
//					
////					if(src != '') {
////						img = new Image();
////						$(img).load(function() {
////							//$(this).hide();
////							
////							$(this).fadeIn('normal');
////						})
////						.error(function() {
////							alert('error');	
////						})
////						.attr('src', src);
//
//						//img_width	= $(img).width();
//						
//						//alert(img_width);
////					}
////					$(this).children('img').ready(function() {
////						img_width	= $(this).children('img').width();
////						
////						$(this).width(img_width);
////					});
//				}
//			});
//		}
		
//		$('#green_background').height($(document).height() - 204);
		
		if (typeof $('.form_details') == 'object' && $('.form_details').length != 0) {
			if (typeof $('.required') == 'object') {
				$('.required').each(function() {
					$(this).prev('label').append(' <span style="color:#FFB400;">*</span>');
				});
			}
			
			$('.form_details').validate({
				errorPlacement: function(error, element) {
					//error.prependTo( element.parent() );
				}
			});
		}

		$('#reload').click(function() {
			var url	= $(this).attr('href');
			
			$.ajax({
				type: "POST",
				url: url,
				cache: false,
				success: function(data){
					$('#reload').empty().html(data);
				}
			});
			
			return false;	
		});
		
//		$('#testimonial_button').click(function() {
//			if($('#testimonial_content').is(':visible')) {
//				$('#testimonial_content').slideUp('normal');
//			} else {
//				$('#testimonial_content').slideDown('normal');
//			}
//			
//			return false;
//		});
		
		$('#menu li').hoverIntent({
			over: function() {
				if(!$(this).children('a').hasClass('parent_active'))
					$(this).children('ul').slideDown('normal');
			},
			timeout: 300,
			out: function() {
				if(!$(this).children('a').hasClass('parent_active'))
					$(this).children('ul').slideUp('normal');
			}	
		});
		
		$('#menu li ul.sub_menu li a').each(function() {
			if($(this).hasClass('active')) {
				$(this).parent().parent('ul.sub_menu').show();
				$(this).parent().parent().parent().children('li a').addClass('parent_active');
			}
		});
		
//		$('#more_button').toggle(function(){
//				var viewport_height	= $(document).height();
//				//204
//				var slide_height	= viewport_height - 204;
//				//alert(slide_height);
//				$('#more_holder').css({'background': '#76AB01', 'border-top': '2px solid #FFB400'});
//				
//				$('#more').animate({height: slide_height}, 'normal', function() {
//					$('.more_parent_wrapper').slideDown('normal');
//				});
//				
//				$('#more_button').html('<span>close more information</span>');
//				
//				return false;
//		}, function() {
//				$('#more_holder').css({'background': '#f7f0e8', 'border': '0px'});
//				//$('#more_holder').css('background', '#f7f0e8');
//				
//				$('.more_parent_wrapper').slideUp('normal', function() {
//					$('#more').animate({height: 30}, 'normal');
//				});
//				
//				$('#more_button').html('more information');
//				
//				return false;
//		});
		
//		$('#logo').hoverIntent({
//			over:function() {
//				$(this).fadeTo('fast', 0.5);	
//			},
//			timeout: 300,
//			out: function() {
//				$(this).fadeTo('fast', 1);	
//			}
//		});
		
		$('ul#menu li a').hoverIntent({
			over:function() {
				if(!$(this).hasClass('parent_active') && !$(this).hasClass('active')) {
					$(this).css({
						'text-decoration': 'underline',
						'color': '#9FC22A'
					});
				}
//				$(this).fadeTo('fast', 0.6);	
			},
			timeout: 300,
			out: function() {
				if(!$(this).hasClass('parent_active') && !$(this).hasClass('active')) {
					$(this).css({
						'text-decoration': 'none'
					});
				}
//				$(this).fadeTo('fast', 1);	
			}
		});

	});
	
Shadowbox.init();

