String.prototype.trim = function()
{
    var x=this;
    x=x.replace(/^\s*(.*)/, "$1");
    x=x.replace(/(.*?)\s*$/, "$1");
    return x;
}

function getElement(id)
{
    if(document.layers) //NN4+
    {
		return document.layers[id];
    }
    else if(document.getElementById) //gecko(NN6) + IE 5+
    {
        return document.getElementById(id);
    }
    else if(document.all)	// IE 4
    {
        return document.all[id];
    }
    return null;
}

function pause(milliseconds)
{
    var now = new Date();
    var exitTime = now.getTime() + milliseconds;
    while(true)
    {
        now = new Date();
        if(now.getTime() > exitTime) return;
    }
}

function getKeyCode(event)
{
   event = event || window.event;
   kc = event.keyCode;
   if (!kc)
       kc = event.which;
   return kc;
}

function preload()
{
    getElement('vawaf_preload').style.display = 'none';
}

function divtggl()
{
	for (var n = 0; n < arguments.length; n++)
	{
		var a = arguments[n];
		var mode = a.substr(0, 1);
		if (mode != "+" && mode != "-")
		{
			var s = getElement(a).style;
			s.display == 'none' ? s.display = 'block' : s.display = 'none';
		}
		else
		{
			o = a.substr(1, a.length);
			s = getElement(o).style;
			mode == "-" ? s.display = 'none' : s.display = 'block';
		}
	}
}

function mv2msptr(id, ox, oy)
{
	if (!ox)
		ox = 0;
	if (!oy)
		oy = 0;
	var o = getElement(id);
	var x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
    var y = (document.all) ? window.event.y + document.body.scrollTop : e.pageY;
    o.style.left = (x + ox) + "px";
    o.style.top  = (y + oy) + "px";
}

function addfavs(url, ttl)
{
	if (window.external)
	{
		window.external.AddFavorite(url, ttl);
	}
	else
	{
		alert("Sorry, your browser does not support adding favortires. You may want to add this page manually to your favorites now!");
	}
}

function msgbox(msg, trgt)
{
	var r = window.confirm(msg);
	if (r == true)
		window.location.href = trgt;
}

function getkeycode(event)
{
    var key = null;
    if( window.event)
        key = window.event.keyCode;
    else if(event)
        key = event.which;
    return key;
}

function submitenter(myfield, e)
{
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else if (e)
		keycode = e.which;
	else
		return true;
	
	if (keycode == 13)
   {
		myfield.form.submit();
		return false;
   }
	else
	   return true;
}

 function CreateBookmarkLink() {

 title = "Webpage Title";
  // Blogger - Replace with <$BlogItemTitle$>
  // MovableType - Replace with <$MTEntryTitle$>

 url = "Webpage URL";
  // Blogger - Replace with <$BlogItemPermalinkURL$>
  // MovableType - Replace with <$MTEntryPermalink$>
  // WordPress - <?php bloginfo('url'); ?>

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }

function add2favs(title, url)
{
    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(title, url,"");
    } else if( window.external ) { // IE Favorite
        window.external.AddFavorite(url, title); }
    else if(window.opera && window.print) { // Opera Hotlist
        return true; }
    return true;
 }
 