startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("topnav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

//search validation
function checkSearch() 
{ 
  if (document.SearchForm.q.value == "")
  {
    window.alert("Please enter a text value to be searched for.");
    return false;
  }
  document.SearchForm.q.value = trim(document.SearchForm.q.value.toLowerCase());
  return true; 
}

function trim(psText) 
{
	psText = psText.replace(/^[\s]+/g,"");
	psText = psText.replace(/[\s]+$/g,"");
	return psText;
}

//receive custom alerts msg
function tmt_findObj(n){
var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
}else{x=document.getElementById(n)}return x;
}
function MM_showHideLayers() { //v3.0A Modified 
var i,p,v,obj,args=MM_showHideLayers.arguments;if(document.getElementById){
for (i=0; i<(args.length-2); i+=3){ obj=tmt_findObj(args[i]);v=args[i+2];
v=(v=='show')?'visible':(v='hide')?'hidden':v;
if(obj)obj.style.visibility=v;}} else{
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
obj.visibility=v; }}
}

function appendLocation(theLink) {
    var thisPage = "" + location;
    var bits = thisPage.split("&");
    var s = ""
    for (var i = 0; i < bits.length; i++) {
      s += bits[i] + "^"
    }
    if (s == "") {
      theLink.href = theLink.href + "&refPage=" + thisPage
     } else {
       theLink.href = theLink.href + "&refPage=" + s
    }
    return true;
}

function ss(w, id)
{
	window.status = w;
	return true;
}

function cs()
{
	window.status = "";
}
function jump(url)
{
	if (document.images && url)
	{
		if (arguments.length > 1)
		{
			type = arguments[1];
		}
		else
		{
			type = 'result';
		}
	
 		new Image().src = '/contents/images/_jump.gif?url=' + escape(url).replace(/\+/g, '%2B') + '&type=' + type;
	}
	
	return true;
}

//login form in c-clamp
function login(mainLoginForm){
	if (document.mainLoginForm.login_id.value == ''){
		alert('Please enter your user name')
		document.mainLoginForm.login_id.focus();
		return false;
	}
	if (document.mainLoginForm.pass.value == ''){
		alert('Please enter your password')
		document.mainLoginForm.pass.focus();
		return false;
	}	
	document.mainLoginForm.returnURL.value = window.location.href	
	document.mainLoginForm.submit()
	return true;
}

// sample call: TimeToNowFrom('2006-03-20T22:00:20Z')

Date.prototype.setISO8601 = function (string) {
	var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})" +
		"(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?" +
		"(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
	var d = string.match(new RegExp(regexp));

	var offset = 0;
	var date = new Date(d[1], 0, 1);

	if (d[3]) { date.setMonth(d[3] - 1); }
	if (d[5]) { date.setDate(d[5]); }
	if (d[7]) { date.setHours(d[7]); }
	if (d[8]) { date.setMinutes(d[8]); }
	if (d[10]) { date.setSeconds(d[10]); }
	if (d[12]) { date.setMilliseconds(Number("0." + d[12]) * 1000); }
	if (d[14]) {
		offset = (Number(d[16]) * 60) + Number(d[17]);
		offset *= ((d[15] == '-') ? 1 : -1);
	}

//	offset -= date.getTimezoneOffset();
	time = (Number(date) + (offset * 60 * 1000));
	this.setTime(Number(time));
}

Date.prototype.toISO8601String = function (format, offset) {
	/* accepted values for the format [1-6]:
	 1 Year:
	   YYYY (eg 1997)
	 2 Year and month:
	   YYYY-MM (eg 1997-07)
	 3 Complete date:
	   YYYY-MM-DD (eg 1997-07-16)
	 4 Complete date plus hours and minutes:
	   YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
	 5 Complete date plus hours, minutes and seconds:
	   YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
	 6 Complete date plus hours, minutes, seconds and a decimal
	   fraction of a second
	   YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
	*/
	if (!format) { var format = 6; }
	if (!offset) {
		var offset = 'Z';
		var date = this;
	} else {
		var d = offset.match(/([-+])([0-9]{2}):([0-9]{2})/);
		var offsetnum = (Number(d[2]) * 60) + Number(d[3]);
		offsetnum *= ((d[1] == '-') ? -1 : 1);
		var date = new Date(Number(Number(this) + (offsetnum * 60000)));
	}

	var zeropad = function (num) { return ((num < 10) ? '0' : '') + num; }

	var str = "";
	str += date.getUTCFullYear();
	if (format > 1) { str += "-" + zeropad(date.getUTCMonth() + 1); }
	if (format > 2) { str += "-" + zeropad(date.getUTCDate()); }
	if (format > 3) {
		str += "T" + zeropad(date.getUTCHours()) +
			":" + zeropad(date.getUTCMinutes());
	}
	if (format > 5) {
		var secs = Number(date.getUTCSeconds() + "." +
			((date.getUTCMilliseconds() < 100) ? '0' : '') +
			zeropad(date.getUTCMilliseconds()));
		str += ":" + zeropad(secs);
	} else if (format > 4) { str += ":" + zeropad(date.getUTCSeconds()); }

	if (format > 3) { str += offset; }
	return str;
}

