//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
function HIN () {}

HIN.prototype.init = function ()
{
	this.KnowlegeModule = new KnowlegeModule();
	this.MapsModule = new MapsModule();
	this.HomePage = new HomePage();
}


//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function KnowlegeModule()
{
	this.init();
}

KnowlegeModule.prototype.init = function()
{
		this.getLinks();
		
}

KnowlegeModule.prototype.loader = function(remove)
{
	var loader = $('#loader');
	var height = $('#content').height();
	
	if(remove == 'remove'){
		loader.addClass('hidden')
			  .removeAttr('style');
		  
	}else{
		loader.removeClass('hidden')
			  .height(height);
			  
	}
	
}

KnowlegeModule.prototype.getLinks = function()
{
	$('.multiContentNav a').bind('click', function() {
		var relContent = $(this).attr('rel');
		KnowlegeModule.prototype.loadContent(relContent);
	});
}

KnowlegeModule.prototype.loadContent = function(contentParam)
{
	var contentKey = contentParam;
	
	KnowlegeModule.prototype.loader();

	
	$.ajax({
	   type: "POST",
	   url: "/get/info.php?page=" + contentKey,
	   dataType: 'html',
	   success:function(html) {
	   		$('#contentArea').html(html);
	   		KnowlegeModule.prototype.loader('remove');
	   }
	 });
						
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function MapsModule() 
{
	this.init();
}



MapsModule.prototype.init = function()
{
	this.showPopUp();
	this.popUplinks();
}


MapsModule.prototype.showPopUp = function()
{
	$('#HINMap .marker').bind('mouseover', function(){
		$('#HINMap .popUps:visible').addClass('hidden');
		$(this).next('div').removeClass('hidden');
	});
	
}

MapsModule.prototype.popUplinks = function()
{
	$('#HINMapLinks li').bind('click', function(){
		var popUpLink = $(this).find('a').attr('rel');
		$('#HINMap .popUps:visible').addClass('hidden');
		$('#HINMap .' + popUpLink).next('div').removeClass('hidden');
	})
}


//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------


function HomePage()
{
	this.init();
}

HomePage.prototype.init = function() 
{
	//this.randContent();
	this.overlay();
	$('#HINHomeTeaser .line').eq(0).show();
	setInterval(this.redirect, 3000);
	setInterval(this.randContent, 3000);

}


HomePage.prototype.randContent = function() 
{
	var currentDiv = $('#HINHomeTeaser .line:visible');
	
	var	nextDiv = currentDiv.next();
	
	if(nextDiv.length == 0){
		nextDiv = $('#HINHomeTeaser .line').eq(0);
	}	
	
	currentDiv.hide();
	nextDiv.fadeIn("slow");
		
}

HomePage.prototype.overlay = function() {
		$('body a').attr('href','javascript:void(0);');
		
		var page = $('.page').addClass('overlay');

		var width = $(document).width();
		var width = (width - (289))/2
		var overlay = $('<div class="notice">').css('left',width);
		var text = $('<p>').text('You will be redirected in a few seconds to the new Heavy Industries site, \n\r\r Industry Source Networks');
		
		overlay.append(text);
		
		$('body').prepend(overlay);
		overlay.slideDown('slow');
}

HomePage.prototype.redirect = function() {
	window.location.href = 'http://shop.industrysourcenetworks.com/'
	
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------


new HIN().init();
