var ie = document.all;
var nn6 = document.getElementById &&! document.all;
var isdrag = false;
var x, y;
var dobj;
var oldLeftCategoryLink;
var oldLeftCategoryDiv;
var oldLeftSubCategoryLink;;
function leftCategoryLinkClick(CategoryID, ActiveClass) {
leftCategoryLink = $('categoryLink' + CategoryID);
leftCategoryDiv = $('categoryDiv' + CategoryID);
Effect.toggle(leftCategoryDiv, 'blind', { duration: 0.2 });
if (oldLeftCategoryDiv) {
Effect.toggle(oldLeftCategoryDiv, 'blind', { duration: 0.2 });
oldLeftCategoryLink.className = 'leftCategoryLink';
}
oldLeftCategoryDiv = leftCategoryDiv;
if (oldLeftCategoryLink != leftCategoryLink) {
if (oldLeftSubCategoryLink)
oldLeftSubCategoryLink.className = 'leftSubCategoryLink';
oldLeftSubCategoryLink = null;
}
leftCategoryLink.className = 'leftCategoryLink leftCategoryLink' + ActiveClass;
oldLeftCategoryLink = leftCategoryLink;
}
function leftSubCategoryLinkClick(SubCategoryID, CategoryID, Department, ActiveClass) {
leftCategoryLink = $('categoryLink' + CategoryID);
leftSubCategoryLink = $('subCategoryLink' + SubCategoryID);
new Ajax.Updater('productsList', 'mainProductsList.php?SubCategoryID=' + SubCategoryID + '&department='+ Department + '&random=' + Math.random(), {evalScripts:true, onComplete: function() {initialiseMenu();}});
if (oldLeftSubCategoryLink)
oldLeftSubCategoryLink.className = 'leftSubCategoryLink';
oldLeftSubCategoryLink = $(leftSubCategoryLink);
if (oldLeftCategoryLink != leftCategoryLink) {
if (oldLeftCategoryLink)
oldLeftCategoryLink.className = 'leftCategoryLink';
leftCategoryLink.className = 'leftCategoryLink leftCategoryLink' + ActiveClass;
oldLeftCategoryLink = leftCategoryLink;
}
leftSubCategoryLink.className = 'leftSubCategoryLink leftSubCategoryLink' + ActiveClass;
}
function fixLeftSubCategoryLinks(leftSubCategoryLink) {
a = $('sideMenu').getElementsByClassName('leftMenu');
for(var i = 0; i < a.length; i++) {
a[i].className = 'leftSubCategoryLink';
}
leftSubCategoryLink.className = 'leftSubCategoryLink';
$('searchBox').value = '';
}
function mainSection(page){
new Ajax.Updater('mainSection', page);
}
function toggleMenu(e, department) {
previousStyle = $(e).style.display;
for(var i = 0; i < $('sideMenu').childNodes.length; i++) {
if ($('sideMenu').childNodes.item(i).nodeName == 'DIV') {
$('sideMenu').childNodes.item(i).style.display = 'none';
}
}
for(var i = 0; i < $('sideMenu').childNodes.length; i++) {
if ($('sideMenu').childNodes.item(i).nodeName == 'A') {
$('sideMenu').childNodes.item(i).className = 'down';
}
}
if (previousStyle == 'none')
$(e).style.display = 'block';
else {
new Ajax.Updater('productsList', 'mainProductsList.php?department=' + department, {evalScripts:true, onComplete: function() {initialiseMenu();}});
new Effect.Morph('productsList', {style:'height:312px', duration:0.0});
new Effect.Morph('productsMenu', {style:'height:312px', duration:0.3});
new Effect.Morph('mainSection', {style:'height:314px', duration:0.3});
$(e).style.display = 'none';
}
}
function toggleClass(c) {
return (c == 'up') ? 'down' : 'up';
}
function initialise() {
initialiseMenu();
new Draggable('popup', {handle:'popupBanner', ghosting:false, revert:true, starteffect: function () {}, endeffect: function () {}});
}
// Popup Functions -------------------------------------------------------------------------------------------------------
function relocatePopup(popup) {
var scrolledX, scrolledY;
if (self.pageYOffset) {
scrolledX = self.pageXOffset;
scrolledY = self.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop) {
scrolledX = document.documentElement.scrollLeft;
scrolledY = document.documentElement.scrollTop;
} else if (document.body) {
scrolledX = document.body.scrollLeft;
scrolledY = document.body.scrollTop;
}
var centerX, centerY;
if (self.innerHeight) {
centerX = self.innerWidth;
centerY = self.innerHeight;
} else if(document.documentElement && document.documentElement.clientHeight) {
centerX = document.documentElement.clientWidth;
centerY = document.documentElement.clientHeight;
} else if(document.body) {
centerX = document.body.clientWidth;
centerY = document.body.clientHeight;
}
var leftOffset = scrolledX + (centerX - 700) / 2;
var topOffset = scrolledY + (centerY - 500) / 2;
$(popup).style.top = topOffset + 'px';
$(popup).style.left = leftOffset + 'px';
if (typeof window.innerWidth != 'undefined') {
viewportheight = window.innerHeight;
} else {
viewportheight = document.documentElement.clientHeight;
}
if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
blanket_height = viewportheight;
} else {
if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
blanket_height = document.body.parentNode.clientHeight;
} else {
blanket_height = document.body.parentNode.scrollHeight;
}
}
var blanket = document.getElementById('blanket');
blanket.style.height = blanket_height + 'px';
}
function showPopup(show) {
if (show) {
relocatePopup('popup');
if ($('popup').style.display != 'block')
Effect.Appear('blanket', {from:0.0, to: 0.6, beforeFinish: function() {
$('popup').style.display = 'block';
Effect.BlindDown('popupOuterBody', {fps: 50,duration: 0.4, transition: Effect.Transitions.sinoidal});
},
duration: 0.0
} );
} else {
Effect.BlindUp('popupOuterBody', {beforeFinish: function() {
$('popup').style.display = 'none';
Effect.Fade('blanket', {fps: 50,from:0.6, to: 0.0, duration:0.4});
},
duration: 0.3,
transition: Effect.Transitions.sinoidal
});
}
}
function closePopup() {
showPopup(false);
}
function Popup(url, show) {
$('popupBody').innerHTML = '';
if (show)
new Ajax.Updater('popupBody', url, {evalScripts:true, onComplete: new function() {showPopup(true);}});
else
new Ajax.Updater('popupBody', url, {evalScripts:true});
}
// Popup Functions -------------------------------------------------------------------------------------------------------
function postForm(url, form) {
Popup(url + '?' + Form.serialize(form), true);
}
function showProduct(productID) {
Popup('productView.php?productID=' + productID, true);
}
function showCart(random) {
Popup('cartView.php?random='+random, true);
}
function validateForm() {
errorMsg = '';
valid = true;
if ($('Name').value == '') {
errorMsg += 'Please enter a Name\n';
valid = false;
}
var regEmail = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
if (!regEmail.test($('Email').value)) {
errorMsg += 'Please enter a valid Email Address\n';
valid = false;
}
if ($('Company').value == '') {
errorMsg += 'Please enter a Company\n';
valid = false;
}
if ($('Phone').value == '') {
errorMsg += 'Please enter a Phone number\n';
valid = false;
}
return errorMsg;
}
function formChange(showStop) {
if (validateForm() == '') {
$('buttonStopSign').src = 'images/buttonPost.jpg';
return true;
} else {
if (showStop)
$('buttonStopSign').src = 'images/buttonStopSign.jpg';
return false;
}
}
// Enquiry Functions -------------------------------------------------------------------------------------------------------
function showEnquiry(random) {
Popup('enquiryDetails.php?random='+random, true);
}
function submitEnquiry() {
msg = validateForm();
if (msg == '') {
postForm('enquirySubmit.php', 'enquiryForm');
// $('popupBody').innerHTML = 'Sending Mail...';
} else
alert(msg);
}
// Enquiry Functions -------------------------------------------------------------------------------------------------------
// Contact Functions -------------------------------------------------------------------------------------------------------
function showContact(random) {
Popup('contactDetails.php?random='+random, true);
}
function submitContact() {
msg = validateForm();
if (msg == '') {
postForm('contactSubmit.php', 'contactForm');
// $('popupBody').innerHTML = 'Sending Mail...';
} else
alert(msg);
}
// Contact Functions -------------------------------------------------------------------------------------------------------
// Wardrobe Functions -------------------------------------------------------------------------------------------------------
function showWardrobe(random) {
Popup('wardrobeDetails.php?random='+random, true);
}
function submitWardrobe() {
msg = validateForm();
if (msg == '')
postForm('wardrobeSubmit.php', 'wardrobeForm');
else
alert(msg);
}
// Wardrobe Functions -------------------------------------------------------------------------------------------------------
// Join Functions -------------------------------------------------------------------------------------------------------
function showJoin(random) {
Popup('joinDetails.php?random='+random, true);
}
function submitJoin() {
msg = validateForm();
if (msg == '')
postForm('joinSubmit.php', 'joinForm');
else
alert(msg);
}
// Join Functions -------------------------------------------------------------------------------------------------------
// Enquiry Functions -------------------------------------------------------------------------------------------------------
function submitEnquiry() {
msg = validateForm();
if (msg == '')
postForm('cartEnquirySubmit.php', 'enquiryForm');
else
alert(msg);
}
// Enquiry Functions -------------------------------------------------------------------------------------------------------
// Search Functions -------------------------------------------------------------------------------------------------------
function searchProducts(random){
if (trim($('searchBox').value) != '') {
saySearching();
new Ajax.Updater('mainSection', 'mainProducts.php?search=' + $('searchBox').value, {evalScripts:true, onComplete: function() {initialiseMenu(); finishedSearching();}});
}
}
function saySearching() {
$('searchBoxContainer').innerHTML = '
';
}
function finishedSearching() {
random = Math.random();
$('searchBoxContainer').innerHTML = '
';
$('searchBox').value = '';
}
// Search Functions -------------------------------------------------------------------------------------------------------
// Utility Functions -------------------------------------------------------------------------------------------------------
function keyPressHandler(oEvent) {
var oEvent = (oEvent) ? oEvent : event;
var oTarget = (oEvent.target) ? oEvent.target : oEvent.srcElement;
if ((oTarget.type == "text" || oTarget.type == "select-one" || oTarget.type == "password") && oEvent.keyCode == 13)
if (oTarget.id != 'searchBox')
oEvent.keyCode = 9;
else
searchProducts(0);
var Esc = (window.event) ? 27 : oEvent.DOM_VK_ESCAPE // MSIE : Firefox
if (oEvent.keyCode == Esc)
showPopup(false);
}
function trim(sString) {
while (sString.substring(0, 1) == ' ') {
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length - 1, sString.length) == ' ') {
sString = sString.substring(0, sString.length - 1);
}
return sString;
}
// Utility Functions -------------------------------------------------------------------------------------------------------
document.onkeydown = keyPressHandler;