var editwin = null;
function setCheckedAll(obj, fr) {
	for (var i = 0; i < fr.elements.length; i++) {
		var e = fr.elements[i];
		if ((e.name != obj.name) && (e.type=='checkbox') && (e.disabled != true))
			e.checked = obj.checked;
	}
}

function setCheckID(obj, fr) {
	var TB = TO = 0;
	for (var i = 0; i < fr.elements.length; i++) {
		var e = fr.elements[i];
		if ((e.name != obj.name) && (e.type == 'checkbox') && (e.disabled != true)) {
			TB++;
			if (e.checked)
				TO++;
		}
	}
	if (TO == TB)
		obj.checked = true;
	else
		obj.checked = false;
}
function OWEdit(File, W, H) {
	W += 50;
	H += 50;
	if(W > 780)	W = 780;
	if(H > 600)	 H = 600;
	Temp = "scrollbars=2, resizable=yes, width=" + W + ", height = " + H;
	window.open(File, "FullImage", Temp);
}
function CheckMarkVal(strss, mark) {
	for(i = 0; i < mark.length && strss.indexOf(mark.charAt(i)) < 0; i++);
	return ( i < mark.length) ? false : true;
}


var reAlphanumeric = /^[a-zA-Z0-9]+$/;

function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}
function isEmpty(s){
	return ((s == null) || (s.length == 0))
}
function isAlphanumeric(s){
	if (isEmpty(s) == false)
		return reAlphanumeric.test(s);
}
function isValidChar(s){
	if(isEmpty(s) == false){
		var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
		var temp;

		for (var i = 0; i < s.length; i++){
			temp = "" + s.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") return false;
		}
		return true;
	}
}

//This function is used to check the validation of email address.
function isEmail(value) {
	/*
		Email Address's Format: username@subdomain.domain
		Email Address must be include 3 part:
			part 1: username
			part 2: @
			part 3: <domainname[.domainname,...]>.<domainname>
	*/
	if (value==null || value=="")	return true;
	if (value.indexOf(" ")>=0)		return false;

	var state, code, username, domain, amountOfDot, i;
	state = 1; username=''; domain=''; amountOfDot = 0;
	for (i=0; i<value.length; i++) {
		code = value.charAt(i);
		if (state==1) {
			if (code == "<" || code == ">" || code == "(" || code == ")"	) return false;
			else if (	code == "@"	)
				if (username == '') return false;
				else state = 3;
			username += code;
		}
		else if (state==3) {
			if ((code >= "0" && code <= "9")
					|| (code >= "A" && code <= "Z")
					|| (code >= "a" && code <= "z")
					|| code == "_"
					|| code == "-"
				) ;
			else if (code == ".")
				if (domain == '' || domain.charAt(domain.length-1) == '.') return false;
				else amountOfDot++;
			else return false;
			domain += code;
		}
	}
	if (state != 3) return false;
	if (domain == '' || domain.charAt(domain.length-1) == '.') return false;
	if (amountOfDot <1) return false;
	return true;
}
//This function is used to check the validation of username.
function isUsername(userName)
{
  var pattern=/^[a-z][a-z0-9_-]{2,30}$/i;
  if (!pattern.test(userName)) return false;
  return true;
}
//var emailPatter=/^[-a-zA-Z0-9._]+@([-a-zA-Z0-9_]+\.)+[a-zA-Z0-9_]+$/;
//This function is used to check the validation of telephone, fax number.
function isTelephone(phone)
{
  var pattern = /^\+?[0-9 ()-.]+[0-9.]$/;
  var phoneval=trim(phone);
  if (!pattern.test(phoneval)) return false;
  return true;
}
///Kiem tra ngay thang hop le
//Dem so ky tu mark trong chuoi str
function countChar(str, mark) {
	var Count = 0;
	for(i = 0; i < str.length; i++)
		if (str.charAt(i) == mark) 
			Count++;
	return 	Count;
}
//Ham nay tra ve Ngay trong chuoi strDate duoc format thanh kieu so nguyen
function getDateToInt(strDate) {
	k = strDate.indexOf("/");			
	strDay = strDate.substring(0, k);
	return stringToInt(strDay);
}
//Ham nay tra ve Thang trong chuoi strDate duoc format thanh kieu so nguyen
function getMonthToInt(strDate) {
	i = strDate.lastIndexOf("/");
	j = strDate.lastIndexOf("/", i - 1) ;	
	strMonth = strDate.substring(j + 1, i);
	return stringToInt(strMonth);
}
//Ham nay tra ve Nam trong chuoi strDate duoc format thanh kieu so nguyen
function getYearToInt(strDate) {
	i = strDate.lastIndexOf("/");
	strYear = strDate.substring(i + 1, strDate.length);
	return stringToInt(strYear);
}
//
//Ham nay tra ve Ngay trong chuoi strDate duoc format dd/mm/yyyy H:i
function getDaytimeToInt(strDate) {
	k = strDate.indexOf("/");			
	strDay = strDate.substring(0, k);
	return stringToInt(strDay);
}
//Ham nay tra ve Thang trong chuoi strDate duoc format dd/mm/yyyy H:i
function getMonthtimeToInt(strDate) {
	i = strDate.indexOf("/");
	strMonth = strDate.substring(i + 1, i+3);
	return stringToInt(strMonth);
}
//Ham nay tra ve Nam trong chuoi strDate duoc format format dd/mm/yyyy H:i
function getYeartimeToInt(strDate) {
	i = strDate.lastIndexOf("/");
	strYear = strDate.substring(i + 1, i+5);
	return stringToInt(strYear);
}
//Ham nay tra ve Hour trong chuoi strDate duoc format format dd/mm/yyyy H:i
function getHourtimeToInt(strDate) {
	i = strDate.indexOf(":");
	strHour = strDate.substring(i-2, i);
	return stringToInt(strHour);
}
//Ham nay tra ve Minute trong chuoi strDate duoc format format dd/mm/yyyy H:i
function getMinutetimeToInt(strDate) {
	i = strDate.lastIndexOf(":");
	strMinute = strDate.substring(i+1, strDate.length);
	return stringToInt(strMinute);
}

