/*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('extensions/email.php?link=','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;
	}
}
