function jsScroller (o, w, h) {
	var self = this;
	var list = o.getElementsByTagName("div");
	for (var i = 0; i < list.length; i++) {
		if (list[i].className.indexOf("Scroller-Container") > -1) {
			o = list[i];
		}
	}

	//Private methods
	this._setPos = function (x, y) {
		if (x < this.viewableWidth - this.totalWidth)
			x = this.viewableWidth - this.totalWidth;
		if (x > 0) x = 0;
		if (y < this.viewableHeight - this.totalHeight)
			y = this.viewableHeight - this.totalHeight;
		if (y > 0) y = 0;
		this._x = x;
		this._y = y;
		with (o.style) {
			left = this._x +"px";
			top  = this._y +"px";
		}
	};

	//Public Methods
	this.reset = function () {
		this.content = o;
		this.totalHeight = o.offsetHeight;
		this.totalWidth	 = o.offsetWidth;
		this._x = 0;
		this._y = 0;
		with (o.style) {
			left = "0px";
			top  = "0px";
		}
	};
	this.scrollBy = function (x, y) {
		this._setPos(this._x + x, this._y + y);
	};
	this.scrollTo = function (x, y) {
		this._setPos(-x, -y);
	};
	this.stopScroll = function () {
		if (this.scrollTimer) window.clearInterval(this.scrollTimer);
	};
	this.startScroll = function (x, y) {
		this.stopScroll();
		this.scrollTimer = window.setInterval(
			function(){ self.scrollBy(x, y); }, 40
		);
	};
	this.swapContent = function (c, w, h) {
		o = c;
		var list = o.getElementsByTagName("div");
		for (var i = 0; i < list.length; i++) {
			if (list[i].className.indexOf("Scroller-Container") > -1) {
				o = list[i];
			}
		}
		if (w) this.viewableWidth  = w;
		if (h) this.viewableHeight = h;
		this.reset();
	};

	//variables
	this.content = o;
	this.viewableWidth  = w;
	this.viewableHeight = h;
	this.totalWidth	 = o.offsetWidth;
	this.totalHeight = o.offsetHeight;
	this.scrollTimer = null;
	this.reset();
};
// JavaScript Document

function highlight(name) {
	var list = new Array();
	list = name.split(',');
	for (var i=0;i<list.length;i++) {
		$('a[data-name="'+list[i]+'"]').addClass('highlight');
	}
}

function unhighlight() {
	$('.highlight').removeClass('highlight');
}