//
function checkIntVal(val, low, high) {
	if (val <= high && val >= low) 
		return true;
	return false;
}
//
function stringToInt(str) {
	if(!stringIsNum(str))
		return 0 ;
	if(str.charAt(0) == '0') 
		return stringToInt(str.substring(1, str.length));
	else 
		if(str.length > 0) 
			return parseInt(str);
		 else 
			return (0);
}
//
function stringIsNum(val) {
	var str = new String(val);
	for (i=0;i<str.length;i++) 
		if (isNaN(parseInt(str.charAt(i))))
			return false;
	return true;
}
//Kiem tra chuoi theo chuan ton tai cua chuoi mark trong chuoi str
function checkExistVal(str, mark) {
	for(i = 0; i < str.length; i++)
		if (mark.indexOf(str.charAt(i)) < 0) 
			return false;
	return 	true;
}
// Kiem tra ngay theo chuan (dd/mm/yyyy)
function checkFormatDate(strDate, sb_year, se_year) {
	if(!checkExistVal(strDate, '1234567890/') || countChar(strDate, '/') != 2)
		return false;
	Year = getYearToInt(strDate);
	Month = getMonthToInt(strDate);
	Day = getDateToInt(strDate);
	var objDate = new Date();
	var currYear = objDate.getYear();
	if(typeof(sb_year) == 'undefined')
		sb_year = currYear - 1;
	if(typeof(se_year) == 'undefined')
		se_year = currYear + 222;
	if(!checkIntVal(Year, sb_year, se_year))
		return false;	
	if(!checkIntVal(Month, 1, 12))
		return false;	
	if(!checkIntVal(Day, 1, 31))
		return false;	
	if (Month == 4 || Month == 6 || Month == 9 || Month == 11 )
		if(Day > 30)
			return false;
	if(((Year % 4 == 0) && (Year %100 != 0)) || Year % 400 == 0) {
		if((Month == 2 ) && ( Day > 29))
			return false;
	} else
		if((Month == 2 ) && ( Day > 28))
			return false;
	return 	true;
}
// Kiem tra ngay theo chuan (dd/mm/yyyy H:i)
function checkFormatDatetime(strDate, sb_year, se_year) {
	if(!checkExistVal(strDate, '1234567890/: ') || countChar(strDate, '/') != 2 || countChar(strDate, ':') != 1 || countChar(strDate, ' ') != 1)
		return false;
	Year = getYeartimeToInt(strDate);
	Month = getMonthtimeToInt(strDate);
	Day = getDaytimeToInt(strDate);
	Hour = getHourtimeToInt(strDate);
	Minute = getMinutetimeToInt(strDate);
	var objDate = new Date();
	var currYear = objDate.getYear();
	if(typeof(sb_year) == 'undefined')
		sb_year = currYear - 1;
	if(typeof(se_year) == 'undefined')
		se_year = currYear + 222;
	if(!checkIntVal(Year, sb_year, se_year))
		return false;	
	if(!checkIntVal(Month, 1, 12))
		return false;	
	if(!checkIntVal(Day, 1, 31))
		return false;	
	if (Month == 4 || Month == 6 || Month == 9 || Month == 11 )
		if(Day > 30)
			return false;
	if(((Year % 4 == 0) && (Year %100 != 0)) || Year % 400 == 0) {
		if((Month == 2 ) && ( Day > 29))
			return false;
	} else
		if((Month == 2 ) && ( Day > 28))
			return false;
	if((Hour > 23) || ( Minute > 59)) 
		return false;
	return 	true;
}
//Kiem tra ngay bat dau va ket thuc co hop le khong
function checkCondDate(fromDate, toDate) {
	fromYear = getYearToInt(fromDate);
	fromMonth = getMonthToInt(fromDate);
	fromDay = getDateToInt(fromDate);
	toYear = getYearToInt(toDate);
	toMonth = getMonthToInt(toDate);
	toDay = getDateToInt(toDate);
	if(fromYear < toYear)
		return true;
	if(fromYear == toYear)
		if(fromMonth == toMonth) {
			if(fromDay <= toDay)
				return true;
		} else
			if(fromMonth < toMonth)
				return true;
	return false;
}
//Kiem tra ngay bat dau va ket thuc co hop le khong
function checkCondDatetime(fromDate, toDate) {
	fromYear = getYeartimeToInt(fromDate);
	fromMonth = getMonthtimeToInt(fromDate);
	fromDay = getDaytimeToInt(fromDate);
	fromHour=getHourtimeToInt(fromDate);
	fromMinute=getMinutetimeToInt(fromDate);
	toYear = getYeartimeToInt(toDate);
	toMonth = getMonthtimeToInt(toDate);
	toDay = getDaytimeToInt(toDate);
	toHour=getHourtimeToInt(toDate);
	toMinute=getMinutetimeToInt(toDate);
	if(fromYear < toYear)
		return true;
	if(fromYear == toYear)
		if(fromMonth == toMonth) {
			if(fromDay == toDay){
				if(fromHour==toHour){
					if(fromMinute<=toMinute) return true;
				}else 
					if(fromHour<toHour) return true;
			}else 
				if(fromDay < toDay)
					return true;
		} else
			if(fromMonth < toMonth)
				return true;
	return false;
}
//Ham nay kiem tra ngay nhap vao so voi ngay hien hanh
function checkDateCurrent(strDate) {
	if(!checkFormatDate(strDate))
		return false;
	inputYear = getYearToInt(strDate);
	inputMonth = getMonthToInt(strDate);
	inputDate = getDateToInt(strDate);
	thisDate = new Date();
	currentDate = thisDate.getDate();
	currentMonth = thisDate.getMonth() + 1;
	currentYear = thisDate.getYear();
	if(inputYear > currentYear)
		return true;
	if(inputYear == currentYear)
		if(currentMonth == inputMonth) {
			if(currentDate < inputDate)
				return true;
		} else
			if(currentMonth < inputMonth)
				return true;
	return false;
}
function printArticle() {
	var agt=navigator.userAgent.toLowerCase();
	if (window.print) {
		setTimeout('window.print();',200);
	}
	else if (agt.indexOf("mac") != -1) {
		alert("Press 'Cmd+p' on your keyboard to print article.");
	}
	else {
		alert("Press 'Ctrl+p' on your keyboard to print article.")
	}
}
/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
var marked_row = new Array;

