// JavaScript Document
var home_0 = new Image(49,22);
home_0.src = 'images/service_nav_home0.gif';
var home_1 = new Image(49,22);
home_1.src = 'images/service_nav_home1.gif';

var profile_0 = new Image(48,22);
profile_0.src = 'images/service_nav_profile0.gif';
var profile_1 = new Image(48,22);
profile_1.src = 'images/service_nav_profile1.gif';

var contact_0 = new Image(48,22);
contact_0.src = 'images/service_nav_contact0.gif';
var contact_1 = new Image(48,22);
contact_1.src = 'images/service_nav_contact1.gif';

var downloads_0 = new Image(70,22);
downloads_0.src = 'images/service_nav_downloads0.gif';
var downloads_1 = new Image(70,22);
downloads_1.src = 'images/service_nav_downloads1.gif';

var consulting_0 = new Image(48,14);
consulting_0.src = 'images/main_nav_consulting0.gif';
var consulting_1 = new Image(48,14);
consulting_1.src = 'images/main_nav_consulting1.gif';

var speaking_0 = new Image(67,17);
speaking_0.src = 'images/main_nav_speaking0.gif';
var speaking_1 = new Image(67,17);
speaking_1.src = 'images/main_nav_speaking1.gif';

var writing_0 = new Image(67,17);
writing_0.src = 'images/main_nav_writing0.gif';
var writing_1 = new Image(67,17);
writing_1.src = 'images/main_nav_writing1.gif';

var live_0 = new Image(67,17);
live_0.src = 'images/main_nav_live0.gif';
var live_1 = new Image(67,17);
live_1.src = 'images/main_nav_live1.gif';

var heritage_0 = new Image(67,16);
heritage_0.src = 'images/main_nav_heritage0.gif';
var heritage_1 = new Image(67,16);
heritage_1.src = 'images/main_nav_heritage1.gif';

var press_0 = new Image(67,16);
press_0.src = 'images/main_nav_press0.gif';
var press_1 = new Image(67,16);
press_1.src = 'images/main_nav_press1.gif';

var news_0 = new Image(67,11);
news_0.src = 'images/main_nav_news0.gif';
var news_1 = new Image(67,11);
news_1.src = 'images/main_nav_news1.gif';

var newsletter_0 = new Image(66,11);
newsletter_0.src = 'images/main_nav_newsletter0.gif';
var newsletter_1 = new Image(66,11);
newsletter_1.src = 'images/main_nav_newsletter1.gif';

var bookings_0 = new Image(58,13);
bookings_0.src = 'images/main_nav_bookings0.gif';
var bookings_1 = new Image(58,13);
bookings_1.src = 'images/main_nav_bookings1.gif';


function SwapImage(objectname,objectnewstate) {
	var imageobj = document.getElementById(objectname);
	imageobj.src = this[objectnewstate].src;
}

//Form valdation functions

	function validForm(form) {



	var complete = true;
	 
	
	
		if (document.forms["dataForm"].enqType.value == "") {
	
			alert ("Please select a type of enquiry.");
	
			document.forms["dataForm"].enqType.focus();
	
			complete = false;
	
			return false;
	
		}
	
		if (document.forms["dataForm"].firstname.value == "") {
	
			alert ("Please enter your first name.");
	
			document.forms["dataForm"].firstname.focus();
	
			document.forms["dataForm"].firstname.select();
	
			complete = false;
	
			return false;
	
		}
	
		if (document.forms["dataForm"].lastname.value == "") {
	
			alert ("Please enter your last name.");
	
			document.forms["dataForm"].lastname.focus();
	
			document.forms["dataForm"].lastname.select();
	
			complete = false;
	
			return false;
	
		}
	
		if (document.forms["dataForm"].email.value == "") {
	
			alert ("Please enter your e-mail address.");
	
			document.forms["dataForm"].email.focus();
	
			document.forms["dataForm"].email.select();
	
			complete = false;
	
			return false;
	
		}
	
		if (document.forms["dataForm"].query.value == "") {
	
			alert ("Please enter your query.");
	
			document.forms["dataForm"].query.focus();
	
			document.forms["dataForm"].query.select();
	
			complete = false;
	
			return false;
	
		}
	
		if (complete == true) {
	
			document.forms["dataForm"].submit;	
	
		}
	
	}
	
	

imageItems = [{imageFile:'home_thebe_ikalafeng_traditional_ghanain_dance.jpg'},{imageFile:'home_thebe_ikalafeng_and_helen_suzman.jpg'},{imageFile:'home_thebe_ikalafeng_and_oprah_winfrey.jpg'},{imageFile:'home_thebe_ikalafeng_and_sam_nujoma.jpg'},{imageFile:'home_thebe_ikalafeng_and_nike.jpg'},{imageFile:'home_thebe_ikalafeng_and_friends.jpg'},{imageFile:'home_thebe_ikalafeng_and_tiger_woods.jpg'},{imageFile:'home_thebe_ikalafeng_and_marian_jones.jpg'},{imageFile:'home_thebe_ikalafeng_and_the_president.jpg'}];

