/*Copyright 2005. William Ukoh @ http://www.williamukoh.com. All rights reserved worldwide. This material remains a property of William Ukoh and should not used or otherwised distributed without the permission of the owner*/


//Email page to someone
function emailPage(){
	openBrWindow('/contact/email.php?link='+document.URL,'email','status=yes,scrollbars=no,resizable=no,width=520,height=550');
}


//Mail to someone
function mailto(user,domain) 
{ 
document.location.href = "mailto:" + user + "@" + domain;
}


//Add to Favourites
function addToFavorite(){
  if ((navigator.appVersion.indexOf("MSIE") > 0) && (parseInt(navigator.appVersion) >= 4)) {
    window.external.AddFavorite(location.href, document.title);
  }
  else{
	  window.alert('Please use Internet Explorer to bookmark this site');
  }
}

//Set the URL address in the Address Bar
function flashPutHref(href) { 
	location.href = href; 
}

//Set the Title of the Window
function flashPutTitle(title) { 
	document.title = title; 
}
	
//Display my site
function displaySite(site){
	window.open(site);
}

//Open Browser Window
function openBrWindow(theURL,winName,features) {
  var result = window.open(theURL,winName,features);
  return result;
}

function getURLVar(urlVarName) {
//divide the URL in half at the '?' 
var urlHalves = String(document.location).split('?');
var urlVarValue = '';
if(urlHalves[1]){
//load all the name/value pairs into an array 
var urlVars = urlHalves[1].split('&');
//loop over the list, and find the specified url variable 
for(i=0; i<=(urlVars.length); i++){
if(urlVars[i]){
//load the name/value pair into an array 
var urlVarPair = urlVars[i].split('=');
if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
//I found a variable that matches, load it's value into the return variable 
urlVarValue = urlVarPair[1];
}
}
}
}
return urlVarValue;   
}


//Generate random string
function generateCode(iLen) {
	var sChrs = '123456789ABCDEFGHIJKLMNOPQRSTUVWZ-';
	var sRnd = '';
	for (var i=0; i < iLen ; i++){
		var randomPoz = Math.floor(Math.random() * sChrs.length);
		sRnd += sChrs.substring(randomPoz,randomPoz+1);
	}
	return sRnd;
}



function printPage(){
	window.print();
}

function getHostName(){
	var url = document.location.href;	
	var index = url.indexOf("/",7);
	
	if(index != 0){
		hostname = url.substring(0,index + 1);
		return hostname;
	}
	else{
		return url;
	}
}
function displayDate(){
    /*  var this_month = new Array(12);
      this_month[0]  = "January";
      this_month[1]  = "February";
      this_month[2]  = "March";
      this_month[3]  = "April";
      this_month[4]  = "May";
      this_month[5]  = "June";
      this_month[6]  = "July";
      this_month[7]  = "August";
      this_month[8]  = "September";
      this_month[9]  = "October";
      this_month[10] = "November";
      this_month[11] = "December";
      var today = new Date();
      var day   = today.getDate();
      var month = today.getMonth();
      var year  = today.getYear();
	  var minute = today.getMinutes();
	  var seconds = today.getSeconds();
      if (year < 1900){
         year += 1900;
      }
      return(day+" "+this_month[month]+" " +year);*/
		var today = new Date();
		return today.toLocaleString();
   }

function checkValue(state){
 
 if(state){
	if($("#emailAddress").val() == "email address"){
		$("#emailAddress").val("");
	}
 }
 else{
	 if($("#emailAddress").val() == ""){
		 $("#emailAddress").val("email address");
	 }
 }
}

function displayDisclaimer(){
		openBrWindow('/about/disclaimer.php','disclaimer','status=yes,scrollbars=no,resizable=no,width=480,height=430')
}
function displayTerms(){
		openBrWindow('/about/terms.php','terms','status=yes,scrollbars=yes,resizable=no,width=480,height=430')
}