$(document).ready(function(){
			$("#homepage_app_footer #feedback").attr('href','http://mystart.uservoice.com/forums/9164-general?lang='+ L["Feedback Language Constant"])

$("#homepage_footer_theme").click(function() {
	$('#pageoption').trigger('show');
	$('#search_theme_tab').trigger('click');
	
	// set current slide as active
	try{
	 	var fullfilename = $.fn.getCurrentSlide();	
	 	filename = fullfilename.substring(fullfilename.lastIndexOf('/')+1);
	 	$('#thumbs img').removeClass('active');
	 	$('#thumbs img[src$="'+ filename +'"]').addClass('active');
	 	} catch(e)
 	{};
	return false;
});

$("#homepage_footer_language").click(function() {
	$('#pageoption').trigger('show');
	$('#search_interface_tab').trigger('click');
	return false;
});

$("#homepage_footer_preferences").click(function() {
	$('#pageoption').trigger('show');
	return false;
});

var lang = {
	en : 'English', 
	fr : 'Français', 
	es : 'Español', 
	de : 'Deutsch', 
	it : 'Italiano'
};

$('#homepage_footer_language').html(lang[L['Feedback Language Constant']]);
$('#homepage_footer_theme').html(L['Choose a background picture']);
$('#homepage_footer_preferences').html(L['Preferences']);
$('#feedback').html(L['Feedback']);
var iSearchSuggestionNumber = "8";

$("#search_preferences").click(function() {
	$('#pageoption').trigger('show');
	return false;
});

$("#option_panes_search_pref").html('<input type="checkbox" value="1" class="SafeSearch" id="safesearch_checkbox" /> ' + L["Safe Search (non adult content only)"]);

if($.cookie("vmn-mystart_y-1_0SafeSearchOn") == 'yes') {
	$("#safesearch_on").val("yes");
	$("#safesearch_checkbox").attr('checked', true);
}

$("#safesearch_checkbox").click(function() {
	if($('#safesearch_checkbox:checked').val() != undefined) { 
		$.cookie("vmn-mystart_y-1_0SafeSearchOn", "yes",{ expires: 365});
		$('#safesearch_on').val('yes');
	} else {
		$.cookie("vmn-mystart_y-1_0SafeSearchOn", "no",{ expires: 365});
		$('#safesearch_on').val('no');
	}
});


$(".q").inputCaption({
	'caption': "", 
	'color': '#aaa'
});

$('#pageoption').bind('show', function(oEvent, iPanel) {

	var oTabAPI = $("#pageoption ul.tabs").tabs(
		"#pageoption div.panes > div", { initialIndex: iPanel }
	);
	
	var oCBox = jQuery.colorbox({ 
		inline: true, 
		href: "#pageoption", 
		open: true, 
		initialWidth: 10,
		initialHeight: 10,
		width: 600, 
		height: 300,
		opacity: .4
	});
	
	oCBox.bind('cbox_closed', function() {
		oCBox.unbind('cbox_closed');
		// reset the bg popup
		setBackgroundDescriptions();
	});
	
});

if($("#homepage_topbar").length != 0) {
	$("#homepage_topbar a.options").click(function() {
		$('#pageoption').trigger('show');
		return false;
	});
}

if($("#homepage_searchfeedbar").length != 0) {
	$("#homepage_searchfeedbar a.options").click(function() {
		$('#pageoption').trigger('show');
		return false;
	});
}

$('#search_preferences').html(L['Preferences']);
$('.buttonlabel').html(L['Web Search']);

	
	
$('#search_preferences_tab').html(L['Search']);
$('#search_interface_tab').html(L['Language']);
$('#search_theme_tab').html(L['Themes']);

if($.cookie("vmn-mystart_y-1_0language") != '') {
	var language = $.cookie("vmn-mystart_y-1_0language");
	$('#option_panes_interface input').filter("[value="+language+"]").attr('checked', true);
}

// when language is changed, set cookie reload page immediately
$("#option_panes_interface input").change(function() {
	$.cookie("vmn-mystart_y-1_0language",$(this).val(),{ expires: 365});
	location.reload();
});

$(".searchbutton").click(function(){
	if($(this).siblings(".q").val() != "")
		$("form").filter(":visible").submit();
});	
	
$('#option_panes_theme_selector_text').html(L["Choose a background picture"]);

$('#option_panes_theme_selector_text_no_image a').html(L['Remove Theme']);

$('#option_panes_theme_selector_text_no_image').click(function (){
	try{
		$.fn.superbgShowImage(1);
	}catch(e)
	{};
	// set cookie to blank
	$.cookie("vmn-mystart_y-1_0HomepageBackgroundImage",'./resources/images/large_backgrounds/0000_blank.png',{ expires: 365});
	//set new image as current
	$('#thumbs').find('img').removeClass('active');
	$('#thumbs img:first-child').addClass('active');
})

// show the right searchform
	
			$("#homepage_app_searchbox #homepage_app_searchform_mystart-y").show();
	
// set focus to active searchbox
$('#homepage_app_searchbox input.q:visible').focus();

$('.searchtabs').click(function(){
	$(this).siblings().removeClass('current');
	$(this).addClass('current');

	// hide all forms
	$("#homepage_app_searchbox .homepage_app_searchform").hide();

			
		var dir = 'yahoo'; 
		if($(this).attr('id').indexOf('images') > -1)
		{
			var dir = 'flickr';
			$("#homepage_app_searchbox #homepage_app_searchform_mystart-y").show();
		}
		else if($(this).attr('id').indexOf('videos') > -1)
		{
			var dir = 'youtube';
			$("#homepage_app_searchbox #homepage_app_searchform_mystart-y").show();
		}
		else // this is for the web search
		{
							$("#homepage_app_searchbox #homepage_app_searchform_mystart-y").show();
					}
		$('#homepage_app_searchbox .end img').attr('src','./search_feeds/'+ dir +'/images/powered_by_square.png');
		$('#homepage_app_searchform_mystart-y input[name="searchfeed"]').attr('value', dir);
		
	// change button label if default label was web search
			var buttonlabel = 'Web Search';
		if($(this).attr('id').indexOf('images') > -1)
			buttonlabel = 'Image Search';
		else if($(this).attr('id').indexOf('videos') > -1)
			buttonlabel = 'Video Search';
			
		$('#homepage_app_searchbox .buttonlabel').html(L[buttonlabel]);	
		
		
	calcSuggestionWidth();
	
});
		
		
		
		
		
		
	// Themes
	var bAnimationRunning = false;
	var oScrollingDiv = $("#option_panes_theme_selector .scrolling");
	var iThemeImageCount = 0;

	function createThumbList(data){
		var oImgTemplate = $("#option_panes_theme_selector a.template");
		oImgTemplate.remove();
		var sImagePath = './resources/images/thumbs_backgrounds/';
		bRetrived2 = true;
		var count = 0;
		var thumbsRow1 = $("<div />");
		var thumbsRow2 = $("<div />");
		var thumbsRow3 = $("<div />");			
		$.each(data, function(i, oneEntry) {
			var oNew = oImgTemplate.clone();
			oNew.attr('href', './resources/images/large_backgrounds/'+i);
			var oNewImg = $(oNew).children('img');
			oNewImg.attr('src', './resources/images/thumbs_backgrounds/'+i);
			oNewImg.attr('title', oneEntry.name );

			oNew.append(oNewImg);
			jQuery(oNewImg).click(onThemeImageClick);

			jQuery(oNewImg).mouseover(onThemeImageMouseover);
			
			jQuery(oNewImg).mouseout(onThemeImageMouseout);
			
			//populate 3 rows with images (because the new images should be on the left)
			if(iThemeImageCount%3 == 0)
				thumbsRow1.append(oNew);
			if(iThemeImageCount%3 == 1)
				thumbsRow2.append(oNew);	
			if(iThemeImageCount%3 == 2)
				thumbsRow3.append(oNew);	
				
			iThemeImageCount++;
			count++;
		});

		$("#option_panes_theme_selector .scrolling").append(thumbsRow1);
		$("#option_panes_theme_selector .scrolling").append(thumbsRow2);
		$("#option_panes_theme_selector .scrolling").append(thumbsRow3);

		updateThumbTitles(data);
	}    

	$("#option_panes_theme_selector .next").click(function() {
		var iPos = parseInt(oScrollingDiv.css('left'));
		if (bAnimationRunning == false && iPos > -(iThemeImageCount * 84 /3) + 6 * 84) { 
			bAnimationRunning = true;
			oScrollingDiv.animate(
				{ left: '-=505' }, {
					duration: 800, 
					complete: function() { bAnimationRunning = false; }
				}
			);
		} 
		return false;
	});

	var onThemeImageClick = function() {
		$(this).parent().parent().parent().find('img').removeClass('active');
		$(this).addClass('active');
		return true;
	}

	var onThemeImageMouseover = function() {
		var file = $(this).parent().attr('href');
		file = file.substring(file.lastIndexOf('/')+1);
		if(file != '0000_blank.png')
		{
			setBackgroundDescriptions(file);
			$('#slideinfo').trigger('mouseover');
		}
	}

	var onThemeImageMouseout = function() {
		$('#slideinfo').trigger('mouseout');
	}

	$("#option_panes_theme_selector .prev").click(function() {
		var iPos = parseInt(oScrollingDiv.css('left'));
		if (bAnimationRunning == false && iPos < 0) {
			bAnimationRunning = true;
			oScrollingDiv.animate(
				{ left: '+=505' }, { 
					duration: 800,
					complete: function() { bAnimationRunning = false; }
				}
			);
		}
		return false;
	});	
	
	$('#searchtabs_web').html(L['Web Search Link']);
	$('#searchtabs_images').html(L['Images']);
	$('#searchtabs_videos').html(L['Videos']);	

	$('#suggestiontabs_web .content').html(L['Web Search Link']);
	$('#suggestiontabs_images .content').html(L['Images']);
	$('#suggestiontabs_videos .content').html(L['Videos']);	
	
	if($.browser.msie && $.cookie('vmn-mystart_y-1_0HomepageBackgroundMakeItHomepage') == null )
	{
		$('#makeHomepage').show();
	}
		
	/**
	** This should only be executed when both "thumbs_backgrounds" and "backgrounds_descriptions" are loaded
	**/	
	function updateThumbTitles(data){
		$.each(data, function(i, imageDescription) {
			var imageTitle = '';
		 	// get the current language
 			var lang = $('#option_panes_interface input:checked').val();
 			if(typeof(imageDescription.name) === 'object')
 			{
 				if(imageDescription.name[lang] != undefined)
 					imageTitle = imageDescription.name[lang];
 				else
 					imageTitle = imageDescription.name.en;
 			}
	 		else
				imageTitle = imageDescription.name;

			$('.bg-thumbs[src$="'+i+'"]').attr('title',imageTitle);
		});
	}
	
 	function setBackgroundDescriptions(filename){
 	
 		// update description with current bg-image 
 		if(typeof(filename) === 'undefined')
 		{
 			try{
	 			var fullfilename = $.fn.getCurrentSlide();	
	 			filename = fullfilename.substring(fullfilename.lastIndexOf('/')+1);
 			} catch(e) {
 				return;
 			};
		}
	
 		var imageDescription = window.imageDescriptions[filename];
 		if(typeof(imageDescription) !== 'undefined')
 		{	
 			// get the current language
 			var lang = $('#option_panes_interface input:checked').val();
 			if(typeof(imageDescription.name) === 'object')
 			{
 				if(imageDescription.name[lang] != undefined)
 					$('#slideheader').html(imageDescription.name[lang]);
 				else
 					$('#slideheader').html(imageDescription.name.en);
 			}
	 		else
				$('#slideheader').html(imageDescription.name);
			
 			// add the maps link
 			if(imageDescription.map != undefined)
 				$('#slideheader').append(' <a href="'+imageDescription.map+'" target="_blank"><img src="resources/images/icons_logos/gmaps.png" alt="gmaps"></a>');
 			
 			if(imageDescription.detail != undefined)
 			{
	 			var imageDetail = '';
 				if(typeof(imageDescription.detail) === 'object')
	 			{
	 				if(imageDescription.detail[lang] != undefined)
	 					imageDetail = imageDescription.detail[lang];
	 				else
	 					imageDetail = imageDescription.detail.en;
	 			}
		 		else
		 			imageDetail = imageDescription.detail;
 			}
 			
	 		if(imageDescription.provider == 'veer')
	 		{
	 			var veerTrackUrl = 'http://offers.veer.com/click.track?CID=134842&AFID=189279&ADID=626009&SID=&NonEncodedURL=';
	 			//$('#slidebody').html(' Stock Photo: <a class="shoplink slidelink" href="#" target="_blank">'+imageDescription.stockPhoto+'</a>');
	 			$('#slidebody').html('');
	 			$('#slidefooter').show();
	 			$('#slidefooter').html('<span>Purchase this image on </span><a class="shoplink" href="#" target="_blank"><strong class="slidelink">Veer.com</strong><img src="resources/images/icons_logos/veer_22x14.png"/></a>');
	 			$('#slidedescription .shoplink').attr('href', veerTrackUrl + 'http://marketplace.veer.com/products/' + imageDescription.id);
	 		}
	 		else
	 		{
	 			if(imageDescription.author != undefined && imageDescription.author != '')
	 				$('#slidebody').html('by: ' + imageDescription.author);
	 			
	 			$('#slidefooter').hide();
	 		}	
 			
	 		if(imageDetail != undefined)
	 			$('#slidebody').append('<div class="slidedetails">' + imageDetail.text + ' <a href="' + imageDetail.link + '" target="_blank"><span class="slidelink">More Info</span><img src="resources/images/icons_logos/external-12x12.png"/></a></div>');
 		}
 		else
 		{
 			$('#slidebody').html('No description available.');
 		}	
 	}	


	calcSuggestionWidth();

	// Suggestion handling
	var sLastQuery = '';
	var iSelected = -1;
	
	var applyMouseHandler = function () {
		var oLISuggestion = $(".suggetion .result li");  	
		oLISuggestion.mouseenter(function(oEvent) {
			oLISuggestion.removeClass('selected');
			jQuery(this).addClass('selected');
		});
		oLISuggestion.mouseleave(function(oEvent) {
			jQuery(this).removeClass('selected');
		});
		oLISuggestion.click(function(oEvent) {
			iSelected = jQuery(this).index(); 
			$(".q").val(jQuery(this).text());
			sLastQuery = jQuery(this).text();
			$("form").filter(":visible").submit();
		});
	}

	
			var onYahooResult = function(a, oULResult, sQuery) {
			oULResult.empty();
			for(var i in a.ResultSet.Result) {
				var sSuggestion = a.ResultSet.Result[i];
				var iPos = sSuggestion.indexOf(sQuery);
				var sFinal = "<strong>"+ sSuggestion.substr(0, iPos)+ "</strong>"+ sSuggestion.substr(iPos, sQuery.length)+"<strong>"+ sSuggestion.substr(iPos + sQuery.length)+ "</strong>";
				oULResult.append("<li>"+ sFinal +"</li>");
			}
			applyMouseHandler();				
			if (sQuery) {
				$(".suggetion").slideDown();
			} else {
				$(".suggetion").slideUp();
			}
		}
	
	$(".q").keyup(function(oEvent) {
		var sQuery = jQuery(this).val();
		if(sQuery.length <= 0)
			return false;
	
		var oULResult = $(".suggetion ul.result");
					if(sLastQuery != sQuery)
			{ 
				jQuery.getJSON(
					'http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=YahooDemo&results='+ iSearchSuggestionNumber +'&output=json&query='+ escape(sQuery)+ '&callback=?',
					function(a) { onYahooResult(a, oULResult, sQuery); }
				);
				iSelected = -1;
			}
			
			
		sLastQuery = sQuery;
	
		if (oEvent.which == 40 || oEvent.which == 38) { // up or down
			iSelectedNew = (oEvent.which == 40 ? iSelected+1: iSelected-1); // 40=down
			var numItems = $(".suggetion ul.result li").length;
			if (iSelectedNew >= 0 && iSelectedNew < numItems) 
			{
				oULResult.find("li:eq("+ iSelected+ ")").removeClass('selected');
				iSelected = (oEvent.which == 40 ? iSelected+1: iSelected-1);
				var oLISelected = oULResult.find("li:eq("+ iSelected+ ")").addClass('selected');
				$(this).val(oLISelected.text());
				sLastQuery = oLISelected.text(); 
			}
		}
		
		if (oEvent.which == 13) {
			$("form").filter(":visible").submit();
		}
		
		if (oEvent.which == 27) {
			$(".suggetion").slideUp();
		}
		
	});

	$("body").click(function(e) {
		// when anything is clicks, except the searchtabs, then remove the suggestions
		if($(e.target).isChildOf('#suggestion_searchtabs') == false)
			$(".suggetion").slideUp();
	});


function calcSuggestionWidth()
{
	// JS Fix of width suggestion width base on button space 	
	var pos1 = $(".searchbutton:visible").offset().left;
	var pos2 = $("#searchBoxInputArea").offset().left;
	var iInputFieldWidth = pos1 - pos2;

	$(".q").css('width', iInputFieldWidth + 'px'); 	
	$(".suggetion").css('width', iInputFieldWidth + 'px'); 
}


(function($) {
    $.fn.extend({
        isChildOf: function( filter_string ) {
          
          var parents = $(this).parents().get();
         
          for ( j = 0; j < parents.length; j++ ) {
           if ( $(parents[j]).is(filter_string) ) {
      return true;
           }
          }
          
          return false;
        }
    });
})(jQuery); 
var TopValue = 0;
var BottomValue = 0;
var EndUserModifyable = "";

if($("#homepage_topbar").length != 0 || $("#homepage_searchfeedbar").length != 0) {
	var heightTb = $("#homepage_topbar").height();
	var heightSfb = $("#homepage_searchfeedbar").height();
	var height = heightTb + heightSfb;
	TopValue += height;
}

if($("#homepage_logoarea").length != 0) {
	TopValue += $("#homepage_logoarea").outerHeight();
}

if($("#homepage_app_footer").length != 0) {
	BottomValue += 35;
	if($("#footer_logo").length != 0) {
		BottomValue += 66;
	}
}

$("#homepage_background").css("top", 0);
$("#homepage_background").css("bottom", 0);




// this is a workaround, because the AJAX call above causes trouble in IE
var data = { "0000_blank.png":{ "id":"0000_blank.png","name":"","author":"","stockPhoto":"","provider":"visicom"},"1892766.jpg":{ "id":"1892766","name":"Blue Striped Snapper in Hawaii","author":"","stockPhoto":"","provider":"veer"},"2515670.jpg":{ "id":"2515670","name":"Rio De Janeiro Brazil","author":"","stockPhoto":"","provider":"veer"},"2627746.jpg":{ "id":"2627746","name":"wooden background","author":"","stockPhoto":"","provider":"veer"},"2738252.jpg":{ "id":"2738252","name":"Sunflower","author":"","stockPhoto":"","provider":"veer"},"2947195.jpg":{ "id":"2947195","name":"Golden Gate Bridge at night","author":"","stockPhoto":"","provider":"veer"},"CUP0051339.jpg":{ "id":"CUP0051339","name":"Tower Bridge lit up at night","author":"","stockPhoto":"","provider":"veer"},"OCP0112532.jpg":{ "id":"OCP0112532","name":"Horseshoe Bend, Colorado River","author":"","stockPhoto":"","provider":"veer"},"0020.jpg":{ "id":"2481259","name":"airplane","author":"veerguy","stockPhoto":"2481259","provider":"veer","availableForRandom":true},"0021.jpg":{ "id":"1000905035","name":"Bora Bora Islands, aerial view","author":"Ocean Photography","stockPhoto":"2481259","provider":"veer","availableForRandom":true,"map":"http:\/\/g.co\/maps\/ms5w","detail":{ "en":{ "link":"http:\/\/en.wikipedia.org\/wiki\/Bora_Bora","text":"A major international tourist destination, famous for its aqua-centric luxury resorts."}}},"0022.jpg":{ "id":"1002464484","name":"Erg Admer, Sahara, Algeria","author":"Fancy Photography","stockPhoto":"FAN9007923","provider":"veer","availableForRandom":true,"map":"http:\/\/g.co\/maps\/fst9","detail":{ "en":{ "link":"http:\/\/en.wikipedia.org\/wiki\/Erg_(landform)","text":"An erg (also sand sea or dune sea) is a broad, flat area of desert covered with wind-swept sand with little or no vegetative cover."},"fr":{ "link":"http:\/\/fr.wikipedia.org\/wiki\/Erg_(dune)","text":"Un erg (mot provenant de l'arabe) d&eacute;signe un d&eacute;sert de dunes, plus pr&eacute;cis&eacute;ment des champs de dunes fixes dont seul le sable superficiel est remodel&eacute; sans cesse par le vent. "}}},"0023.jpg":{ "id":"1000853537","name":"Tree frog","author":"Corbis Photography","stockPhoto":"CBP1018670","provider":"veer","availableForRandom":true},"0024.jpg":{ "id":"3156367","name":"New York City Manhattan","author":"David Deng","stockPhoto":"3156367","provider":"veer","availableForRandom":true,"map":"http:\/\/g.co\/maps\/b2v7","detail":{ "en":{ "link":"http:\/\/en.wikipedia.org\/wiki\/Manhattan","text":"New York City Manhattan aerial skyline panorama view with skyscrapers and office buildings on street."}}},"0025.jpg":{ "id":"2569128","name":"Moonlight","author":"GoodOlga","stockPhoto":"2569128","provider":"veer","availableForRandom":true,"detail":{ "en":{ "link":"http:\/\/en.wikipedia.org\/wiki\/Moonlight","text":"Moonlight is the light that reaches Earth from the Moon. This light does not originate from the Moon, but from sunlight."},"fr":{ "link":"http:\/\/fr.wikipedia.org\/wiki\/Clair_de_lune","text":"Le clair de lune est la lumi&egrave;re re\u00e7ue la nuit sur Terre depuis son satellite naturel, la Lune. Cette lumi&egrave;re n'est qu'indirecte, la Lune ne fait que refl&eacute;ter celle du Soleil."}}},"0026.jpg":{ "id":"2378416","name":"Street Art","author":"ncousla","stockPhoto":"2378416","provider":"veer","availableForRandom":true,"detail":{ "en":{ "link":"http:\/\/en.wikipedia.org\/wiki\/Street_art","text":""}}},"0027.jpg":{ "id":"1366032","name":"Grunge background","author":"IKO","stockPhoto":"1366032","provider":"veer","availableForRandom":true},"0028.jpg":{ "id":"1619563","name":"Mesa Arch and Washerwoman Arch at Sunset, Canyonlands, UT","author":"lumenessence","stockPhoto":"1619563","provider":"veer","availableForRandom":true,"map":"http:\/\/g.co\/maps\/mngu","detail":{ "en":{ "link":"http:\/\/en.wikipedia.org\/wiki\/Canyonlands_National_Park","text":"View across Canyonlands, Moab, Utah with Mesa Arch - Washerwoman formation in center."},"fr":{ "link":"http:\/\/fr.wikipedia.org\/wiki\/Parc_national_de_Canyonlands","text":"Le parc national de Canyonlands est situ&eacute; pr&egrave;s de Moab, dans l'Utah."}}},"0030.jpg":{ "id":"1000677457","name":"Carousel Horse on Merry-Go-Round","author":"Corbis Photography","stockPhoto":"CBP0030570","provider":"veer","availableForRandom":true},"0031.jpg":{ "id":"1002360447","name":"Looking down on tulip fields from an airplane, Holland, Netherlands.","author":"Aurora Open","stockPhoto":"AYP2900881","provider":"veer","availableForRandom":true,"detail":{ "en":{ "link":"http:\/\/www.keukenhof.nl\/en\/","text":"Tulips, along with windmills, clogs (wooden shoes) are typically associated with Holland."},"fr":{ "link":"http:\/\/www.keukenhof.nl\/en\/","text":"Le Keukenhof est un parc floral situ\u00e9 au nord-ouest de Lisse, en Hollande m\u00e9ridionale, aux Pays-Bas. Il est ouvert chaque ann\u00e9e de la mi-mars \u00e0 la mi-mai."}}},"0032.jpg":{ "id":"1002394674","name":"Rice terraces, Lonji, China","author":"OJO Images","stockPhoto":"OJP0018649","provider":"veer","availableForRandom":true,"detail":{ "en":{ "link":"http:\/\/en.wikipedia.org\/wiki\/Terrace_(agriculture)","text":""}}},"0033.jpg":{ "id":"1002629398","name":"Looking up at the dome of St Peter's Basilica","author":"Ocean Photography","stockPhoto":"OCP0123424","provider":"veer","availableForRandom":true,"map":"http:\/\/g.co\/maps\/kzs9","detail":{ "en":{ "link":"http:\/\/en.wikipedia.org\/wiki\/St_Peter%27s_Basilica","text":"The dome of St. Peter's rises to a total height of 136.57 metres (448.1 ft), making it the tallest dome in the world."}}},"0001.jpg":{ "id":1002628219,"name":{ "en":"Manhattan Bridge taken in Brooklyn","fr":"Le pont de Manhattan vu de Brooklyn"},"author":"moodboard Photography","stockPhoto":"MWP0058776","provider":"veer","availableForRandom":true,"map":"http:\/\/g.co\/maps\/hc2m","detail":{ "en":{ "link":"http:\/\/en.wikipedia.org\/wiki\/Manhattan_Bridge","text":"The Manhattan Bridge is a suspension bridge that crosses the East River in New York City, connecting Lower Manhattan with Brooklyn."},"fr":{ "link":"http:\/\/fr.wikipedia.org\/wiki\/Pont_de_Manhattan","text":"Le pont de Manhattan est un pont suspendu de la ville de New York au-dessus de l'East River, qui relie la partie inf&eacute;rieure de l'\u00eele de Manhattan au borough de Brooklyn."}}},"0002.jpg":{ "id":3508088,"name":"Paris, France","author":"interlight","stockPhoto":"3508088","provider":"veer","availableForRandom":true,"map":"http:\/\/g.co\/maps\/ecgq","detail":{ "en":{ "link":"http:\/\/en.wikipedia.org\/wiki\/Eiffel_Tower","text":"Sunrise in Paris, with the Eiffel Tower"}}},"0003.jpg":{ "id":2797361,"name":"The Lonely Lavender Tree","author":"thinkjames","stockPhoto":"2797361","provider":"veer","availableForRandom":true,"detail":{ "en":{ "link":"http:\/\/en.wikipedia.org\/wiki\/Lavender","text":"Can you imagine the wonderful smell?"}}},"0004.jpg":{ "id":1002666777,"name":"Chinese lanterns at night","author":"Ocean Photography","stockPhoto":"OCP0152894","provider":"veer","availableForRandom":true},"0005.jpg":{ "id":3181780,"name":"Varanasi in India","author":"yuliang11","stockPhoto":"3181780","provider":"veer","availableForRandom":true},"0006.jpg":{ "id":1000823824,"name":"verdent public garden","author":"Ocean Photography","stockPhoto":"BXP0027679","provider":"veer","availableForRandom":true},"0007.jpg":{ "id":2357398,"name":"Taj Mahal Sunset from Jamuna River","author":"Pius Lee","stockPhoto":"2357398","provider":"veer","availableForRandom":true},"0008.jpg":{ "id":1170123,"name":"Umbrellas on beach","author":"enjoylife25","stockPhoto":"1170123","provider":"veer","availableForRandom":true},"0009.jpg":{ "id":1406802,"name":"Meteor in atmosphere above clouds","author":"eraxion","stockPhoto":"1406802","provider":"veer","availableForRandom":true},"0010.jpg":{ "id":1099674,"name":"Thai wood carving","author":"sumners","stockPhoto":"1099674","provider":"veer","availableForRandom":true},"0011.jpg":{ "id":3126102,"name":"Yellow flower","author":"pulen","stockPhoto":"3126102","provider":"veer","availableForRandom":true},"0012.jpg":{ "id":3114650,"name":"Sunset on Sri Lanka","author":"fyle","stockPhoto":"3114650","provider":"veer","availableForRandom":true},"0013.jpg":{ "id":1000829860,"name":"Brown-eyed Susans","author":"Fancy","stockPhoto":"FAN2018939","provider":"veer","availableForRandom":true},"0014.jpg":{ "id":1379013,"name":"Earthbound","author":"Corey Ford","stockPhoto":"1379013","provider":"veer","availableForRandom":true},"0015.jpg":{ "id":1002053141,"name":"Flower close up","author":"Image Source","stockPhoto":"ISP2121013","provider":"veer","availableForRandom":true},"14_center_center.jpg":{ "id":"14_center_center.jpg","name":"Cheeses","author":"Elad","stockPhoto":"","provider":"visicom"},"18_center_center.jpg":{ "id":"18_center_center.jpg","name":"Mountain landscape ","author":"Elad","stockPhoto":"","provider":"visicom"},"4_center_center.jpg":{ "id":"4_center_center.jpg","name":"Airplane","author":"Elad","stockPhoto":"","provider":"visicom"},"7_center_center.jpg":{ "id":"7_center_center.jpg","name":"Desert","author":"Elad","stockPhoto":"","provider":"visicom"},"19_center_top.jpg":{ "id":"19_center_top.jpg","name":"Sharks","author":"Elad","stockPhoto":"","provider":"visicom"},"2_center_center.jpg":{ "id":"2_center_center.jpg","name":"Dream catcher","author":"Elad","stockPhoto":"","provider":"visicom"},"5_right_center.jpg":{ "id":"5_right_center.jpg","name":"Beach","author":"Elad","stockPhoto":"","provider":"visicom"},"8_left_center.jpg":{ "id":"8_left_center.jpg","name":"Basalt Columns","author":"Elad","stockPhoto":"","provider":"visicom"},"1_right_bottom.jpg":{ "id":"1_right_bottom.jpg","name":"Clown fish","author":"Elad","stockPhoto":"","provider":"visicom"},"3_right_center.jpg":{ "id":"3_right_center.jpg","name":"Gibraltar","author":"Elad","stockPhoto":"","provider":"visicom"},"7_right_center.jpg":{ "id":"7_right_center.jpg","name":"Panda","author":"","stockPhoto":"","provider":"visicom"}};

window.imageDescriptions = data;
// this function is in another component, so we need to check if it exists
try {
       createThumbList(data);
   }
   catch(err) {
       //console.log(err);   
}
setBackgroundImages();


function setBackgroundImages()
{
	var index = -1;
	var allItems = $('#thumbs').find('a');
	window.hasBgChanged = false;
	
	// check if bg image is already selected
	var defaultImage = $.cookie("vmn-mystart_y-1_0HomepageBackgroundImage");
	if(defaultImage != null)
	{
		var currentItem = $('#thumbs').find("a[href='"+defaultImage+"']");
		index = allItems.index(currentItem);
	}
	else
	{
		// if no image selected, use default for profile, else show random out of the new images
			
	}

	// if preselected image doesn't exist, use random
	if(index < 0)
	{
		currentItem = getRandomImage();
		index = allItems.index(currentItem);
	}

	$(function() {	
		// Options for SuperBGImage
		$.fn.superbgimage.options = {
			id: 'superbgimage', // id for the containter
			z_index: 0, // z-index for the container
			inlineMode: 0, // 0-resize to browser size, 1-do not resize to browser-size
			showimage: index + 1, // number of first image to display
			vertical_center: 1, // 0-align top, 1-center vertical
			transition: 1, // 0-none, 1-fade, 2-slide down, 3-slide left, 4-slide top, 5-slide right, 6-blind horizontal, 7-blind vertical, 90-slide right/left, 91-slide top/down
			transitionout: 1, // 0-no transition for previous image, 1-transition for previous image
			randomtransition: 0, // 0-none, 1-use random transition (0-7)
			showtitle: 0, // 0-none, 1-show title
			slideshow: 0, // 0-none, 1-autostart slideshow
			slide_interval: 5000, // interval for the slideshow
			randomimage: 0, // 0-none, 1-random image
			speed: 'slow', // animation speed
			preload: 0, // 0-none, 1-preload images
			onShow: superbgimage_show, // function-callback show image
			onClick: superbgimage_click, // function-callback click image
			onHide: superbgimage_hide, // function-callback hide image
			onMouseenter: superbgimage_mouseenter, // function-callback mouseenter
			onMouseleave: superbgimage_mouseleave, // function-callback mouseleave
			onMousemove: superbgimage_mousemove // function-callback mousemove
		};
	
		// initialize SuperBGImage
		$('#thumbs').superbgimage();
	
	});

}

function getRandomImage(){
	var availableForRandom = Array();
	// get those images available for random
	var data = window.imageDescriptions;
	for(var loop in data) {
		if(typeof data[loop].availableForRandom != 'undefined' && data[loop].availableForRandom == true)
		{
			availableForRandom.push(loop);				
		}
	}
	// select one of those
	preSelectedBgIndex = availableForRandom[Math.floor(Math.random()*availableForRandom.length)+1];
	return currentItem = $('#thumbs').find("a[href='./resources/images/large_backgrounds/" + preSelectedBgIndex + "']");
}

// function callback on hiding image
function superbgimage_hide(img) {
	$('#showtitle').hide();
}

// function callback on showing image
// get title and display it
function superbgimage_show(img) {
	// change the no-shadow for shadow background
 	if(img == 1)
 	{
 		$('#arrow_navigation').hide();
 		// add placeholder class noshadow
 		$('.shadow').removeClass('shadow').addClass('noshadow');
 	}
 	else
 	{
 		$('#arrow_navigation').show();
 		$('.noshadow').removeClass('noshadow').addClass('shadow');
 	}

	// store current bg in cookie if bg has been changed
	if (window.hasBgChanged === true)
	{
		$.cookie("vmn-mystart_y-1_0HomepageBackgroundImage", $.fn.getCurrentSlide(), { expires: 365});
	}
	else
		window.hasBgChanged = true;
		
	setBackgroundDescriptions();
}

// function callback on clicking image, show next slide
function superbgimage_click(img) {
}

$('#nextslide').click(function(){
	$('#thumbs').nextSlide();
});

$('#prevslide').click(function(){
	$('#thumbs').prevSlide();
});

// function callback onmouseenter, stop slideshow, show pause-indicator
function superbgimage_mouseenter(img) {

}

// function callback onmouseleave, start slideshow, hide pause-indicator
function superbgimage_mouseleave(img) {

}

// function callback onmousemove, show and move pause-indicator
function superbgimage_mousemove(img, e) {

}

/**
	This is some stuff for the popup
**/
$(function () {
	  $('.bubbleInfo').each(function () {
	    // options
	    var distance = 5;
	    var time = 250;
	    var hideDelay = 500;
	    var opacity = 0.9;
	
	    var hideDelayTimer = null;
	
	    // tracker
	    var beingShown = false;
	    var shown = false;
	    
	    var trigger = $('.trigger', this);
	    var popup = $('.popup', this).css('opacity', 0);
	
	    // set the mouseover and mouseout on both element
	    $([trigger.get(0), popup.get(0)]).mouseover(function () {
	      // stops the hide event if we move from the trigger to the popup element
	      if (hideDelayTimer) clearTimeout(hideDelayTimer);
	
	      // don't trigger the animation again if we're being shown, or already visible
	      if (beingShown || shown) {
	        return;
	      } else {
	        beingShown = true;
	
	        // reset position of popup box
	        popup.css({
	          display: 'block' // brings the popup back in to view
	        })
	
	        // (we're using chaining on the popup) now animate it's opacity and position
	        .animate({
	          bottom: '+=' + distance + 'px',
	          opacity: opacity
	        }, time, 'swing', function() {
	          // once the animation is complete, set the tracker variables
	          beingShown = false;
	          shown = true;
	        });
	      }
	    }).mouseout(function () {
	      // reset the timer if we get fired again - avoids double animations
	      if (hideDelayTimer) clearTimeout(hideDelayTimer);
	      
	      // store the timer so that it can be cleared in the mouseover if required
	      hideDelayTimer = setTimeout(function () {
	        hideDelayTimer = null;
	        popup.animate({
	          bottom: '-=' + distance + 'px',
	          opacity: 0
	        }, time, 'swing', function () {
	          // once the animate is complete, set the tracker variables
	          shown = false;
	          // hide the popup entirely after the effect (opacity alone doesn't do the job)
	          popup.css('display', 'none');
	        });
	      }, hideDelay);
	    });
	  });
});

/*********************************
 -- START ------------
 homepage_app_grid_box_js
*********************************/

/*
 * jQuery doTimeout: Like setTimeout, but better! - v1.0 - 3/3/2010
 * http://benalman.com/projects/jquery-dotimeout-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($){var a={},c="doTimeout",d=Array.prototype.slice;$[c]=function(){return b.apply(window,[0].concat(d.call(arguments)))};$.fn[c]=function(){var f=d.call(arguments),e=b.apply(this,[c+f[0]].concat(f));return typeof f[0]==="number"||typeof f[1]==="number"?this:e};function b(l){var m=this,h,k={},g=l?$.fn:$,n=arguments,i=4,f=n[1],j=n[2],p=n[3];if(typeof f!=="string"){i--;f=l=0;j=n[1];p=n[2]}if(l){h=m.eq(0);h.data(l,k=h.data(l)||{})}else{if(f){k=a[f]||(a[f]={})}}k.id&&clearTimeout(k.id);delete k.id;function e(){if(l){h.removeData(l)}else{if(f){delete a[f]}}}function o(){k.id=setTimeout(function(){k.fn()},j)}if(p){k.fn=function(q){if(typeof p==="string"){p=g[p]}p.apply(m,d.call(n,i))===true&&!q?o():e()};o()}else{if(k.fn){j===undefined?e():k.fn(j===false);return true}else{e()}}}})(jQuery);

_gaq.push(['AGTracking._setAccount', 'UA-17836508-2']);



	// keep it hidden





$('#bannerinfo').bind('show', function(oEvent, iPanel) {
	$(this).show();
	_gaq.push(['AGTracking._trackEvent', 'AppGridBanner', 'clicked']);
	var oBBox = jQuery.colorbox({ 
		inline: true, 
		href: "#bannerinfo", 
		open: true, 
		initialWidth: 10,
		initialHeight: 10,
		width: 900, 
		height: 525,
		opacity: .4
	});
	
	oBBox.bind('cbox_closed', function() {
		oBBox.unbind('cbox_closed');
	});
});

$('.closeBanner').click(function(){
	// set cookie if user closed appgrid banner
	$.cookie("vmn-mystart_y-1_0HomepageAppgridBannerClosed", true, { expires: 30});
	$('#homepage_app_grid_banner').fadeOut(400);
});

$('.openBannerInfo').click(function(){
	$('#bannerinfo').trigger('show');
});

$('#cboxClose').css('background', 'url(/components/homepage_app_grid_box/images/btn-close.png)');

// this value is being set in the HTML-template of this component
if(typeof show_ag != 'undefined' && show_ag == true)
	$('#bannerinfo').trigger('show');

$('.appGridDownloadButton').click(function(e) {
	_gaq.push(['AGTracking._trackEvent', 'AppGridDownloadButton', 'clicked']);
	e.preventDefault();
	window.location.href = 'http://';
});



/*********************************
 -- END --------------
 homepage_app_grid_box_js
*********************************/ }); 
