function closeAds(targat){
	targat.style.display = 'none';
}
function showimage(selSource,imgDes){
	var PATH_IMG_MENBER_ICONS = 'http://www.extreamranchu.com/mc/img/member/icons/';
	//alert(PATH_IMG_MENBER_ICONS + selSource.options[selSource.selectedIndex].value);
	imgDes.src = PATH_IMG_MENBER_ICONS + selSource.options[selSource.selectedIndex].value;
}
function check_digit_id_card(id_card) {
	var multi_num = 13;
	var str_digit = 0;
	var result = 0;
	if(id_card.length != 13) {
		return false;
	}
	while(multi_num != 1) {
		if(id_card.charAt(str_digit) == Number.NaN) {
			return false;
		}
		result = result + id_card.charAt(str_digit)*multi_num;
		multi_num = multi_num - 1;
		str_digit = str_digit + 1;
	}

	result = result % 11;
	if(result == 0) result = 10;

	result = 11 - result;

	if(result == 10) result = 0;

	if(result == id_card.charAt(12)) {
		return true;
	} else {
		return false;
	}
}
function checkemail(value){
	var str=document.validation.emailcheck.value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
	results=true
	else{
		alert("Please input a valid email address!")
		testresults=false
	}
	return (testresults)
}
//Email validation
function validateEmail(email)
{
	// a very simple email validation checking.
	// you can add more complex email checking if it helps
	if(email.length <= 0)
	{
		return true;
	}
	var splitted = email.match("^(.+)@(.+)$");
	if(splitted == null) return false;
	if(splitted[1] != null )
	{
		var regexp_user=/^\"?[\w-_\.]*\"?$/;
		if(splitted[1].match(regexp_user) == null) return false;
	}
	if(splitted[2] != null)
	{
		var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
		if(splitted[2].match(regexp_domain) == null)
		{
			var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
			if(splitted[2].match(regexp_ip) == null) return false;
		}// if
		return true;
	}
	return false;
}
//Filter numeric
//<input id = "upd1" name = "upd1" type = "text" value = "0.00" size = "8" maxlength = "12" onBlur = "javascript:this.value = input_filterAmt (this.value, 2, 1);">
//onBlur = "javascript:this.value = input_filterAmt (this.value, 0, 0);"  0 decimal places (+)
//onBlur = "javascript:this.value = input_filterAmt (this.value, 2, 1);"  2 decimal places (+/-)
function input_filterAmt (str, dec, bNeg){ // auto-correct input - force numeric data based on params.
	var cDec = '.'; // decimal point symbol
	var bDec = 0; var val = "";
	var strf = ""; var neg = ""; var i = 0;

	if (str == "") return; round_number (parseFloat ("0"), dec);
	if (bNeg && str.charAt (i) == '-') { neg = '-'; i++; }

	for (i; i < str.length; i++)
	{
		val = str.charAt (i);
		if (val == cDec)
		{
			if (!bDec) { strf += val; bDec = 1; }
		}
		else if (val >= '0' && val <= '9')
		strf += val;
	}
	strf = (strf == "" ? 0 : neg + strf);
	return round_number (parseFloat (strf), dec);
}
//round_number
function round_number (num, dec)
{ // low-level numeric format with upward rounding at 5+
	var cDec = '.'; // decimal point symbol
	if (!(dec >= 0 && dec <= 9))
	dec = 2;
	if (isNaN (num) || num == '')
	{ // zero values are returned in proper decimal format
		var sdec = "";
		for (var i = 0; i < dec; i++)
		sdec += '0';
		return "0" + (sdec != "" ? cDec + sdec : "");
	}
	var snum = new String (num);
	var arr_num = snum.split (cDec);
	var neg = '';
	var nullify = 0;
	dec_a = arr_num.length > 1 ? arr_num[1].length : 0;
	if (dec_a <= dec)
	{ // fill decimal places with trailing zeros if necessary
		if (!dec_a)
		arr_num[1] = "";
		for (var i = 0; i < dec - dec_a; i++)
		arr_num[1] += '0';
		dec_a = dec;
	}
	// total decimal places in value before rounding and formatting
	dec_i = dec_a;
	dec_a -= dec;
	if (arr_num[0].charAt(0) == '-')
	{ // preserve negative symbol, remove from value (calculations)
		neg = '-';
		arr_num[0] = arr_num[0].substring (1, arr_num[0].length);
	}
	if (!parseInt (arr_num[0])) // case when whole value is 0
	{ // nullify a zero whole value for correct decimal point placement
		arr_num[0] = "1"; // 0 whole # would not preserve amount in calc.
		nullify = 1; // flag to remove greatest 1 portion from whole #
	}
	var whole = parseInt (arr_num[0] * Math.pow (10, arr_num[1].length));
	// remove leading zeros
	for (i = 0; i < arr_num[1].length; i++)
	if (arr_num[1].charAt (i) != '0')
	break;
	if (arr_num[1].length == i) // decimal portion blank or all zeros
	return (neg + arr_num[0] + (arr_num[1] != "" ? (cDec + arr_num[1]) : ""));
	whole += parseInt (arr_num[1].substring (i, arr_num[1].length));
	if (arr_num[1].length != dec)
	{ // round number affecting appropriate cluster of decimal places
		var diff = "";
		var str = new String (whole);
		for (i = dec_a; i > 0; i--)
		diff += str.charAt (str.length - i);
		diff = Math.pow (10, dec_a) - parseInt (diff);
		whole += ((diff <= 5 * Math.pow (10, dec_a - 1)) ? diff : 0);
	}
	str = new String (whole);
	var str_f = "";
	var j = 0;
	var k = 0;
	if (nullify)
	{
		arr_num[0] = "0"; // remove 1 from greatest decimal place (restoration)
		str = (parseInt (str.charAt(0)) - 1) + str.substring (1, str.length);
	}
	else // re-assign whole numeric portion from entire numeric string value
	arr_num[0] = str.substring (0, str.length - dec_i);
	for (i = 0; i < str.length; i++)
	{ // combine portions of decimal number (whole, fraction, sign)
		if (k - 1 > dec)
		break; // fraction termination case
		if (j == arr_num[0].length)
		{
			if (!j)
			str_f += 0;
			str_f += (dec != 0 ? cDec : ''); // insert decimal point
			--i; // backtrack one character
			k++; // signal fraction count
		}
		else // assign character by character
		str_f += str.charAt (i);
		j++;
		if (k) // fractional counter increment
		k++;
	}
	return neg + str_f;
}
function setURL()
{
	var temp = window.prompt('Please enter URL for make link','http://'); 
	if(temp) setsmile('[url]'+temp+'[/url]');
}
function setImage()
{
	var temp = window.prompt('Please enter URL of image to show in your topic','http://'); 
	if(temp) setsmile('[img]'+temp+'[/img]');
}