function getRandomAmount(from,to) {
	return Math.floor(Math.random()*(to+1)+from);
}

function getImageItem() {
	var imageItem = imageItems[getRandomAmount(0,imageItems.length-1)];
	
	return '<img src="images/'+imageItem.imageFile+'" width="447" height="215" border="0" />';
}


imageItems2 = [{imageFile2:'home_brands_and_branding.jpg'},{imageFile2:'home_brands_and_branding_2000.jpg'},{imageFile2:'home_brands_and_branding_2002.jpg'},{imageFile2:'home_brands_and_branding_2005.jpg'},{imageFile2:'home_brands_and_branding_2002.jpg'}];

function getImageItem2() {
	var imageItem2 = imageItems2[getRandomAmount(0,imageItems2.length-1)];
	
	return '<img src="images/'+imageItem2.imageFile2+'" width="210" height="215" border="0" />';
}
 
 
 imageItems3 = [{imageFile3:'consulting_mercury.jpg'},{imageFile3:'consulting_metrofile.jpg'},{imageFile3:'consulting_ndc.jpg'},{imageFile3:'consulting_ndc2.jpg'},{imageFile3:'consulting_transnet.jpg'},{imageFile3:'consulting_transnet2.jpg'},{imageFile3:'consulting_unisa.jpg'},{imageFile3:'consulting_university_botswana.jpg'}];

function getImageItem3() {
	var imageItem3 = imageItems3[getRandomAmount(0,imageItems3.length-1)];
	
	return '<img src="images/'+imageItem3.imageFile3+'" width="447" height="215" border="0" />';
}

 imageItems4 = [{imageFile4:'speaking_1.jpg'},{imageFile4:'speaking_3.jpg'},{imageFile4:'speaking_4.jpg'},{imageFile4:'speaking_5.jpg'}];

function getImageItemOne() {
	var imageItem4 = imageItems4[getRandomAmount(0,imageItems4.length-1)];
	
	return '<img src="images/'+imageItem4.imageFile4+'" width="447" height="215" border="0" />';
}

imageItems5 = [{imageFile5:'profile_1.jpg'}];

function getImageItemProfile() {
	var imageItem5 = imageItems5[getRandomAmount(0,imageItems5.length-1)];
	
	return '<img src="images/'+imageItem5.imageFile5+'" width="447" height="215" border="0" />';
}

imageItems6 = [{imageFile6:'heritage_1.jpg'},{imageFile6:'heritage_2.jpg'},{imageFile6:'heritage_3.jpg'},{imageFile6:'heritage_4.jpg'},{imageFile6:'heritage_5.jpg'},{imageFile6:'heritage_6.jpg'}];

function getImageItemHeritage() {
	var imageItem6 = imageItems6[getRandomAmount(0,imageItems6.length-1)];
	
	return '<img src="images/'+imageItem6.imageFile6+'" width="447" height="215" border="0" />';
}



function go_there(targ,selObj,restore)
{ 
//var where_to= confirm("What your leaving! Are you sure? Press OK to continue.");
//if (where_to== true)
//{
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
//}
} 



//========= AJAX PAGE RELOAD ============
/* INCLUDE PAGES INSIDE THE RIGHT COLUMN*/
function clientSideInclude(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id + 
   "passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}

function poorman_toggle(id) { 
	var tr = document.getElementById(id); 
	if (tr==null) { 
		return;
	} 
	var bExpand = tr.style.display == ''; 
	tr.style.display = (bExpand ? 'none' : ''); 
} 
function poorman_changeimage(id, sMinus, sPlus) { 

	var img = document.getElementById(id); 
	if (img!=null) { 
		var bExpand = img.src.indexOf(sPlus) >= 0; 
		if (!bExpand) img.src = sPlus; else img.src = sMinus; 
	} 
} 

function Open() {
	poorman_changeimage('open',  'images/button_table_close_inbox.png', 'images/button_table_open_inbox.png'); 
	poorman_toggle('open_presentation');
}


//function ShowImageRandomlyHome() {
	arr1 = new Array("images/home_thebe_ikalafeng_traditional_ghanain_dance.jpg","images/home_thebe_ikalafeng_and_helen_suzman.jpg","images/home_thebe_ikalafeng_and_oprah_winfrey.jpg");
	arr2 = new Array();
	
	function change(){

		if(arr1.length == 0){
		arr1 = arr2;
		delete arr2;
		arr2 = new Array();
		}
		
		var randNum = getRand();
		
		while(document.getElementById("img").value==arr1[randNum]){
		var randNum = getRand();
		}
		document.getElementById("img").value = arr1[randNum];
		arr2.push(arr1[randNum]);
		arr1.splice(randNum,1);
	
		setTimeout('change()',2000);
	}
	
	function getRand () {
		var rnum;
		if(arr1.length==1)
		return '0';
		var id=Math.round(Math.random()*(arr1.length-1));
		return id;
	}
//}

// JavaScript Document

//===================================SLIDER


function TrackFrm() {
	var theForm = document.getElementById("TrackFrmR");
	theForm.submit();
	//alert("welccc");
}

function TrackFrm2() {
	var theForm = document.getElementById("TrackFrmR");
	theForm.submit();
	//alert("welccc");
}

function RegUser() {
	//document.location.href = 'reg_user.php';				
	//document.form.submit();
	
	/*document.form.action = 'http://electricpencilnewsletters.createsend.com/t/y/s/idkkyk/';
	document.form.submit();*/
	//window.location.href="reg_user.php";
	
	//var fname = document.getElementById("FirstName").value;
	alert("Test");
	document.form.action = 'reg_user.php';
	document.form.submit();
	//window.location.href="reg_user.php";
}
function checkEmail() {
	var theForm = document.getElementById("formF");
	var requiredMessage = "";
	var validateMessage = "";
	var fullMessage = "";
	
	if (theForm.email.value == "") {
		requiredMessage += "\t* Email Address.\n";
	} else if (!isValidEmail(theForm.email.value)) {
		validateMessage += "\t* Email Address.\n";
	}
	
	if (requiredMessage != "") {
		fullMessage += "This field is required:\n"+requiredMessage;
	}
	if (validateMessage != "") {
		fullMessage += "This fields have invalid values:\n"+validateMessage;
	}
	
	if (fullMessage != "") {
		alert(fullMessage);
	} else {
		theForm.submit();
	}
}

function isValidEmail(strEmail){
	validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	// search email text for regular exp matches
	if (strEmail.search(validRegExp) == -1) {
		return false;
	} 
	return true; 
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		//alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		//alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		//alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		//alert("Invalid E-mail ID")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		//alert("Invalid E-mail ID")
		return false
	 }

	 return true					
}


