/*
JS for WIP http://www.wip.com.my

By: Mohd Farhan bin Nor

Integricity Corporation Sdn Bhd
mohd.farhan@integricity.com

- need jquery to run

*/

var wipMessageTimeout;

function initRoundNavi() {
	jQuery(window).ready(function () {	 

		jQuery(".wipNavi ul li").append('<span class="wipNaviViolet">&nbsp;<\/span>');

		jQuery(".wipNavi ul li")
		.mouseover(function() {
			jQuery("#" + jQuery(this).attr("id")+" .wipNaviViolet").fadeIn("normal");
		})
		.mouseout(function() {
			jQuery("#" + jQuery(this).attr("id")+" .wipNaviViolet").fadeOut("fast");
		})	

	});
}

function wipSwitchTab(tabID, contentID) {
	closeWipMessageBox();
	jQuery(".wipPageNavi .wipNaviButton").removeClass('wipInsideNaviActive').addClass('wipInsideNaviDeactive');
	jQuery(""+tabID+"").removeClass('wipInsideNaviDeactive').addClass('wipInsideNaviActive');
	wipShowContent(contentID);
	return false;

}

function  wipShowContent(contentID) {
	jQuery(".wipInsideContent").css("display","none"); 
	jQuery(""+contentID+"").fadeIn("normal");
}

function wipSwitchHeader(headerID, contentID) {
	jQuery(".wipContent h2 a").removeClass('wipActive');
	jQuery(""+headerID+"").addClass('wipActive');
	wipShowContentExt(contentID);
	return false;
}

function  wipShowContentExt(contentID) {
	jQuery(".wipListWrapper").css("display","none"); 
	jQuery(""+contentID+"").fadeIn("normal");
}

function processContactForm() {
	clearTimeout(wipMessageTimeout);
	var wipName = document.getElementById('name').value;
	var wipPhone = document.getElementById('phone').value;
	var wipEmail = document.getElementById('email').value;
	var wipComment = document.getElementById('comments').value;
	jQuery("#wipMessageBox").load("processForm.php",{formType : 'contact', theName : wipName, phone: wipPhone, email : wipEmail, comments: wipComment}, function() {
		if(jQuery("#wipMessageBox").html()!="succeed") {
			displayWipMessageBox();
		}
		else {
			jQuery("#wipMessageBox").html("Thank you for your comments. We will get in touch with you soon.");
			displayWipMessageBox();
		}
	});


}

function processReserveForm() {
	clearTimeout(wipMessageTimeout);
	var wipSalutation = document.getElementById('salutation').value;
	var wipName = document.getElementById('reservename').value;
	var wipPhone = document.getElementById('reservephone').value;
	var wipEmail = document.getElementById('reserveemail').value;
	var wipDate = document.getElementById('reservedate').value;
	var wipTime = document.getElementById('reservetime').value;
	var wipPax = document.getElementById('reservepax').value;
	var wipLocation = document.getElementById('reservelocation').value;
	jQuery("#wipMessageBox").load("processForm.php",{formType : 'reserve', salutation: wipSalutation, theName : wipName, phone: wipPhone, email : wipEmail, date: wipDate, time: wipTime, pax: wipPax, thelocation: wipLocation}, function() {
		if(jQuery("#wipMessageBox").html()!="succeed") {
			displayWipMessageBox();
		}
		else {
			jQuery("#wipMessageBox").html("Thank you for reserving with us. Our staff will contact you soon.");
			displayWipMessageBox();
		}
	});
}

function displayWipMessageBox() {
	jQuery("#wipMessageBox").prepend("<div class='wipMessageClose'><a onclick='closeWipMessageBox()'> <\/a><\/div>");
	jQuery("#wipMessageBox").fadeIn("normal");
	//wipMessageTimeout = setTimeout("closeWipMessageBox()", 5000);
}

function closeWipMessageBox() {
	jQuery("#wipMessageBox").fadeOut("normal", function() {
		jQuery("#wipMessageBox").html("");
	});
}