// Start add-ons for select multiple
function addOption(fromID, toID) {
	var fromSel = document.getElementById(fromID);
	var toSel = document.getElementById(toID);
	var selIndex = fromSel.selectedIndex;
	var selText = fromSel.options[selIndex].text;
	var selValue = fromSel.options[selIndex].value;
	var bExists = false;

	for (var i = 0; i < toSel.length; i++) {
		if (toSel.options[i].value == selValue)
			bExists = true;
	}

	if (!bExists && selValue != '')
		toSel.options[toSel.length] = new Option(selText, selValue);
	else if (bExists)
		alert('This option has already been added');
	else
		alert('Please select an option to add');
}

function delOption(fromID) {
	var fromSel = document.getElementById(fromID);

	for (var i = fromSel.length-1; i >= 0; i--) {
		if (fromSel.options[i].selected)
			fromSel.options[i] = null;
	}
}
// End add-ons for select multiple



// workaround for absence of target attributes in xhtml strict
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}



function toggle_id(id) {
   var item = document.getElementById(id);

   if (item.style.display == "block")
      item.style.display = "none";
   else
      item.style.display = "block";
}



function toggle(linkid, id) {
   var item = document.getElementById(id);
   var link = document.getElementById(linkid);

   if (item.style.display != "block") {
      item.style.display = "block";
      link.firstChild.src = 'images/ico_collapse.gif';
   }
   else {
      item.style.display = "none";
      link.firstChild.src = 'images/ico_expand.gif';
   }
}