Date.prototype.getMonthName = function (abbreviated) {
	var monthName = '';
	switch (this.getMonth())
	{
		case 0:
			monthName = 'January';
			break;
		case 1:
			monthName = 'February';
			break;
		case 2:
			monthName = 'March';
			break;
		case 3:
			monthName = 'April';
			break;
		case 4:
			monthName = 'May';
			break;
		case 5:
			monthName = 'June';
			break;
		case 6:
			monthName = 'July';
			break;
		case 7:
			monthName = 'August';
			break;
		case 8:
			monthName = 'September';
			break;
		case 9:
			monthName = 'October';
			break;
		case 10:
			monthName = 'November';
			break;
		case 11:
			monthName = 'December';
			break;
	}

	if (abbreviated)
		monthName = monthName.substr(0, 3);

	return monthName;
}

Math.truncate = function (value)
{
	value = '' + value;
	var position = value.indexOf('.');

	if (position != -1)
		return value.substr(0, position);
	else
		return value;
}

function TimeToNowFrom(iso8601String)
{
	var output = '';

	var fromDate = new Date();
	fromDate.setISO8601(iso8601String);

	var currentDate = new Date();

	var difference = currentDate - fromDate;

	var seconds = (difference / 1000) % 60;
	var minutes = ((difference / 1000) / 60) % 60;
	var hours = (((difference / 1000) / 60) / 60) % 24;
	var days = ((((difference / 1000) / 60) / 60) / 24);

	seconds = Math.truncate(seconds);
	minutes = Math.truncate(minutes);
	hours = Math.truncate(hours);
	days = Math.truncate(days);

	/* test (for use in a browser)
	document.write('Current date: ' + currentDate.toISO8601String(5) + '<hr/>');
	document.write('Compare date: ' + fromDate.toISO8601String(5) + '<hr/>');
	document.write('Difference (days hours minutes seconds | difference): ' + days + ' ' + hours + ' ' + minutes + ' ' + seconds + ' | ' + difference + '<hr/>');
	*/

	if (difference > 0)
	{
		if (days > 0)
		{
			output = fromDate.getMonthName(true) + ' ' + fromDate.getDate() + ', ' + fromDate.getYear();
		}
		else
		{
			if (hours > 1)
				output += hours + ' hours ';
			else if (hours > 0)
				output += hours + ' hour ';

			if (minutes > 1)
				output += minutes + ' minutes ';
			else if (minutes > 0)
				output += minutes + ' minute ';

			output += 'ago';
		}
	}

	return output;
}