function WebFrm() {
	var theForm = document.getElementById("bookingFrm");
	var requiredMessage = "";
	var validateMessage = "";
	var fullMessage = "";
	
	
	if (theForm.FirstName.value == "") {
		requiredMessage += "\t* First Name.\n";
	}
	if (theForm.LastName.value == "") {
		requiredMessage += "\t* Last Name.\n";
	}
	if (theForm.Organisation.value == "") {
		requiredMessage += "\t* Organisation.\n";
	}
	if (theForm.Position.value == "") {
		requiredMessage += "\t* Position.\n";
	}
	if (theForm.PostalAddres.value == "") {
		requiredMessage += "\t* PostalAddres.\n";
	}
	if (theForm.city.value == "") {
		requiredMessage += "\t* City.\n";
	}
	if (theForm.province.value == "") {
		requiredMessage += "\t* Province.\n";
	}
	if (theForm.PostalCode.value == "") {
		requiredMessage += "\t* Postal Code.\n";
	}
	if (theForm.TelephoneNumber.value == "") {
		requiredMessage += "\t* Telephone Number.\n";
	}
	if (theForm.FaxNumber.value == "") {
		requiredMessage += "\t* Fax Number.\n";
	}
	if (theForm.CellNumber.value == "") {
		requiredMessage += "\t* Cell Number.\n";
	}
	if (theForm.Industry.value == "") {
		requiredMessage += "\t* Industry.\n";
	}
	if (theForm.keynote_presentation.value == "none") {
		requiredMessage += "\t* Keynote Presentation.\n";
	}
	if (theForm.presentation_duration.value == "none" && theForm.workshop_duration.value == "none") {
		requiredMessage += "\t* Duration.\n";
	}
	if (theForm.workshops.value == "none") {
		requiredMessage += "\t* Workshop.\n";
	}
	/*if (theForm.workshop_duration.value == "none") {
		requiredMessage += "\t* Workshop Duration.\n";
	}*/
	
	if (theForm.PurposeOfEvent.value == "") {
		requiredMessage += "\t* Purpose of Event.\n";
	}
	if (theForm.NumberOfDelegates.value == "") {
		requiredMessage += "\t* Number of Delegates.\n";
	}
	if (theForm.DelegateInformation.value == "") {
		requiredMessage += "\t* Delegate Information.\n";
	}
	if (theForm.date.value == "") {
		requiredMessage += "\t* Date.\n";
	}
	if (theForm.Time.value == "") {
		requiredMessage += "\t* Time.\n";
	}
	if (theForm.Venue.value == "") {
		requiredMessage += "\t* Venue.\n";
	}
	if (theForm.physical_address_of_venue.value == "") {
		requiredMessage += "\t* Physical address of venue.\n";
	}
	if (theForm.telephone_number_of_venue.value == "") {
		requiredMessage += "\t* Telephone number of venue.\n";
	}
	
	
	if (theForm.EmailAddress.value == "") {
		requiredMessage += "\t* Email Address.\n";
	} else if (!isValidEmail(theForm.EmailAddress.value)) {
		validateMessage += "\t* Email Address.\n";
	}
	
	if (requiredMessage != "") {
		fullMessage += "These fields are required:\n"+requiredMessage;
	}
	if (validateMessage != "") {
		fullMessage += "These fields have invalid values:\n"+validateMessage;
	}
	
	if (fullMessage != "") {
		alert(fullMessage);
	} else {
		theForm.submit();
	}
}