function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0) 
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function
function kiemtrangay(date,month)
{
	switch(month)
	{
		case '04':
		case '06':
		case '09':
		case '11': 
			if(date>'30') return 0;
			break;
		case '02':
			if(date>'28') return 0;
			break;
	}
	return 1;
}
function kiemtrangaythangofsearch()
{
	date=searchtin.ngay.options[searchtin.ngay.selectedIndex].value;
	if(date.length<2) date="0"+date;
	month=searchtin.thang.options[searchtin.thang.selectedIndex].value;
	if(month.length<2) month="0"+month;
	year=searchtin.nam.value;
	if(!kiemtrangay(date,month))
	{
		alert("Date invalid, please select date again!");
		return;
	}
	else
	{
		searchtin.ketqua.value=year+"-"+month+"-"+date;
		if(date=="00")
		{
			searchtin.ketqua.value=year+"-"+month+"-";
			//alert(searchtin.ketqua.value);
		}
		document.searchtin.submit();
	}
}
//
/*
 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
 * Digest Algorithm, as defined in RFC 1321.
 * Copyright (C) Paul Johnston 1999 - 2000.
 * Updated by Greg Holt 2000 - 2001.
 * See http://pajhome.org.uk/site/legal.html for details.
 */

/*
 * Convert a 32-bit number to a hex string with ls-byte first
 */
