/* 
////////////////////////////////////////
//// DEFAULT PAGE JQUERY FUNCTIONS ////
//////////////////////////////////////
*/

/* 

We run a few Jquery functions on this site, and on each page
is one of these nifty files which will hold the jquery call functions / events.

Default.Js
1. Add a explode function to the main logo onmouseover
2. Add listeners to the show / hide divs for the News Stories.
3. 

*/


$(document).ready(function(){

/* We use Jquery to hide the main info boxes because if people dont have javascript enabled
 * they still need to be able to see the info etc they just dont have the option of closing it.
 * particulary helpful for things like google bot because the info isnt hidden from bots :)
 */

$("#mainHeader2BODY").hide();
$("#mainHeader3BODY").hide();
document.getElementById('prodcatcurrentlyon').value = "PCBottleCoolers";


//* Add a role over function on the main logo which runs the effect (explode)
//$("#headerLogoImg").mouseover(function() {
//runEffect("explode");
//return false;
//});

/* These are the listeners to show and hide the news section. Functions Below */
$('#mainHeader1Hide').click(function() { hidemainHeader1()  });
$('#mainHeader1Show').click(function() { showmainHeader1()  });
$('#mainHeader2Hide').click(function() { hidemainHeader2()  });
$('#mainHeader2Show').click(function() { showmainHeader2()  });
$('#mainHeader3Hide').click(function() { hidemainHeader3()  });
$('#mainHeader3Show').click(function() { showmainHeader3()  });




/* These are the click listeners that will swap the main image background pic */
$('#mainimgoptionholder1').click(function() { changemainimg1() });
$('#mainimgoptionholder2').click(function() { changemainimg2() });
$('#mainimgoptionholder3').click(function() { changemainimg3() });
$('#mainimgoptionholder4').click(function() { changemainimg4() });
$('#maindivlink').click(function() { redirecttheuser() });


/* Logins Are Disabled. Notify */
$('#submitdiv').click(function() { iserror()  });
$('#cleardiv').click(function() {  clearerror()  });


/* Adds cursor pointer and changes color of the links in the product cat and services menu */
$('#prodlinkoutline div').hover(function() {
$(this).addClass('pointer-hover');
$(this).addClass('SSLBlue');
}, function() {
$(this).removeClass('pretty-hover');
$(this).removeClass('SSLBlue');
});


/* Changes color of the links for show/hide of menus */
$('span.menushowhide').hover(function() {
$(this).addClass('SSDBlue');
}, function() {
$(this).removeClass('SSDBlue');
});



/* LEFT NAV MENU */
/* LEFT NAV MENU */
/* LEFT NAV MENU */
$('.fadeThis').append('<span class="hover"></span>').each(function () {
  var $span = $('> span.hover', this).css('opacity', 0);
  $(this).hover(function () {
    $span.stop().fadeTo(500, 1);
  }, function () {
    $span.stop().fadeTo(500, 0);
  });
});



}); //* END DOCUMENT READY FUNCTION - ALL BELOW IS CUSTOM FUNCTIONS TO BE CALLED



//* This will run the effect on the header img.
function runEffect(passedeffect){
var options = {};
$("#headerLogoImg").effect(passedeffect,options,500,callback);
};



//* removes the effect on the header img
function callback(){
	setTimeout(function(){
		$("#headerLogoImg:hidden").removeAttr('style').hide().fadeIn('fast');
	}, 50);
};




function hidemainHeader1() {
$("#mainHeader1BODY").hide("slide", {direction: "up"}, 400);
$("#mainHeader1Hide").hide();
$("#mainHeader1Show").show();
}

function showmainHeader1() {
$("#mainHeader1BODY").show("slide", {direction: "up"}, 400);
$("#mainHeader1Hide").show();
$("#mainHeader1Show").hide();
}



function hidemainHeader2() {
$("#mainHeader2BODY").hide("slide", {direction: "up"}, 500);
$("#mainHeader2Hide").hide();
$("#mainHeader2Show").show();
}

function showmainHeader2() {
$("#mainHeader2BODY").show("slide", {direction: "up"}, 500);
$("#mainHeader2Hide").show();
$("#mainHeader2Show").hide();
}



function hidemainHeader3() {
$("#mainHeader3BODY").hide("slide", {direction: "up"}, 400);
$("#mainHeader3Hide").hide();
$("#mainHeader3Show").show();
}

function showmainHeader3() {
$("#mainHeader3BODY").show("slide", {direction: "up"}, 400);
$("#mainHeader3Hide").show();
$("#mainHeader3Show").hide();
}









function iserror() {
/* If someone tries to login then just show an error.
 * Will add error checking etc when we build backend
 */
$("#loginError").html("Error 21: Disabled").css("text-align","center").css("color","red");
$("#loginError").show();
}


function clearerror() {
$("#loginError").hide();
document.getElementById('loginEmail').value = "";
document.getElementById('loginPassword').value = "";
}




function changemainimg1() {
$('#mainimgholder').css({'background-image':"url('images/Banner_water_01.jpg')"});
}

function changemainimg2() {
$('#mainimgholder').css({'background-image':"url('images/Banner_products_01.jpg')"});
}

function changemainimg3() {
$('#mainimgholder').css({'background-image':"url('images/Banner_health_01.jpg')"});
}

function changemainimg4() {
$('#mainimgholder').css({'background-image':"url('images/Banner_promo_01.jpg')"});
}

function redirecttheuser() {
alert('redirect');
}





function ShowProdCatSt1(thedivtoshow) {
var currentyon = document.getElementById('prodcatcurrentlyon').value;
//$("#" + currentyon).hide("drop", 300, ShowProdCatSt2(thedivtoshow));
$("#" + currentyon).hide();
ShowProdCatSt2(thedivtoshow);
}


function ShowProdCatSt2(thedivtoshow2) {
setTimeout(function(){
//$("#" + thedivtoshow2).show("drop", {direction: "right"},  400);
$("#" + thedivtoshow2).show();

document.getElementById('prodcatcurrentlyon').value = thedivtoshow2;
}, 100);
}





$(document).ready(function(){
	$(".fade_img").fadeTo("slow", 0.6);
	$(".fade_img").hover(function(){
	$(this).fadeTo("slow", 1.0);
	},function(){
	$(this).fadeTo("slow", 0.6);
	});
	});


$(document).ready(function(){
	$("#text p").fadeTo("slow", 0.7);
	$("#text p").hover(function(){
	$(this).fadeTo("slow", 1.0);
	},function(){
	$(this).fadeTo("slow", 0.7);
	});
	});


$(document).ready(function(){
	$("#div").fadeTo("slow", 0.7);
	$("#div").hover(function(){
	$(this).fadeTo("slow", 1.0);
	},function(){
	$(this).fadeTo("slow", 0.7);
	});
	});




function ismouseover(imageid) {
alert(imageid);
};


