$('html').addClass('json');

  function TitleCase(objField) 
        {
            var objValues = objField.split(" ");
            var outText = "";
            for (var i = 0; i < objValues.length; i++) {
                outText = outText + objValues[i].substr(0, 1).toUpperCase() + objValues[i].substr(1).toLowerCase() + ((i < objValues.length - 1) ? " " : "");
            }
            return outText;
        }
		
var citrusCMS = {
		
	load : function() {
		citrusCMS.coreFunctions();
	},
	
		coreFunctions : function(){
		
		$('.openWindow').click(function() {window.open(this.href); return false});
		$('.printWindow').click(function() {window.print()});
	
		$('.textform').focus(function() {
			if(this.nodeName != 'SELECT'){
				$('#' + this.id).attr('class', 'textformfocus');
				$('.textform').each(function(){if ($(this).attr('value')=='' && $(this).attr('id')!='file_address'){$(this).attr('value',TitleCase($(this).attr('id').replace(/_/gi,' ')+'...'));} });
				if (this.value.substr(this.value.length-3,3) == '...') {this.value=''; }
						}
			});
		$('.textform').blur(function(){$('#' + this.id).attr('class', 'textform');});
		
		$('#thumbs').galleriffic();
		
		// ANIMATE DROP DOWN NAVIGATION
		$('#mainnav li ul').hide();
		$('#mainnav li').hover(function(){	
				$('ul', this).stop(true, true).slideDown(200);
			},
			function(){	
				$('ul', this).stop(true, true).hide();
		});
		
		
	},
	
	GoogleMap : function(){
						
			var showmap = new google.maps.LatLng(51.5150978,-0.1360886);
			  var mapOptions = {
				center: showmap,
				zoom: 15,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			  };
			  
			  var map = new google.maps.Map(document.getElementById('googlemap'), mapOptions);
			  
			  var infowindow = new google.maps.InfoWindow(
				{ content: '<p style="width: 260px; height: 90px;"><strong>Lumina</strong><br />The Cobalt Building<br />19-20 Noel Street<br />London<br />W1F 8GW</p>',
					size: new google.maps.Size(50,50),
					position: showmap
				});


			  infowindow.open(map);

				}
				
	
}

function slideSwitch() {
    var $active = $('#imgslideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#imgslideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#imgslideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {setInterval( "slideSwitch()", 5000 );});

function slideSwitch2() {
    var $active = $('#quoteslideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#quoteslideshow DIV:last');

    var $next =  $active.next().length ? $active.next()
        : $('#quoteslideshow DIV:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {setInterval( "slideSwitch2()", 5000 );});


$(document).ready(citrusCMS.load);