function google_ad_request_done(google_ads) {
    /*
     * This function is required and is used to display
     * the ads that are returned from the JavaScript
     * request. You should modify the document.write
     * commands so that the HTML they write out fits
     * with your desired ad layout.
     */
    var s = '';
    var i;

    /*
     * Verify that there are actually ads to display.
     */
    if (google_ads.length == 0) {
      return;
    }
    /*
     * If an image or Flash ad is returned, display that ad.
     * Otherwise, build a string containing all of the ads and
     * then use a document.write() command to print that string.
     */

    if (google_ads[0].type == "flash") {
      s += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
              ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"' +
              ' WIDTH="' + google_ad.image_width +
              '" HEIGHT="' + google_ad.image_height + '">' +
              '<PARAM NAME="movie" VALUE="' + google_ad.image_url + '">'
              '<PARAM NAME="quality" VALUE="high">'
              '<PARAM NAME="AllowScriptAccess" VALUE="never">'
              '<EMBED src="' + google_ad.image_url +
              '" WIDTH="' + google_ad.image_width +
              '" HEIGHT="' + google_ad.image_height + 
              '" TYPE="application/x-shockwave-flash"' + 
              ' AllowScriptAccess="never" ' + 
              ' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';

    } else if (google_ads[0].type == "image") {
      s += '<a hre' + 'f=\"' + google_ads[0].url +
              '" target="_top" title="go to ' + google_ads[0].visible_url +
              '"><img border="0" src="' + google_ads[0].image_url +
              '"width="' + google_ads[0].image_width +
              '"height="' + google_ads[0].image_height + '"></a>';

    } else {
      s += '<div id=\"google\"><div class=\"googleSponsor\">Ads By Google</div>';
      if (google_ads.length == 1) {
        /*
         * Partners should adjust text sizes
         * so ads occupy the majority of ad space.
         */
        s += '<a hre' + 'f=\"' + google_ads[0].url + '" ' +
                          'onmouseout="window.status=\'\'" ' +
                          'onmouseover="window.status=\'go to ' +
                          google_ads[0].visible_url + '\'" ' +
                          'style="text-decoration:none">' +
                          '<div class=\"googleAd\">' + google_ads[0].line1 + '</div>' +
						  '<div class=\"googleAdText\">' + google_ads[0].line2 + 
						  '&nbsp;' + google_ads[0].line3 + '</div>' +
                          '<div class=\"googleAdURL\">' +
                          google_ads[0].visible_url + '</div></a></div>';
      } else if (google_ads.length > 1) {
        /*
         * For text ads, append each ad to the string.
         */
        for(i=0; i < google_ads.length; ++i) {
          s += '<a hre' + 'f=\"' + google_ads[i].url + '" ' +
                            'onmouseout="window.status=\'\'" ' +
                            'onmouseover="window.status=\'go to ' +
                            google_ads[i].visible_url + '\'" ' +
                            'style="text-decoration:none">' +
                            '<div class=\"googleAd\">' + google_ads[i].line1 + '</div>' + 
                            '<div class=\"googleAdText\">' + google_ads[i].line2 + 
							'&nbsp;' + google_ads[i].line3 + '</div>' +
                            '<div class=\"googleAdURL\">' +
                            google_ads[i].visible_url + '</div></a>';

        }
s += '</div>';
      }
    }

    document.write(s);
    return;
  }

function CheckForm(){
mystr = document.emailArticle.mailTo.value;
varArr = new Array();
varArr = mystr.split(";");

for (j=0; j<=varArr.length-1; j++){     
     if(!ValidEmail(varArr[j]))
     {strMsg = "The Colleague email address you typed is invalid.";            
     alert(strMsg);
     document.emailArticle.mailTo.focus();
     return false;
     }
}

if (!ValidEmail(document.emailArticle.mailFrom.value))
   {strMsg = "The email address you typed as yours is invalid.";            
    alert(strMsg);
    document.emailArticle.mailFrom.focus();
    return false;
   }

addRefPage();
}

function ValidEmail(email) {

var invalidChars = " /:,;";
var invalidChar;

if (email == "") {
   return false;
}

for (i=0; i<invalidChars.length; i++) {
     invalidChar = invalidChars.charAt(i)
     if (email.indexOf(invalidChar,0) != -1) {
         return false;
     }
     }
     atPos = email.indexOf("@",1)
     if (atPos == -1) {
        return false;
     }
     if (email.indexOf("@",atPos+1) != -1) {
        return false;
     }
     periodPos = email.indexOf(".",atPos)
     if (periodPos == -1) {
        return false;
     }
     if (periodPos+3 > email.length) {
        return false;
     }       

     return true;
}

function addRefPage() {
     var loc = "" + location
     if (loc.indexOf("&refPage") == -1) 
     return  
     var ref = loc.substring( loc.indexOf("&refPage=") + 9, loc.length );
     document.emailArticle.refPage.value = ref;
     return true;
}

function makeCookie(name,value,days) {

	if (days)

	{

		var date = new Date();

		date.setTime(date.getTime()+(days*24*60*60*1000));

		var expires = "; expires="+date.toGMTString();

	}

	else var expires = "";

	document.cookie = name+"="+value+expires+"; path=/";

}

function getCookie(name) {

	var nameEQ = name + "=";

	var ca = document.cookie.split(';');

	for(var i=0;i < ca.length;i++)

	{

		var c = ca[i];

		while (c.charAt(0)==' ') c = c.substring(1,c.length);

		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);

	}

	return null;

}

function deleteCookie(name) {

	makeCookie(name,"",-1);

}