var hex_chr = "0123456789abcdef";
function rhex(num)
{
  str = "";
  for(j = 0; j <= 3; j++)
    str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) +
           hex_chr.charAt((num >> (j * 8)) & 0x0F);
  return str;
}

/*
 * Convert a string to a sequence of 16-word blocks, stored as an array.
 * Append padding bits and the length, as described in the MD5 standard.
 */
function str2blks_MD5(str)
{
  nblk = ((str.length + 8) >> 6) + 1;
  blks = new Array(nblk * 16);
  for(i = 0; i < nblk * 16; i++) blks[i] = 0;
  for(i = 0; i < str.length; i++)
    blks[i >> 2] |= str.charCodeAt(i) << ((i % 4) * 8);
  blks[i >> 2] |= 0x80 << ((i % 4) * 8);
  blks[nblk * 16 - 2] = str.length * 8;
  return blks;
}

/*
 * Add integers, wrapping at 2^32. This uses 16-bit operations internally 
 * to work around bugs in some JS interpreters.
 */
function add(x, y)
{
  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  return (msw << 16) | (lsw & 0xFFFF);
}

/*
 * Bitwise rotate a 32-bit number to the left
 */
function rol(num, cnt)
{
  return (num << cnt) | (num >>> (32 - cnt));
}

/*
 * These functions implement the basic operation for each round of the
 * algorithm.
 */