function setBold()
{
	var temp = window.prompt('Please enter MESSAGE for make bold font',''); 
	if(temp) setsmile('[b]'+temp+'[/b]');
}

function setItalic()
{
	var temp = window.prompt('Please enter MESSAGE for make italic font',''); 
	if(temp) setsmile('[i]'+temp+'[/i]');
}

function setUnderline()
{
	var temp = window.prompt('Please enter MESSAGE for make underlind',''); 
	if(temp) setsmile('[u]'+temp+'[/u]');
}

function setColor(color,name)
{
	var temp = window.prompt('Please enter MESSAGE for make font color :'+name,''); 
	if(temp) setsmile('[color='+color+']'+temp+'[/color]');
}
function setsmile(what)
{
	document.form_q.desc.value = document.form_q.elements.desc.value+" "+what;
	document.form_q.desc.focus();
}
function over(td)
{
	td.className = 'smiley_bg_hover Hand' ;
}

function out(td)
{
	td.className = 'smiley_bg Hand' ;
}
function wb_over(c,td)
{
	td.className = c ;
}

function wb_out(oc,td)
{
	td.className = oc ;
}

/*popup windows fit size*/
function PopupPic(imgSrc) { 
	var newImg = new Image();
	newImg.src = imgSrc;
	var height = newImg.height;
	var width = newImg.width;
	//window.open( "popup.html?"+imgSrc, "","resizable=0,HEIGHT=10,WIDTH=10"); 
	if(navigator.appName=="Netscape")
	//window.open( "popup.html?"+imgSrc, ""); 
	window.open( imgSrc, ""); 
	else
	//window.open( "popup.html?"+imgSrc, "","resizable=0,HEIGHT=" + height + ",WIDTH=" + width); 
	window.open( imgSrc, "","resizable=0,HEIGHT=" + height + ",WIDTH=" + width); 
} 