var browserName = navigator.appName; 

/*
 * Delegate function
 */
function delegate(instance, method)
{
  return function()
  {
    return method.apply(instance, arguments);
  }
}

// method creates an e-mail link
function openLinkToMail()
{
	// create an unreadably link for safety reason
	var s = "mailto:";
	s += "i";
	s += "n";
	s += "f";
	s += "o";
	s += "@";
	s += "v";
	s += "a";
	s += "n";
	s += "o";
	s += "u";
	s += "w";
	s += "e";
	s += "n";
	s += "d";
	s += "o";
	s += "r";
	s += "p";
	s += ".";
	s += "n";
	s += "l";
	window.location.href = s;	
}

// function converts a hex string to a number
function hex2num(hex)
{
	if(hex.charAt(0) == "#")
	{ 
		hex = hex.slice(1);
	}
	
	hex = hex.toUpperCase();
	var hex_alphabets = "0123456789ABCDEF";
	var value = new Array(3);
	var k = 0;
	var int1,int2;
	
	for(var i=0;i<6;i+=2)
	{
		int1 = hex_alphabets.indexOf(hex.charAt(i));
		int2 = hex_alphabets.indexOf(hex.charAt(i+1));
		value[k] = (int1 * 16) + int2;
		k++;
	}
	
	return(value);
}

// function converts a triplet array to an hex string
function num2hex(triplet)
{
	var hex_alphabets = "0123456789ABCDEF";
	var hex = "#";
	var int1,int2;
	
	for(var i=0;i<3;i++)
	{
		int1 = triplet[i] / 16;
		int2 = triplet[i] % 16;

		hex += hex_alphabets.charAt(int1) + hex_alphabets.charAt(int2);
	}
	
	return(hex);
}

function onInputText_Focus(sender, event)
{
	var defaultText = sender.getAttribute('defaultvalue');
	
	if (sender.value == defaultText)
	{
		sender.value = "";
	}
}

function onInputText_Blur(sender, event)
{
	var defaultText = sender.getAttribute('defaultvalue');
	
	if (sender.value == "")
		sender.value = defaultText;
}