function cmn(q, a, b, x, s, t)
{
  return add(rol(add(add(a, q), add(x, t)), s), b);
}
function ff(a, b, c, d, x, s, t)
{
  return cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function gg(a, b, c, d, x, s, t)
{
  return cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function hh(a, b, c, d, x, s, t)
{
  return cmn(b ^ c ^ d, a, b, x, s, t);
}
function ii(a, b, c, d, x, s, t)
{
  return cmn(c ^ (b | (~d)), a, b, x, s, t);
}

/*
 * Take a string and return the hex representation of its MD5.
 */
function MD5(str)
{
  x = str2blks_MD5(str);
  var a =  1732584193;
  var b = -271733879;
  var c = -1732584194;
  var d =  271733878;
 
  for(i = 0; i < x.length; i += 16)
  {
    var olda = a;
    var oldb = b;
    var oldc = c;
    var oldd = d;

    a = ff(a, b, c, d, x[i+ 0], 7 , -680876936);
    d = ff(d, a, b, c, x[i+ 1], 12, -389564586);
    c = ff(c, d, a, b, x[i+ 2], 17,  606105819);
    b = ff(b, c, d, a, x[i+ 3], 22, -1044525330);
    a = ff(a, b, c, d, x[i+ 4], 7 , -176418897);
    d = ff(d, a, b, c, x[i+ 5], 12,  1200080426);
    c = ff(c, d, a, b, x[i+ 6], 17, -1473231341);
    b = ff(b, c, d, a, x[i+ 7], 22, -45705983);
    a = ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
    d = ff(d, a, b, c, x[i+ 9], 12, -1958414417);
    c = ff(c, d, a, b, x[i+10], 17, -42063);
    b = ff(b, c, d, a, x[i+11], 22, -1990404162);
    a = ff(a, b, c, d, x[i+12], 7 ,  1804603682);
    d = ff(d, a, b, c, x[i+13], 12, -40341101);
    c = ff(c, d, a, b, x[i+14], 17, -1502002290);
    b = ff(b, c, d, a, x[i+15], 22,  1236535329);    

    a = gg(a, b, c, d, x[i+ 1], 5 , -165796510);
    d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
    c = gg(c, d, a, b, x[i+11], 14,  643717713);
    b = gg(b, c, d, a, x[i+ 0], 20, -373897302);
    a = gg(a, b, c, d, x[i+ 5], 5 , -701558691);
    d = gg(d, a, b, c, x[i+10], 9 ,  38016083);
    c = gg(c, d, a, b, x[i+15], 14, -660478335);
    b = gg(b, c, d, a, x[i+ 4], 20, -405537848);
    a = gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
    d = gg(d, a, b, c, x[i+14], 9 , -1019803690);
    c = gg(c, d, a, b, x[i+ 3], 14, -187363961);
    b = gg(b, c, d, a, x[i+ 8], 20,  1163531501);
    a = gg(a, b, c, d, x[i+13], 5 , -1444681467);
    d = gg(d, a, b, c, x[i+ 2], 9 , -51403784);
    c = gg(c, d, a, b, x[i+ 7], 14,  1735328473);
    b = gg(b, c, d, a, x[i+12], 20, -1926607734);
    
    a = hh(a, b, c, d, x[i+ 5], 4 , -378558);
    d = hh(d, a, b, c, x[i+ 8], 11, -2022574463);
    c = hh(c, d, a, b, x[i+11], 16,  1839030562);
    b = hh(b, c, d, a, x[i+14], 23, -35309556);
    a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
    d = hh(d, a, b, c, x[i+ 4], 11,  1272893353);
    c = hh(c, d, a, b, x[i+ 7], 16, -155497632);
    b = hh(b, c, d, a, x[i+10], 23, -1094730640);
    a = hh(a, b, c, d, x[i+13], 4 ,  681279174);
    d = hh(d, a, b, c, x[i+ 0], 11, -358537222);
    c = hh(c, d, a, b, x[i+ 3], 16, -722521979);
    b = hh(b, c, d, a, x[i+ 6], 23,  76029189);
    a = hh(a, b, c, d, x[i+ 9], 4 , -640364487);
    d = hh(d, a, b, c, x[i+12], 11, -421815835);
    c = hh(c, d, a, b, x[i+15], 16,  530742520);
    b = hh(b, c, d, a, x[i+ 2], 23, -995338651);

    a = ii(a, b, c, d, x[i+ 0], 6 , -198630844);
    d = ii(d, a, b, c, x[i+ 7], 10,  1126891415);
    c = ii(c, d, a, b, x[i+14], 15, -1416354905);
    b = ii(b, c, d, a, x[i+ 5], 21, -57434055);
    a = ii(a, b, c, d, x[i+12], 6 ,  1700485571);
    d = ii(d, a, b, c, x[i+ 3], 10, -1894986606);
    c = ii(c, d, a, b, x[i+10], 15, -1051523);
    b = ii(b, c, d, a, x[i+ 1], 21, -2054922799);
    a = ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
    d = ii(d, a, b, c, x[i+15], 10, -30611744);
    c = ii(c, d, a, b, x[i+ 6], 15, -1560198380);
    b = ii(b, c, d, a, x[i+13], 21,  1309151649);
    a = ii(a, b, c, d, x[i+ 4], 6 , -145523070);
    d = ii(d, a, b, c, x[i+11], 10, -1120210379);
    c = ii(c, d, a, b, x[i+ 2], 15,  718787259);
    b = ii(b, c, d, a, x[i+ 9], 21, -343485551);

    a = add(a, olda);
    b = add(b, oldb);
    c = add(c, oldc);
    d = add(d, oldd);
  }
  return rhex(a) + rhex(b) + rhex(c) + rhex(d);
}

function InsertImage(filename, params) {
	filename=unescape(filename);
	window.document.write('<img src="' + filename + '" ' + params + '>');
}

function InsertFlash(filename, width, height, flashvars, wmode) {
	filename=unescape(filename);
	window.document.write('<embed src="' + filename +'" menu=false quality=high ' + wmode +	 ' width="' + width + '" height="' + height + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" flashVars="' + flashvars + '" ></embed>');
}
//<script language="javascript">InsertMedia("%73%74%6f%72%65%73%2f%63%61%72%64%2f%32%30%30%37%30%32%30%31%2f%64%75%61%20%62%65%20%28%6d%69%6e%68%20%6b%68%61%6e%67%29%2e%77%6d%76","400","370","showstatusbar=1 EnableContextMenu=true autostart=true transparentAtStart=1 loop=0 showControls=true animationAtStart=true clickToPlay=0");</script>
function InsertMedia(filename, width, height, params) {
	filename=unescape(filename);
	window.document.write('<object width="' + width + '" height="' + height + '" classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,0,0" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">');
	window.document.write('<param name="filename" value="' + filename + '">');
	listparam=Array();
	if (params.length>0) listparam=params.split(" ");
	for (i=0;i<listparam.length;i++) {
		tmp=listparam[i].split("=");
		window.document.write('<param name="' + tmp[0] + '" value="' + tmp[1] + '">');
	}
	window.document.write('<embed src="' + filename + '" width="' + width + '" height="' + height + '" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"'+ params +'></embed>');
	window.document.write('</object>');
}

function nullUrl() {}