function validateAdmin() {
	var aMsg = new Array();
	var aMandatory = new Array('admUsername','admEmail','admFirstName','admLastName');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fUsername = document.getElementById('admUsername');
	var sUsername = fUsername.value;
	if (sUsername != '' && (sUsername.length < 4 || sUsername.length > 16)) {
		aMsg[aMsg.length] = 'Username should be between 4 to 16 characters';
		highlightLabel(fUsername.previousSibling);
	}

	var fPassword1 = document.getElementById('admPassword1');
	var sPassword1 = fPassword1.value;
	if (sPassword1 != '' && (sPassword1.length < 8 || sPassword1.length > 32)) {
		aMsg[aMsg.length] = 'Password should be between 8 to 32 characters';
		highlightLabel(fPassword1.previousSibling);
	}

	var fPassword2 = document.getElementById('admPassword2');
	var sPassword2 = fPassword2.value;
	if (sPassword2 != sPassword1) {
		aMsg[aMsg.length] = 'Passwords do not match';
		highlightLabel(fPassword2.previousSibling);
	}

	var fEmail = document.getElementById('admEmail');
	var sEmail = fEmail.value;
	if (sEmail != '' && sEmail.length > 255) {
		aMsg[aMsg.length] = 'Email should be less than 255 characters';
		highlightLabel(fEmail.previousSibling);
	}
	else if (sEmail != '' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Email is invalid';
		highlightLabel(fEmail.previousSibling);
	}

	var fFirstName = document.getElementById('admFirstName');
	var sFirstName = fFirstName.value;
	if (sFirstName != '' && sFirstName.length > 64) {
		aMsg[aMsg.length] = 'First name should be less than 64 characters';
		highlightLabel(fFirstName.previousSibling);
	}

	var fLastName = document.getElementById('admLastName');
	var sLastName = fLastName.value;
	if (sLastName != '' && sLastName.length > 64) {
		aMsg[aMsg.length] = 'Last name should be less than 64 characters';
		highlightLabel(fLastName.previousSibling);
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateTag() {
	var aMsg = new Array();
	var aMandatory = new Array('confName','confDisplay');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fName = document.getElementById('confName');
	var sName = fName.value;
	if (sName != '' && sName.length > 32) {
		aMsg[aMsg.length] = 'System name should be less than 32 characters';
		highlightLabel(fName.previousSibling);
	}
	else if (sName != '' && !validateAlphanumeric(sName)) {
		aMsg[aMsg.length] = 'System name should contain only letters and numbers';
		highlightLabel(fName.previousSibling);
	}

	var fDisplay = document.getElementById('confDisplay');
	var sDisplay = fDisplay.value;
	if (sDisplay != '' && sDisplay.length > 255) {
		aMsg[aMsg.length] = 'Display name should be less than 255 characters';
		highlightLabel(fDisplay.previousSibling);
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validatePromotion(type) {
	var aMsg = new Array();
	if (type == 'all')
		var aMandatory = new Array('promoTypeID','promoTitle','promoImgFilename','promoDesc');
	else
		var aMandatory = new Array('promoTypeID','promoTitle','promoDesc');
	//var aMandSelMul = new Array('restSel');
	var aSelMul = new Array('restID');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	
			// Start highlight label for multiple select
		if (document.getElementById(aSelMul[0]).options.length==0) {
			bMissing = true;
			highlightLabel(document.getElementById('restSel').previousSibling);
		}
		// End highlight label for multiple select
	

	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fTitle = document.getElementById('promoTitle');
	var sTitle = fTitle.value;
	if (sTitle != '' && sTitle.length > 255) {
		aMsg[aMsg.length] = 'Title should be less than 255 characters';
		highlightLabel(fTitle.previousSibling);
	}

	var fImg = document.getElementById('promoImgFilename');
	var sImg = fImg.value;
	if (sImg != '' && !validateImgExt(sImg)) {
		aMsg[aMsg.length] = 'Image to be uploaded should be a gif, jpg, or png file';
		highlightLabel(fImg.previousSibling);
	}

	var fStartYear = document.getElementById('promoStartYear');
	var fStartMonth = document.getElementById('promoStartMonth');
	var fStartDay = document.getElementById('promoStartDay');
	var dStart = new Date(fStartYear.value, fStartMonth.value, fStartDay.value, 0,0,0,0);

	var fEndYear = document.getElementById('promoEndYear');
	var fEndMonth = document.getElementById('promoEndMonth');
	var fEndDay = document.getElementById('promoEndDay');
	var dEnd = new Date(fEndYear.value, fEndMonth.value, fEndDay.value, 0,0,0,0);

	if (Date.parse(dStart) > Date.parse(dEnd)) {
		aMsg[aMsg.length] = 'End date should be after Start date';
		highlightLabel(fEndDay.previousSibling);
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else {
		//for selects with multiple options, select all
		for (var i = 0; i < aSelMul.length; i++) {
			var fSelMul = document.getElementById(aSelMul[i]);
			for (var j = 0; j < fSelMul.options.length; j++) {
				fSelMul.options[j].selected = true;
			}
		}
		return true;
	}
}



function validateRestaurant(type) {
	var aMsg = new Array();
	if (type == 'all')
		var aMandatory = new Array('restName','restShortDesc','restFullDesc','restMetaKeywords','restLocation','restTypeOfDining','restOperatingHrs','restGettingThere','restNearestCarpark','restTnFilename','restImg1Filename');
	else
		var aMandatory = new Array('restName','restShortDesc','restFullDesc','restMetaKeywords','restLocation','restTypeOfDining','restOperatingHrs','restGettingThere','restNearestCarpark');
	var bMissing = false;
	var currField = '';

	resetLabels();

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
			highlightLabel(currField.previousSibling);
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fName = document.getElementById('restName');
	var sName = fName.value;
	if (sName != '' && sName.length > 64) {
		aMsg[aMsg.length] = 'Name should be less than 64 characters';
		highlightLabel(fName.previousSibling);
	}

	var fLocation = document.getElementById('restLocation');
	var sLocation = fLocation.value;
	if (sLocation != '' && sLocation.length > 255) {
		aMsg[aMsg.length] = 'Location should be less than 255 characters';
		highlightLabel(fLocation.previousSibling);
	}

	var fTypeOfDining = document.getElementById('restTypeOfDining');
	var sTypeOfDining = fTypeOfDining.value;
	if (sTypeOfDining != '' && sTypeOfDining.length > 255) {
		aMsg[aMsg.length] = 'Type of dining should be less than 255 characters';
		highlightLabel(fTypeOfDining.previousSibling);
	}

	var fTelephone = document.getElementById('restTelephone');
	var sTelephone = fTelephone.value;
	if (sTelephone != '' && sTelephone.length > 255) {
		aMsg[aMsg.length] = 'Telephone should be less than 255 characters';
		highlightLabel(fTelephone.previousSibling);
	}

	var fGettingThere = document.getElementById('restGettingThere');
	var sGettingThere = fGettingThere.value;
	if (sGettingThere != '' && sGettingThere.length > 255) {
		aMsg[aMsg.length] = 'Getting there should be less than 255 characters';
		highlightLabel(fGettingThere.previousSibling);
	}

	var fNearestCarpark = document.getElementById('restNearestCarpark');
	var sNearestCarpark = fNearestCarpark.value;
	if (sNearestCarpark != '' && sNearestCarpark.length > 255) {
		aMsg[aMsg.length] = 'Nearest Carpark should be less than 255 characters';
		highlightLabel(fNearestCarpark.previousSibling);
	}

	var fWebsite = document.getElementById('restWebsite');
	var sWebsite = fWebsite.value;
	if (sWebsite != '' && sWebsite.length > 255) {
		aMsg[aMsg.length] = 'Website should be less than 255 characters';
		highlightLabel(fWebsite.previousSibling);
	}
	else if (sWebsite != '' && !validateURL(sWebsite)) {
		aMsg[aMsg.length] = 'Website is invalid';
		highlightLabel(fWebsite.previousSibling);
	}

	var fEmail = document.getElementById('restEmail');
	var sEmail = fEmail.value;
	if (sEmail != '' && sEmail.length > 255) {
		aMsg[aMsg.length] = 'Email should be less than 255 characters';
		highlightLabel(fEmail.previousSibling);
	}
	else if (sEmail != '' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Email is invalid';
		highlightLabel(fEmail.previousSibling);
	}

	var fMap = document.getElementById('restMapFilename');
	var sMap = fMap.value;
	if (sMap != '' && !validateImgExt(sMap)) {
		aMsg[aMsg.length] = 'Map to be uploaded should be a gif, jpg, or png file';
		highlightLabel(fMap.previousSibling);
	}

	var fChef = document.getElementById('restChefFilename');
	var sChef = fChef.value;
	if (sChef != '' && !validatePdfExt(sChef)) {
		aMsg[aMsg.length] = 'Chef file to be uploaded should be a PDF file';
		highlightLabel(fChef.previousSibling);
	}

	var fMenu = document.getElementById('restMenuFilename');
	var sMenu = fMenu.value;
	if (sMenu != '' && !validatePdfExt(sMenu)) {
		aMsg[aMsg.length] = 'Menu file to be uploaded should be a PDF file';
		highlightLabel(fMenu.previousSibling);
	}

	var fTn = document.getElementById('restTnFilename');
	var sTn = fTn.value;
	if (sTn != '' && !validateImgExt(sTn)) {
		aMsg[aMsg.length] = 'Thumbnail image to be uploaded should be a gif, jpg, or png file';
		highlightLabel(fTn.previousSibling);
	}

	for (var i = 1; i <= 5; i++) {
		var fImg = document.getElementById('restImg' + i + 'Filename');
		var sImg = fImg.value;
		if (sImg != '' && !validateImgExt(sImg)) {
			aMsg[aMsg.length] = 'Main image ' + i + ' to be uploaded should be a gif, jpg, or png file';
			highlightLabel(fImg.previousSibling);
		}
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateReservation() {
	var aMsg = new Array();
	var aMandatory = new Array('restID','reserveFullName','reserveContact','reserveEmail','reserveNoOfPersons','reserveDate','reserveTime');
	var bMissing = false;
	var currField = '';

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fEmail = document.getElementById('reserveEmail');
	var sEmail = fEmail.value;
	if (sEmail != '' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Email is invalid';
	}

	var fNoOfPersons = document.getElementById('reserveNoOfPersons');
	var sNoOfPersons = fNoOfPersons.value;
	if (sNoOfPersons != '' && !validateNumber(sNoOfPersons)) {
		aMsg[aMsg.length] = 'No. of Persons should contain only numbers';
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateMailingList() {
	var aMsg = new Array();
	var aMandatory = new Array('mlSurname','mlGivenName','mlDOB','mlGender','mlMarital','mlMobileTel','mlEmail','mlOccupation','mlIncome','mlMember');
	var bMissing = false;
	var currField = '';

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fDOB = document.getElementById('mlDOB');
	var sDOB = fDOB.value;
	if (sDOB == 'dd/mm/yyyy') {
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';
	}

	var fEmail = document.getElementById('mlEmail');
	var sEmail = fEmail.value;
	if (sEmail != '' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Email is invalid';
	}

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateForwardToFriend() {
	var aMsg = new Array();
	var aMandatory = new Array('friendSenderName','friendSenderEmail','friendName','friendEmail');
	var bMissing = false;
	var currField = '';

	for (var i = 0; i < aMandatory.length; i++) {
		currField = document.getElementById(aMandatory[i]);
		if (currField.value == '') {
			bMissing = true;
		}
	}
	if (bMissing)
		aMsg[aMsg.length] = 'Please fill in all mandatory fields';

	var fSenderEmail = document.getElementById('friendSenderEmail');
	var sSenderEmail = fSenderEmail.value;
	if (sSenderEmail != '' && !validateEmail(sSenderEmail)) {
		aMsg[aMsg.length] = 'Sender email is invalid';
	}

	var fEmail = document.getElementById('friendEmail');
	var sEmail = fEmail.value;
	if (sEmail != '' && !validateEmail(sEmail)) {
		aMsg[aMsg.length] = 'Friend\'s email is invalid';
	}

	var tmpText = document.getElementById("tmpText").value;
	document.getElementById("friendText").value = tmpText;

	if (aMsg.length > 0) {
		alert(aMsg.join('\n'));
		return false;
	}
	else
		return true;
}



function validateEmail(email) {
	var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	if (regex.test(email))
		return true;
	else
		return false;
}

function validateURL(url) {
	var regex = /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/;

	if (regex.test(url))
		return true;
	else
		return false;
}

function validatePdfExt(filename) {
	var dotIndex = filename.lastIndexOf('.');
	var extension = '';

	if (dotIndex != -1) {
		extension = filename.substring(dotIndex+1);
		extension = extension.toLowerCase();
		if (extension == 'pdf')
			return true;
		else
			return false;
	}
	else
		return false;
}

function validateImgExt(filename) {
	var dotIndex = filename.lastIndexOf('.');
	var extension = '';

	if (dotIndex != -1) {
		extension = filename.substring(dotIndex+1);
		extension = extension.toLowerCase();
		if (extension == 'jpg' || extension == 'jpeg' || extension == 'gif' || extension == 'png')
			return true;
		else
			return false;
	}
	else
		return false;
}

function validateAlphanumeric(txt) {
	var regex = /^[a-zA-Z0-9]+$/;

	if (regex.test(txt))
		return true;
	else
		return false;
}

function validateNumber(txt) {
	var regex = /^\d+$/;

	if (regex.test(txt))
		return true;
	else
		return false;
}



function resetLabels() {
	var labels = document.getElementsByTagName('label');
	var currLabel = '';

	for (var i = 0; i < labels.length; i++) {
		currLabel = labels[i];
		currLabel.style.color = '';
	}
}

function highlightLabel(label) {
	if (label.nodeName.toLowerCase() == 'label') {
		label.style.color = 'red';
	}
}



/***********************************************
* Ultimate Fade-In Slideshow (v1.51): © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=["photo1.jpg", "", ""] //plain image syntax
fadeimages[1]=["photo2.jpg", "http://www.cssdrive.com", ""] //image with link syntax
fadeimages[2]=["photo3.jpg", "http://www.javascriptkit.com", "_new"] //image with link and target syntax

var fadeimages2=new Array() //2nd array set example. Remove or add more sets as needed.
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages2[0]=["photo1.jpg", "", ""] //plain image syntax
fadeimages2[1]=["photo2.jpg", "http://www.cssdrive.com", ""] //image with link syntax
fadeimages2[2]=["photo3.jpg", "http://www.javascriptkit.com", "_new"] //image with link and target syntax

var fadebgcolor="white"

////NO need to edit beyond here/////////////

var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers

var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all

function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}

var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2

if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div></div>')
else
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')

if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
else if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
obj.tempobj.style.opacity=obj.degree/101
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}

fadeshow.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTML=slideHTML
}


fadeshow.prototype.rotateimage=function(){
if (this.pausecheck==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseovercheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}

fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=this.degree/100
else if (crossobj.style.opacity&&!crossobj.filters)
crossobj.style.opacity=this.degree/101
}


fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
}
this.rotateimage()
}



function getParamValue(parameter) {
	var sQuery = location.search.substring(1);
	var aParams = sQuery.split('&');
	var sParamName = '';
	var sParamValue = '';

	for (i = 0; i < aParams.length; i++) {
		sParamName = aParams[i].substring(0,aParams[i].indexOf('='));
		if (sParamName == parameter) {
			sParamValue = aParams[i].substring(aParams[i].indexOf('=')+1)
		}
	}

	if (sParamValue != '')
		return sParamValue;
	else
		return false;
}



// run all necessary functions on page load

function openTB() {
	if (location.pathname.search(/home.php/) != -1 && location.search.length != 0) {
		var iRestID = getParamValue('id');
		$(document).ready(function(){
		tb_show('', 'restaurant.php?id=' + iRestID + '&amp;keepThis=true&amp;TB_iframe=true&amp;height=580&amp;width=580', false);
		});
	}
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(openTB);
addLoadEvent(externalLinks);