function listhighlight(name) {
	unhighlight();
	switch (name) {
		case 'Alexandrite':
			highlight('Brazil');highlight('India');highlight('Mozambique');highlight('Myanmar');highlight('Russia');highlight('Sri Lanka');highlight('Tanzania');
		break;
		case 'Aquamarine':
			highlight('Australia');highlight('Brazil');highlight('China');highlight('India');highlight('Kenya');highlight('Madagascar');highlight('Mozambique');highlight('Myanmar');highlight('Namibia');highlight('Nigeria');highlight('USA');highlight('Zimbabwe');
		break;
		case 'Beryl':

		break;
		case 'Chrysoberyl':
			highlight('Brazil');highlight('India');highlight('Madagascar');highlight('Myanmar');highlight('Russia');highlight('Sri Lanka');highlight('Zimbabwe');
		break;
		case 'Citrine':
			highlight('Brazil,Madagascar,Russia,Sri Lanka,Spain');
		break;
		case 'Coral':
			highlight('Mediterranean Sea,Red Sea,Sea of Japan,South Pacific');
		break;
		case 'Diamond':
			highlight('Angola,Australia,Brazil,Canada,Ghana,India,Russia,Sierra Leone,South Africa');
		break;
		case 'Emerald':
			highlight('Australia,Brazil,Colombia,India,Pakistan,Russia,South Africa,Tanzania,Zambia,Zimbabwe');
		break;
		case 'Garnet':
			highlight('Australia,Brazil,India,Kenya,Myanmar,Namibia,Nigeria,South Africa,Sri Lanka,Tanzania,USA');
		break;
		case 'Kunzite':
			highlight('Afghanistan,Brazil,Madagascar,USA');
		break;
		case 'Kyanite':
			highlight('Brazil,China,India,Kenya,Mozambique,Nepal,Russia,Serbia,USA');
		break;
		case 'Pearls':
			highlight('East Africa,Mediterranean Sea,Red Sea');
		break;
		case 'Peridot':
			highlight('Australia,Brazil,China,Egypt,Myanmar,Pakistan,South Africa,USA');
		break;
		case 'Rubellite':
			highlight('Afghanistan,Brazil,East Africa,Kunar,Madagascar,Myanmar,Russia,USA');
		break;
		case 'Ruby':
			highlight('Cambodia,Kenya,Madagascar,Myanmar,Pakistan,Sri Lanka,Tanzania,Thailand,Vietnam');
		break;
		case 'Sapphire':
			highlight('Australia,Brazil,China,India,Kenya,Madagascar,Myanmar,Nigeria,Pakistan,Sri Lanka,Tanzania,Thailand,USA,Vietnam,Zimbabwe');
		break;
		case 'Spinel':
			highlight('Afghanistan,Australia,Kenya,Madagascar,Myanmar,Pakistan,Russia,South Africa,Sri Lanka,Tajikistan,USA');
		break;
		case 'Topaz':
			highlight('Australia,Brazil,Nigeria,Pakistan,Russia,Sri Lanka,USA');
		break;
		case 'Tourmaline':
			highlight('Brazil,Kenya,Madagascar,Mozambique,Myanmar,Namibia,Nigeria,Pakistan,Russia,South Africa,Sri Lanka,USA');
		break;
		case 'Zircon':
			highlight('Australia,Brazil,Cambodia,Canada,Madagascar,Myanmar,Nigeria,Russia,South Africa,Sri Lanka,Tanzania,Thailand,USA,Vietnam');
		break;
	/* Country */
		case 'Afghanistan':
			highlight('Kunzite,Rubellite,Spinel');
		break;
		case 'Angola':
			highlight('Diamond');
		break;
		case 'Australia':
			highlight('Aquamarine,Diamond,Emerald,Garnet,Pearls,Sapphire,Spinel,Topaz,Zircon');
		break;
		case 'Brazil':
			highlight('Alexandrite,Aquamarine,Chrysoberyl,Citrine,Diamond,Emerald,Garnet,Kunzite,Kyanite,Peridot,Rubellite,Sapphire,Topaz,Tourmaline,Zircon');
		break;
		case 'Cambodia':
			highlight('Ruby,Zircon');
		break;
		case 'Canada':
			highlight('Diamond,Zircon');
		break;
		case 'China':
			highlight('Aquamarine,Kyanite,Peridot,Sapphire');
		break;
		case 'Colombia':
			highlight('Emerald');
		break;
		case 'East Africa':
			highlight('Pearls,Rubellite');
		break;
		case 'Egypt':
			highlight('Peridot');
		break;
		case 'Ghana':
			highlight('Diamond');
		break;
		case 'India':
			highlight('Alexandrite,Aquamarine,Chrysoberyl,Diamond,Emerald,Garnet,Kunzite,Sapphire');
		break;
		case 'Kenya':
			highlight('Aquamarine,Garnet,Kyanite,Ruby,Sapphire,Spinel,Tourmaline');
		break;
		case 'Kunar':
			highlight('Rubellite');
		break;
		case 'Madagascar':
			highlight('Aquamarine,Chrysoberyl,Citrine,Kunzite,Rubellite ,Ruby,Sapphire,Spinel,Tourmaline,Zircon');
		break;
		case 'Mediterranean Sea':
			highlight('Coral,Pearls');
		break;
		case 'Mozambique':
			highlight('Alexandrite,Aquamarine,Kyanite,Tourmaline');
		break;
		case 'Myanmar':
			highlight('Alexandrite,Aquamarine,Chrysoberyl,Garnet,Peridot,Rubellite,Ruby,Sapphire,Spinel,Tourmaline,Zircon');
		break;
		case 'Nepal':
			highlight('Kyanite');
		break;
		case 'Nigeria':
			highlight('Aquamarine,Garnet,Sapphire,Topaz,Tourmaline,Zircon');
		break;
		case 'Pakistan':
			highlight('Emerald,Peridot,Ruby,Sapphire,Spinel,Topaz,Tourmaline');
		break;
		case 'Red Sea':
			highlight('Coral,Pearls');
		break;
		case 'Russia':
			highlight('Alexandrite,Chrysoberyl,Citrine,Diamond,Emerald,Kyanite,Rubellite,Spinel,Topaz,Tourmaline,Zircon');
		break;
		case 'Serbia':
			highlight('Kyanite');
		break;
		case 'Sierra Leone':
			highlight('Diamond');
		break;
		case 'Sea of Japan':
			highlight('Coral');
		break;
		case 'South Africa':
			highlight('Diamond,Emerald,Garnet,Peridot,Spinel,Tourmaline,Zircon');
		break;
		case 'South Pacific':
			highlight('Coral');
		break;
		case 'Sri Lanka':
			highlight('Alexandrite,Chrysoberyl,Citrine,Garnet,Ruby,Sapphire,Spinel,Topaz,Tourmaline,Zircon');
		break;
		case 'Spain':
			highlight('Citrine');
		break;
		case 'Tajikistan':
			highlight('Spinel');
		break;
		case 'Tanzania':
			highlight('Alexandrite,Emerald,Garnet,Ruby,Sapphire,Zircon');
		break;
		case 'Thailand':
			highlight('Ruby,Sapphire,Zircon');
		break;
		case 'USA':
			highlight('Aquamarine,Garnet,Kunzite,Kyanite,Peridot,Rubellite,Sapphire,Spinel,Topaz,Tourmaline,Zircon');
		break;
		case 'Vietnam':
			highlight('Ruby,Sapphire,Zircon');
		break;
		case 'Zambia':
			highlight('Emerald');
		break;
		case 'Zimbabwe':
			highlight('Aquamarine,Chrysoberyl,Emerald,Sapphire');
		break;
		case 'Namibia':
			highlight('Aquamarine,Garnet,Tourmaline');
		break;

	}
}
$(document).ready(function(){
	//replace_font();
	/*
	$("a.has_sub").click(function(){
		if (!$(this).next('.sub_menu').is(':visible')) {
			$('.selected').removeClass('selected');
			$('.sub_menu').slideUp();
			$(this).next('.sub_menu').slideDown();
			$(this).addClass('selected');
		}
		else {
			$(this).next('.sub_menu').slideUp();
			$(this).removeClass('selected');
		}
		//return false;
	});
	*/
	/*
	if ($('#minimap').is('a')) {
		$('#footer').css('margin-top','100px');
	}
	*/
	if ($('#feature_list').is('div')) {
		$('#carousel_ul li:first').before($('#carousel_ul li:last'));
		$('#next_y').mouseover(function(){
			timer = setInterval('slide("right")', 10);
		}).mouseout(function(){
			clearTimeout(timer);
		});

		$('#prev_y').mouseover(function(){
			timer = setInterval('slide("left")', 10);
		}).mouseout(function(){
			clearTimeout(timer);
		});
		/*$('#feature_list ul:first').show();
		$('#next_y').click(function(){
			var current = $('#feature_list ul:visible');

			if (!$(current).next('ul').is('ul')) {
				$(current).hide();
				$('#feature_list ul:first').fadeIn(500);
			}
			else {
				$(current).hide();
				$(current).next('ul').fadeIn(500);
			}
			return false;
		});

		$('#prev_y').click(function(){
			var current = $('#feature_list ul:visible');

			if (!$(current).prev('ul').is('ul')) {
				$(current).hide();
				$('#feature_list ul:last').fadeIn(500);
			}
			else {
				$(current).hide();
				$(current).prev('ul').fadeIn(500);
			}

			return false;
		});*/



	}


	if ($('#h_wrapper').is('div')) {
		flashembed('background', {src: 'vid.swf', wmode: 'transparent'}, {
			movieUrl: 'home.flv', // url to movie
			movieWidth: '768',
			movieHeight: '432',
			bufferTime: '5', // secs of video to buffer before starting to play
			wmode: 'transparent' // need to set wmode to allow you to float html over the top
		});
	}

	hiConfig = {
        sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)
        interval: 150, // number = milliseconds for onMouseOver polling interval
        timeout: 100, // number = milliseconds delay before onMouseOut
        over: function() {
		 if ($(this).parent('li').find('.sub_nav').is(':visible')) {
				$(this).parent('li').find('.sub_nav').hide();

		}
		else {

			$(this).parent('li').siblings('.has_sub').find('.sub_nav').hide();
			$(this).parent('li').find('.sub_nav').slideDown();
		}
        }, // function = onMouseOver callback (REQUIRED)
        out: function() {  } // function = onMouseOut callback (REQUIRED)
	}
	/*
	$('#nav>ul>li>a').hoverIntent(hiConfig);

	$('li.has_sub>         a').click(function(){
		$('.has_sub').find('.sub_nav').hide();
	});
	*/
	if ($('#item_img').is("div")) {
		$.idleTimer(5000);
		$('#item_img img').not('.hide').fadeIn(1000);
		if ($('.stone_img').is('div')) {
			$('.stone_img img:first').removeClass('hide').addClass('stone_selected').fadeIn();
		}
		$(document).bind("idle.idleTimer", function(){
		 // function you want to fire when the user goes idle
			//$('#nav a').animate({color:'#2c2c27'},1000);
			//$('body,a').animate({color:'#2c2c27'},500);
			$('body,a').addClass('dim',500);
			$('#nav').css('background','transparent');
		});


		$(document).bind("active.idleTimer", function(){
		 // function you want to fire when the user becomes active again
			//$('#nav a').animate({color:'#A39059'},1000);
			//$('body,a').animate({color:'#A39059'},500);
			$('body,a').removeClass('dim',500);
			$('#nav').removeAttr('style');
		});
		//$.idleTimer('destroy');
		$('#right_box').hover(function(){
			$.idleTimer('destroy');
		},function(){
			$.idleTimer(5000);
			$(document).bind("idle.idleTimer", function(){
				$('body,a').addClass('dim',500);
				$('#nav').css('background','transparent');
			});


			$(document).bind("active.idleTimer", function(){
				$('body,a').removeClass('dim',500);
				$('#nav').removeAttr('style');
			});
		});
	}

	$('#view_option a').hover(function(){
		if (!$(this).parent('li').hasClass('option_selected')) {
			$('#view_option li').removeClass('option_selected');
			$(this).parent('li').addClass('option_selected')
			$('#item_img img').hide();
			//$('#'+$(this).attr('title')).fadeIn(500);
			var pos = $(this).parent('li').index();
			$('#item_img img:eq('+pos+')').fadeIn(500);
		}

	});

	$('#collection_cat_view #next').click(function(){
		//$('body').css('background','#fff');
		var x = $('.cat_list ul').position()['left'];
		if (x==0) {
			$('.cat_list ul').animate({'left':'-900px'},500);
		}
		else {
			$('.cat_list ul').animate({'left':'0px'},500);
		}

	});

	$('#collection_cat_view #previous').click(function(){
		//$('body').css('background','#fff');
		var x = $('.cat_list ul').position()['left'];
		if (x==0) {
			$('.cat_list ul').animate({'left':'-900px'},500);
		}
		else {
			$('.cat_list ul').animate({'left':'0px'},500);
		}

	});

	$('#close_statement').click(function(){
		$('#welcome_page').fadeOut(500);
	});

	mouse_in_userform = false;
	mouse_in_feature_form = false;
	$('#userform').hover(function(){
		mouse_in_userform=true;
	    }, function(){
		mouse_in_userform=false;
	});

	$('#feature_form').hover(function(){
		mouse_in_feature_form=true;
	    }, function(){
		mouse_in_feature_form=false;
	});

	$("body").mouseup(function(){
		if(! mouse_in_userform) {
			if ($('#userform').is(':visible'))
				$('#userform').animate({'right':-350},400).fadeOut();
		}
		if (!mouse_in_feature_form) {
			if ($('#feature_form').is(':visible'))
				$('#feature_form').animate({'left':-350},400).fadeOut();
		}
	});


	$('#appointment_a,#userform_logo a').click(function(){
		var pos = $('#userform').css('right');
		if (pos=='-350px') {
			$('#userform').show().animate({'right':50},400);
		}
		else {
			$('#userform').animate({'right':-350},400).fadeOut();
		}
		return false;
	});

	$('#register_event,#feature_form_logo a').click(function(){
		var pos = $('#feature_form').css('left');
		if (pos=='-350px') {
			$('#feature_form').show().animate({'left':150},400);
		}
		else {
			$('#feature_form').animate({'left':-350},400).fadeOut();
		}
		return false;
	});



	if ($('.set_page').is('div')) {
		$('.cat_description:first,.set_list:first').show();
		$('#set_list_info li:first').addClass('set_selected');
		$('#set_list_info li:last').remove();

		$('.set_link').click(function(){
			var id = $(this).attr('term');

			$('.set_list').hide();
			$('#set_list_'+id).show();
			$('#set_list_'+id+' .ring_list:first').show();
			$('#set_list_info li').removeClass('set_selected');
			$(this).parent('li').addClass('set_selected');

			$('.cat_description').hide();
			$('#des_'+id).show();

			return false;
		});



	}
	if ($('.ring_page').is('div')) {
		$('.ring_list').hide();
		$('.ring_list:first').show();


		function next() {
			$('#next_ring').click();
		}

		$('#next_ring').click(function(){
			var id_old = $('.ring_list:visible').attr('data-term');
			var set =false;
			if ($('.ring_list:visible').parent('.set_list').is('div')) {
				set = true;
				set_id = $('.ring_list:visible').parent('.set_list').attr('id');
			}
			clearInterval(ring);
			ring = setInterval(function(){if (!mouseover) $('#next_ring').click();},4000);
			$('#ring_list_'+id_old).hide();
			if ($('#ring_list_'+id_old).next('.ring_list').is('div')) {
				var id = $('#ring_list_'+id_old).next('.ring_list').attr('data-term');
				$('#ring_list_'+id).fadeIn(1000);
				//$('#set_list_info li').removeClass('set_selected');
				//$('#list_'+id).addClass('set_selected');
				//$('.cat_description').hide();
				//$('#des_'+id).show();
			}
			else {
				if (set) {
					$('#'+set_id+' .ring_list:first').fadeIn(1000);
				}
				else {
					$('.ring_list:first').fadeIn(1000);
				}
				//$('#set_list_info li').removeClass('set_selected');
				//$('#set_list_info li:first').addClass('set_selected');
			}

			return false;
		});

		$('#prev_ring').click(function(){
			var id_old = $('.ring_list:visible').attr('data-term');
			var set =false;
			if ($('.ring_list:visible').parent('.set_list').is('div')) {
				set = true;
				set_id = $('.ring_list:visible').parent('.set_list').attr('id');
			}
			clearInterval(ring);
			ring = setInterval(function(){if (!mouseover) $('#next_ring').click();},4000);
			$('#ring_list_'+id_old).hide();
			if ($('#ring_list_'+id_old).prev('.ring_list').is('div')) {
				var id = $('#ring_list_'+id_old).prev('.ring_list').attr('data-term');
				$('#ring_list_'+id).fadeIn(1000);
				//$('#set_list_info li').removeClass('set_selected');
				//$('#list_'+id).addClass('set_selected');
				//$('.cat_description').hide();
				//$('#des_'+id).show();
			}
			else {
				if (set) {
					$('#'+set_id+' .ring_list:last').fadeIn(1000);
				}
				else {
					$('.ring_list:last').fadeIn(1000);
				}
				//$('#set_list_info li').removeClass('set_selected');
				//$('#set_list_info li:last').addClass('set_selected');
			}

			return false;
		});

		var mouseover = false;



		$('.ring_list a').hover(function(){
			$(this).next('.item_description').fadeIn();
			mouseover = true;
			$.idleTimer(3000);

		$(document).bind("idle.idleTimer", function(){
		 // function you want to fire when the user goes idle
			//$('#nav a').animate({color:'#2c2c27'},1000);
			//$('body,a').animate({color:'#2c2c27'},500);
			$('body,a').addClass('dim',500);
			$('#nav').css('background','transparent');
		});


		$(document).bind("active.idleTimer", function(){
		 // function you want to fire when the user becomes active again
			//$('#nav a').animate({color:'#A39059'},1000);
			//$('body,a').animate({color:'#A39059'},500);
			$('body,a').removeClass('dim',500);
			$('#nav').removeAttr('style');
		});
		},function(){
			$(this).next('.item_description').fadeOut();
			 mouseover = false;
			 $.idleTimer('destroy');
		});
		ring = setInterval(function(){if (!mouseover) $('#next_ring').click();},4000);

	}
	if ($('.other_page').is('div')) {
		$('.set_list').show();
	}

	$('#h_wrapper').hover(function(){
			$('#dim').fadeIn('2000');
		}
		,function(){
			$('#dim').fadeOut('1000');
		}
	);


	$("#left_box").nivoSlider({
		effect:'fade', //Specify sets like: 'fold,fade,sliceDown'

		animSpeed:1000, //Slide transition speed
		pauseTime:5000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:false, //Next & Prev
		directionNavHide:false, //Only show on hover
		controlNav:false, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
		controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:true, //Use left & right arrows
		pauseOnHover:false, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){}, //Triggers after all slides have been shown
		lastSlide: function(){}, //Triggers when last slide is shown
		afterLoad: function(){} //Triggers when slider has loaded
	});
	if ($('#right_box').is('div')) {
		el = document.getElementById("right_box");
		scroller = new jsScroller(el, 199, 320);
	}
	$('#feature_reserve,.feature_reserve').click(function(){
			$('.feature_reserve_form').toggle('slow');
		});
	if ($('#feature_photo_list').is('div')) {
		$('.item_wrapper').show().css('height','380px');
		$('.item_photo img').hide();
		$('.item_photo img:first').show();
		$('#item_list li:first a').addClass('selected');
		$('#feature_next').click(function(){
			var cur_feature = $('.item_photo img:visible');
			$('a.selected').removeClass('selected');
			$(cur_feature).hide();
			if ($(cur_feature).next('img').is('img')) {
				$(cur_feature).next('img').fadeIn('slow');
				$('a[data-id='+$(cur_feature).next('img').attr('id')+']').addClass('selected');
			} else {
				$('.item_photo img:first').fadeIn('slow');
				$('#item_list li:first a').addClass('selected');
			}
		});

		$('#feature_prev').click(function(){
			var cur_feature = $('.item_photo img:visible');
			$(cur_feature).hide();
			if ($(cur_feature).prev('img').is('img')) {
				$(cur_feature).prev('img').fadeIn('slow');
				$('a[data-id='+$(cur_feature).prev('img').attr('id')+']').addClass('selected');
			} else {
				$('.item_photo img:last').fadeIn('slow');
				+$('#item_list li:last a').addClass('selected');
			}
		});

		$('.item_photo img').css('cursor','pointer').click(function(){
			$('a[data-id='+$(this).attr('id')+']').click();
		});

		$('#item_list a').mouseover(function(){
			id = $(this).attr('data-id');
			$('#item_list a').removeClass('selected');
			$(this).addClass('selected');
			$('.item_photo img:visible').hide();
			$('#'+id).fadeIn('slow');
		});
/*
		function feature_slideshow() {
			$('#feature_next').click();
		}
		feature_slide = window.setInterval(feature_slideshow,5000);

		$('#features').mouseover(function(){
			clearInterval(feature_slide);
			clearTimeout(feature_slide);
		}).mouseout(function(){
			feature_slide = window.setInterval(feature_slideshow,5000);
		});
		*/

	}


	if ($('.worldmap').is('div')) {
		$('#stones_list li:first a').addClass('selected');
		$('#map_area img:first').show();
		//highlight('Alexandrite');
		listhighlight('Alexandrite');
		$('#stones_list a,#country_list a').hoverIntent({over:function(){
			if (!$(this).hasClass('selected')) {
				$('.selected').removeClass('selected');
				$('#map_area img:visible').fadeOut(500);
				$(this).addClass('selected');
				var name = $(this).html();
				$('#map_area img[data-name="'+name+'"]').fadeIn(1000);
				//highlight(name);
				listhighlight(name);
			}
		},sensitivity:3,interval:150,timeout:100,out:function(){}});



	}

	$('#close_interest').click(function(){
		$('#interest_box').slideUp();
	});


	$('#interest_text').focus(function(){
		$('#interest_box').slideDown();
	});

	$('#interest_box a').click(function(){
		$('#interest_text').val($(this).html().replace('&amp;','&'));
		$('#interest_box').slideUp();
	});

	$('#close_event').click(function(){
		$('#event_box').slideUp();
	});

	$('#event_text').focus(function(){
		$('#event_box').slideDown();
	});

	$('#event_box a').click(function(){
		$('#event_text').val($(this).html().replace('&amp;','&'));
		$('#event_box').slideUp();
		return false;
	});


	$('#userform form').submit(function(){
		var check = true;
		if ($('#userform input[name=name]').val()=='') check=false;
		if ($('#userform input[name=email]').val()=='') check=false;
		if ($('#userform input[name=area]').val()=='') check=false;
		if ($('#userform input[name=mobile]').val()=='') check=false;
		if ($('#userform input[name=comment]').val()=='') check=false;
		if ($('#userform input[name=interest]').val()=='') check=false;

		if (!check) {
			alert('Please fill all fields')
		} else {
			alert('Thanks! Your appointment have been submit.');
			//$('#userform form').clear();
			$('#appointment_a').click();
		}
		return false;
	});

	$('#feature_form form').submit(function(){
		var check = true;
		var err="";
		if ($('#feature_form input[name=name]').val()=='') check=false;
		if ($('#feature_form input[name=email]').val()=='') check=false;
		if ($('#feature_form input[name=area]').val()=='') check=false;
		if ($('#feature_form input[name=mobile]').val()=='') check=false;
		if ($('#feature_form input[name=event]').val()=='') check=false;
		if ($('#feature_form input[name=address]').val()=='') check=false;

		if (!check) {
			alert('Please fill all fields')
		} else {
			alert('Thanks! Your appointment have been submit.');
			//$('#userform form').clear();
			$('#register_event').click();
		}
		return false;
	});

	if ($('#photo_list').is('div')) {
		$('#item_list ul li:last').addClass('last');
		$('.item_wrapper:first').show();
		$('#item_list ul li:first a').addClass('selected');

		$('#item_list ul li a').click(function(){
			var id = $(this).attr('data-id');
			if (!$(this).hasClass('selected')) {
				$('#item_list .selected').removeClass('selected');
				$(this).addClass('selected');
				$('.item_wrapper:visible').hide();
				$('#'+id).show();
			}
			return false;
		});

		$(".item_photo").nivoSlider({
			effect:'fade', //Specify sets like: 'fold,fade,sliceDown'

			animSpeed:500, //Slide transition speed
			pauseTime:5000,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:true, //Next & Prev
			directionNavHide:false, //Only show on hover
			controlNav:false, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
			controlNavThumbsFromRel:false, //Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', //Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:false, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){}, //Triggers after all slides have been shown
			lastSlide: function(){}, //Triggers when last slide is shown
			afterLoad: function(){} //Triggers when slider has loaded
		});


	}
	if ($('#video_list').is('div')) {
		$('#item_list ul li:last').addClass('last');
		$('.video_wrapper:first').show();
		$('#item_list ul li:first a').addClass('selected');

		$('#item_list ul li a').click(function(){
			var id = $(this).attr('data-id');
			if (!$(this).hasClass('selected')) {
				$('#item_list .selected').removeClass('selected');
				$(this).addClass('selected');
				$('.video_wrapper:visible').hide();
				$('#'+id).show();
			}
			return false;
		});
	}

	$('#column2 label').click(function(){
		if ($(this).hasClass('checked')) {
			$(this).removeClass('checked');
		} else {
			$(this).addClass('checked');
		}
	});

	$('#form_page form').validate({
		errorClass: "invalid",
		errorContainer: "#dumb_report,#error_report",
		errorLabelContainer: "#dumb_report ul",
		wrapper: "li",
		submitHandler: function(form) {
			// some other code
			// maybe disabling submit button
			// then:
			//$(form).ajaxSubmit();
			//alert('Thanks You for your submit.');
			$(form).ajaxSubmit({success:function(){
				if ($('input[name=type]').val()=='event') {
					$('#error_report p').html('Thank you for submitting your registration. The Events Team will contact you shortly.');
				}
				else {
					$('#error_report p').html('Thank you. The concierge team will confirm an appointment with you shortly.');
				}
				$('#error_report').show();
				setTimeout(function(){
					$('#form_page').fadeOut(1000);
				},2000);

				setTimeout(function(){
					window.location = "/";
				},4000);
			}});

			return false;
		}
	});

	if ($('.communique').is('div')) {
		$('#left_communique_box img:first').show();
		$('#right_box a:first').addClass('selected');
		$('.communique_select').click(function(){
			if (!$(this).hasClass('selected')) {
				$('#right_box .selected').removeClass('selected');
				$(this).addClass('selected');
				$('.communique img:visible').hide();
				$('#'+$(this).attr('data-id')).fadeIn(1000);
			}
			return false;
		});
	}


	$('#item_list a').hover(function(){
		$(this).find('.infor').show();
	},function(){
		$(this).find('.infor').hide();
	});

	$('.landing_block').hover(function(){
		$(this).find('.info').show();
	},function(){
		$(this).find('.info').hide();
	});

	$(".slider").nivoSlider({
			effect:'fade', //Specify sets like: 'fold,fade,sliceDown'

			animSpeed:500, //Slide transition speed
			pauseTime:5000,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:false, //Next & Prev
			directionNavHide:false, //Only show on hover
			controlNav:false, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
			controlNavThumbsFromRel:false, //Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', //Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:false, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){}, //Triggers after all slides have been shown
			lastSlide: function(){}, //Triggers when last slide is shown
			afterLoad: function(){} //Triggers when slider has loaded
		});

	if ($('#landing_feature').is("div")) {

		$(".slider1").nivoSlider( {
			effect:'fade', //Specify sets like: 'fold,fade,sliceDown'

			animSpeed:500, //Slide transition speed
			pauseTime:5000,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:false, //Next & Prev
			directionNavHide:false, //Only show on hover
			controlNav:false, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
			controlNavThumbsFromRel:false, //Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', //Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:false, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){}, //Triggers after all slides have been shown
			lastSlide: function(){}, //Triggers when last slide is shown
			afterLoad: function(){} //Triggers when slider has loaded
		});
		wait(1000);
		$(".slider2").nivoSlider({
			effect:'fade', //Specify sets like: 'fold,fade,sliceDown'

			animSpeed:500, //Slide transition speed
			pauseTime:5000,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:false, //Next & Prev
			directionNavHide:false, //Only show on hover
			controlNav:false, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
			controlNavThumbsFromRel:false, //Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', //Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:false, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){}, //Triggers after all slides have been shown
			lastSlide: function(){}, //Triggers when last slide is shown
			afterLoad: function(){} //Triggers when slider has loaded
		});
		wait(1000);
		$(".slider6").nivoSlider({
			effect:'fade', //Specify sets like: 'fold,fade,sliceDown'

			animSpeed:500, //Slide transition speed
			pauseTime:5000,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:false, //Next & Prev
			directionNavHide:false, //Only show on hover
			controlNav:false, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
			controlNavThumbsFromRel:false, //Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', //Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:false, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){}, //Triggers after all slides have been shown
			lastSlide: function(){}, //Triggers when last slide is shown
			afterLoad: function(){} //Triggers when slider has loaded
		});
		wait(1000);
		$(".slider3").nivoSlider({
			effect:'fade', //Specify sets like: 'fold,fade,sliceDown'

			animSpeed:500, //Slide transition speed
			pauseTime:5000,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:false, //Next & Prev
			directionNavHide:false, //Only show on hover
			controlNav:false, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
			controlNavThumbsFromRel:false, //Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', //Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:false, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){}, //Triggers after all slides have been shown
			lastSlide: function(){}, //Triggers when last slide is shown
			afterLoad: function(){} //Triggers when slider has loaded
		});
		wait(1000);
		$(".slider4").nivoSlider({
			effect:'fade', //Specify sets like: 'fold,fade,sliceDown'

			animSpeed:500, //Slide transition speed
			pauseTime:5000,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:false, //Next & Prev
			directionNavHide:false, //Only show on hover
			controlNav:false, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
			controlNavThumbsFromRel:false, //Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', //Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:false, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){}, //Triggers after all slides have been shown
			lastSlide: function(){}, //Triggers when last slide is shown
			afterLoad: function(){} //Triggers when slider has loaded
		});
	}
});

