
// IPS Ceramics website script


	if (top.location != location) {
		top.location.href = document.location.href ;
	}



	// Font replacement
		Cufon.replace('#DITOP h1', {
			fontFamily: 'Elementary SF',
			color: '-linear-gradient(#E4E4E4,#C5C5C5)',
			textShadow: '#333 0px 1px'
		});
		Cufon.replace('#DITOP p', {
			fontFamily: 'Elementary SF'
		});

		Cufon.replace('div#boxes h2', {
			fontFamily: 'Elementary SF'
		});
		
		Cufon.replace('#centralContent .grid_6 h1, #centralContent .grid_9 h1', {
			fontFamily: 'Elementary SF'
		});
		
		Cufon.replace('#centralContent .grid_6 h2, #centralContent .grid_9 h2', {
			fontFamily: 'Elementary SF'
		});

		Cufon.replace('#centralContent .grid_6 h3, #centralContent .grid_9 h3', {
			fontFamily: 'Elementary SF'
		});
		
		Cufon.replace('#SLTOP .pageNav DIV A', {
			fontFamily: 'Elementary SF'
		});
		

		Cufon.replace('#footer H3', {
			fontFamily: 'Elementary SF'
		});

		Cufon.replace('div#share_article h3, .article_cell h2', {
			fontFamily: 'Elementary SF',
			color: '-linear-gradient(#E4E4E4,#C5C5C5)',
			textShadow: '#333 0px 1px'
		});
		Cufon.replace('.columns h1', {
			fontFamily: 'Elementary SF',
			color: '-linear-gradient(#ffffff,#E4E4E4,#C5C5C5)',
			textShadow: '#333 0px 1px'
		});




	// Define the magic line function generically...
	(function($){
		jQuery.fn.magicLine= function(options) {

			return this.each(function()
			{
				var settings = jQuery.extend({},jQuery.fn.magicLine.defaults, options);
				var $el, leftPos, newWidth, containerWidth,
					navContainer,$mainNav;
				
				/* ---- Get the id of the object to add this slider to
				*/
				navContainer="#"+$(this).attr('id');
				$mainNav=$(navContainer);
				
				
				/* ---- Initialisation
				*/
				$mainNav.append("<li class='magic-line'></li>");
				var $magicLine = $(navContainer+" .magic-line");
				
				
				
				/* ---- Store current selected item position
				*/
				mywidth=$(navContainer+" .thisPage").width();
				mywidthVal=parseInt(mywidth);
				myheight=$(navContainer+" .thisPage").height();
				myheightVal=parseInt(myheight);
				
				
				// If no element has .thisPage class then don't add magic line...
				if ($(navContainer+" .thisPage a").html()!=null)
				{
					/* ---- Underline the current item
					*/
					$magicLine
						.css("width",mywidthVal)
						.css("left", $(navContainer+" .thisPage a").position().left)
						;
					$magicLine
						.data("origLeft", $magicLine.position().left)
						.data("origWidth", $magicLine.width());
						
					containerWidth=$mainNav.width();
					
					
					/* ----- Add the event to move and reset the line on hover...
					*/
					$(navContainer+" li a").hover(function() {
							$el = $(this);
							leftPos = $el.position().left;
							newWidth = $el.parent().width();
							$magicLine.stop().animate({
									left: leftPos,
									width: newWidth
								});
							if (typeof settings['hoverOverCall']== 'function') { // make sure the callback is a function 
									settings['hoverOverCall'].call(this); // brings the scope to the callback
							}
						}, function() {
								if (settings['hoverReturn'])
								{
									$magicLine.stop().animate({
											left: $magicLine.data("origLeft"),
											width: $magicLine.data("origWidth")
										});
								}
								if (typeof settings['hoverOutCall']== 'function') { // make sure the callback is a function 
										settings['hoverOutCall'].call(this); // brings the scope to the callback 
								}
						});
				}
				
			})
		}

		/*	--------- Defaults for Magic Line
		*/
		jQuery.fn.magicLine.defaults = {
					 hoverReturn: true,
					 hoverOverCall:function(){},
					 hoverOutCall: function(){}
			};
	})(jQuery);




	$(document).ready(function() {

		// Add magic line to menus 
		$('#siteNav .thisPage a').css({background:'url(images/nav_blob_background.png) 50% 0 no-repeat'});
		
		$('#siteNav').magicLine();



		function closeImg() {
			$("#fulldiv").fadeTo(100,0,function(){
				$("#fulldiv").empty();
				$("#fulldiv").remove();
				$("#greyout").fadeTo(400,0,function(){
					$(this).remove();
					});
				});
		}
		
		$("a[href*=.jpg]").click(function(e) {
					
			var fullpath = $(this).attr("href");
			var linktitle = $(this).attr('title');
			var y = $(window).scrollTop()+100;
					
			$("<div>").attr("id", "greyout").appendTo("body").css({opacity:0}).height($("body").height()).fadeTo(400,0.8,function(){
				$("<div>").attr("id", "fulldivOutter").appendTo("body");
				$("<div>").attr("id", "fulldiv").appendTo("#fulldivOutter").css({'top':y});
				$("<h1>").text(linktitle).appendTo("#fulldiv");
				$("<img>").attr("src", fullpath).attr("id", "fullimg").appendTo("#fulldiv");
				$("img#fullimg").bind("click",closeImg);
				$("<div>").attr("id", "closediv").appendTo("#fulldiv");
				$("<button>Close</button>").attr("id", "close").appendTo("#closediv").bind("click", closeImg);
				Cufon.replace('#fulldiv h1', {
					fontFamily: 'Elementary SF'
				});
			});
			return false;

		});



	});
	
	

