﻿/// <reference path="./jQuery.intellisense.js" />



/*
Watermarks

This does the watermarking for input boxes, use the watermark class on
labels, watermarkJS is added so you can position the label over the input
*/
$(function(){

    var eleInput;

	$('label.watermark').addClass("watermarkJS");
	$('label.watermark').each(function(index,label){
	    eleInput = $('#'+$(label).attr("for"))[0];
	    
	    if(eleInput.value != "")
	    {
	        $(label).hide();
	    }
	    
	    $(eleInput).blur(function(){
	        eleInput = $('#'+$(label).attr("for"))[0];
	        if(eleInput.value == "")
	        {
	            $(label).show();
	        }
	    });
	    $(eleInput).focus(function(){
	        eleInput = $('#'+$(label).attr("for"))[0];
	        $(label).hide();
	    });
	    
	});
	
});
/*
End Watermarks
*/



jQuery(function($){
	
 
 
 
	
	    $('.LandingGallery ul.galleryslideshow').cycle({
		fx: 'fade',
		speed: 3000,
		timeout: 7000,
		random: 1,
		height: 130
	});
 
 
 $('.PageLeft ul.galleryslideshow').cycle({
		fx: 'fade',
		speed: 3000,
		timeout: 7000,
		random: 1,
		height: 250
	});
 

	
	$('.VenueHeader ul.galleryslideshow').cycle({
		fx: 'fade',
		speed: 3000,
		timeout: 7000,
		random: 1,
		height: 300
	});
	
	$('.LeftColMain .SubLeftGallery ul.galleryslideshow').cycle({
		fx: 'fade',
		speed: 3000,
		timeout: 7000,
		random: 1,
		height: 350
	});
	
	
	$('.page-about_history .LeftColMain .SubLeftGallery ul.galleryslideshow').cycle({
		fx: 'fade',
		speed: 3000,
		timeout: 7000,
		height: 350
	});
	
	
	
	
	/*
    $('#Features').cycle({
		fx: 'scrollHorz',
		next:   '#Featurenavnext',
		prev:   '#Featurenavprev',
		timeout: 10000 
	});
	*/
	function rgbToHex(rgb) {
		var parts = rgb
				.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/)
		;
		// parts now should be ["rgb(0, 70, 255", "0", "70", "255"]
		delete (parts[0]);
		for (var i = 1; i <= 3; ++i) {
			parts[i] = parseInt(parts[i]).toString(16);
			if (parts[i].length == 1) parts[i] = '0' + parts[i];
		}
		return parts.join('');
	} 
	
	function MakeDeity(i,e){
		ele = $(e);
		col = ele.css('color');
		if(col.substring(0,1)=="#")
			col = col.substring(1,7);
		else
			col = rgbToHex(col);
		
		text = ele.css("text-transform")=="uppercase" ? ele.text().toUpperCase() : ele.text() ; 

		img = '/imgsizer.aspx?action=text&text='+escape(text)+'&font=deity&size='+(parseInt(ele.css('font-size'))+2)+'&colour='+col;
		
		if($.browser.msie && $.browser.version < 7)
            e.innerHTML = '<div><img alt="'+text.replace("\"",/&quote;/g)+'" class="textreplaced" src="'+img+'" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+img+'\', sizingMethod=\'image\'); padding-top: 200px;" /></div>';
        else
            e.innerHTML = '<img alt="'+text.replace("\"",/&quote;/g)+'" class="textreplaced" src="'+img+'" />';
    
    
		//ele.addClass("replacement");
		//ele.css("background-image","url("+img+")");
	}
	
	//$('.Deity').each(MakeDeity);
	//$('.currentpage-home .featureLink h3').each(MakeDeity);

	/* embedded audio */
		$("a[rel='audioembed']").each(function(i,e){
		
		var fileinfo = e.href.substring((location.protocol+"//"+location.host).length).split("#");
		var flashvars = {
			file:fileinfo[0],
			length:fileinfo[1]
		};
		var params = {};
		
		var attributes = {};
		e.id = "audioembedder_"+i;
		
		swfobject.embedSWF("/templates/default/player2.swf", "audioembedder_"+i, $(e).parent().width(), "50", "9.0.0","expressInstall.swf", flashvars, params, attributes);
				
		});
	/* end embedded audio */
	
	/*
	404 - auto guess search query
	*/
	if(location.pathname=="/404.aspx")
	{
		try
		{
			unfound = unescape(location.search.replace("?url=",""));
			urlParts = unfound.split("/");
			if(urlParts.length > 1)
			{
				lastPart = urlParts[urlParts.length-1].replace(".aspx","");
				if(urlParts.length > 2 && lastPart == ""+parseInt(lastPart))
				{
					lastPart = urlParts[urlParts.length-3].replace(/_/g," ");
				}
				else
				{
					lastPart = lastPart.replace(/(\w)([A-Z])/g,"$1 $2");
				}
				
				$('#sectionId_1074 .textbox').val(lastPart);
			}
		}
		catch(ex){}
	}
		
});



$(function() {
	/* duplicating paging controls on about/news.aspx */
    $(".currentpage-about_news #sectionId_403 .pager").clone().prependTo("#sectionId_403 .moduleInnerContent");
	
	/*$("#sectionId_1069 fieldset div.textboxRow:eq(0)").before($("div.sec01"));*/
	$("#sectionId_1069 fieldset div.memoRow:eq(0)").before($("div.sec02"));
	$("#sectionId_1069 fieldset div.textboxRow:eq(9)").before($("div.sec03"));
	$("#sectionId_1069 fieldset div.textboxRow:eq(12)").before($("div.sec04"));
	$("#sectionId_1069 fieldset div.textboxRow:eq(15)").after($("div.sec05"));
	$("#sectionId_1069 fieldset div.radiobuttonsRow:eq(0)").before($("div.sec06"));
	$("#sectionId_1069 fieldset div.checkboxesRow:eq(0)").before($("div.sec07"));
	$("#sectionId_1069 fieldset div.checkboxRow:eq(0)").before($("div.sec08"));
	$("#sectionId_1069 fieldset div.memoRow:eq(2)").before($("div.sec09"));
	$("#sectionId_1069 fieldset div.memoRow:eq(2)").after($("div.sec10"));
	
});