function wait(milsecs){
	var to_time = new Date().getTime() + milsecs;
	while( new Date().getTime() < to_time ){}
	return true;
}

function slide(where){

            //get the item width
            var item_width = $('#carousel_ul li').outerWidth() + 14;

            /* using a if statement and the where variable check
            we will check where the user wants to slide (left or right)*/
            if(where == 'left'){
                //...calculating the new left indent of the unordered list (ul) for left sliding
                var left_indent = parseInt($('#carousel_ul').css('left')) + item_width;
            }else{
                //...calculating the new left indent of the unordered list (ul) for right sliding
                var left_indent = parseInt($('#carousel_ul').css('left')) - item_width;

            }


            //make the sliding effect using jQuery's animate function... '
            $('#carousel_ul:not(:animated)').animate({'left' : left_indent},500,function(){

                /* when the animation finishes use the if statement again, and make an ilussion
                of infinity by changing place of last or first item*/
                if(where == 'left'){
                    //...and if it slided to left we put the last item before the first item
                    $('#carousel_ul li:first').before($('#carousel_ul li:last'));
                }else{
                    //...and if it slided to right we put the first item after the last item
                    $('#carousel_ul li:last').after($('#carousel_ul li:first'));
                }

                //...and then just get back the default left indent
                $('#carousel_ul').css({'left' : '-224px'});
            });
        }

