// setStyleById: given an element id, style property and
// value, apply the style.
// args:
//  i - element id
//  p - property
//  v - value
//
function setStyleById(i, p, v) {
        var n = document.getElementById(i);
	      n.style[p] = v;
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }

function isBlank(strTargetId)
{
    if (document.getElementById(strTargetId).value.trim()=='')
    {
       return true;
    }
    else
    {
       return false;
    }
}

function mdGetSelectedValue(strIdCombobox)
{
	objCombobox = document.getElementById(strIdCombobox);
	strComboboxValue = objCombobox.options[objCombobox.selectedIndex].value;
	return (strComboboxValue);
}

function mdSwapImage(strImageID, strImageSource)
{
         document.getElementById(strImageID).src = strImageSource;
}

function mdSwapImage(strImageID, strImageSource)
{
         document.getElementById(strImageID).src = strImageSource;
}

function preloadNav() {
     var i = 0;
     imagesURL = new Array();
     imagesArr = new Array();
     imagesURL[0]="/images/0.1_b.gif";
     imagesURL[1]="/images/0.2_b.gif";
     imagesURL[2]="/images/0.3_b.gif";
     imagesURL[3]="/images/0.4_b.gif";
     imagesURL[4]="/images/0.5_b.gif";
     imagesURL[5]="/images/0.6_b.gif";
     imagesURL[6]="/images/0.7_b.gif";
     imagesURL[7]="/images/0.1_a.gif";
     imagesURL[8]="/images/0.2_a.gif";
     imagesURL[9]="/images/0.3_a.gif";
     imagesURL[10]="/images/0.4_a.gif";
     imagesURL[11]="/images/0.5_a.gif";
     imagesURL[12]="/images/0.6_a.gif";
     imagesURL[13]="/images/0.7_a.gif";
     
     

     // start preloading
     for(i=0; i<=imagesURL.length; i++)
     {
          imagesArr[i]= new Image();
          imagesArr[i].src=imagesURL[i];

     }
}

function moveCursor(e,strSourceId,strTargetId,intTotal)
{
    var keynum;
    var keychar;
    var numcheck;

    if(window.event) // IE
    {
        keynum = e.keyCode;
    }
    else if(e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which;
        intTotal--;
    }

    keychar = String.fromCharCode(keynum);
    numcheck = /[\d]/;
    if (numcheck.test(keychar))
    {
       strSourceValue = document.getElementById(strSourceId).value;
       if (strSourceValue.length==(intTotal)) document.getElementById(strTargetId).focus();
    }
}

//AJAX
//***************************************************************************
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
	// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
	// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}