var uagent=navigator.userAgent.toLowerCase();
var isIE, isGecko, isOpera, isSafari, isKonqueror, isWin, isMac, uaVers;
	isIE=(uagent.indexOf("msie")!=-1 && document.all);
	isGecko = (uagent.indexOf("gecko") != -1);
	isOpera = (uagent.indexOf("opera") !=-1); 
	isSafari = (uagent.indexOf("safari") != -1);
	isKonqueror = (uagent.indexOf("konqueror") != -1);
	isWin    =  ( (uagent.indexOf("win") != -1) || (uagent.indexOf("16bit") !=- 1) );
	isMac    = ( (uagent.indexOf("mac") != -1) || (navigator.vendor == "Apple Computer, Inc.") );
	uaVers   = parseInt(navigator.appVersion);
var showpage = lang_g['g_intm'];
var current_picture = 'moderatethumb';

function multi_page_jump( url_bit, totalposts, perpage ) {
	pages = 1;
	cur_pp = current_page;
	curpage  = 1;
	if ( totalposts % perpage == 0 ) {
		pages = totalposts / perpage;
	} else 	{
		pages = Math.ceil( totalposts / perpage );
	}
	msg = showpage + pages;
	if ( cur_pp > 0 ) {
		curpage = cur_pp / perpage;
		curpage = curpage -1;
	}
	show_page = 1;
	if ( curpage < pages ) {
		show_page = curpage + 1;
	}
	if ( curpage >= pages ) {
		show_page = curpage - 1;
	} else 	{
 		show_page = curpage + 1;
 	}
	userPage = prompt( msg, show_page );
	if ( userPage > 0  ) {
		if ( userPage < 1 ) {
			userPage = 1;
		}
		if ( userPage > pages ) { 
			userPage = pages;
		}
		if ( userPage == 1 ) {
			start = 0;
		} else {
			start = (userPage - 1) * perpage;
		}
		window.location = url_bit + "&pp=" + start;
	}
}
function showHide(id1, id2) {
	if (id1 != '') toggleview(id1);
	if (id2 != '') toggleview(id2);
}
function my_getbyid(id) {
	itm = null;
	if (document.getElementById) {
		itm = document.getElementById(id);
	} else if (document.all)	{
		itm = document.all[id];
	} else if (document.layers) {
		itm = document.layers[id];
	}
	return itm;
}
function toggleview(id) {
	if ( ! id ) return;
	if ( itm = my_getbyid(id) ) {
		if (itm.style.display == "none") {
			my_show_div(itm);
		} else {
			my_hide_div(itm);
		}
	}
}
function my_hide_div(id) {
	if ( ! id ) return;	
	id.style.display = "none";
}
function my_show_div(id) {
	if ( ! id ) return;
	id.style.display = "";
}
function change_cell_color( id, cl ) {
	itm = my_getbyid(id);
	if ( itm )	{
		itm.className = cl;
	}
}
function PopUp(url, name, width,height,center,resize,scroll,posleft,postop) {
	showx = "";
	showy = "";
	if (posleft != 0) { X = posleft }
	if (postop  != 0) { Y = postop  }
	if (!scroll) { scroll = 1 }
	if (!resize) { resize = 1 }
	if ((parseInt (navigator.appVersion) >= 4 ) && (center)) {
		X = (screen.width  - width ) / 2;
		Y = (screen.height - height) / 2;
	}
	if ( X > 0 )	{ showx = ',left='+X; }
	if ( Y > 0 )	{ showy = ',top='+Y; }
	if (scroll != 0) { scroll = 1 }
	var Win = window.open( url, name, 'width='+width+',height='+height+ showx + showy + ',resizable='+resize+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no');
}
function stacksize(thearray) {
	for (i = 0 ; i < thearray.length; i++ ) {
		if ( (thearray[i] == "") || (thearray[i] == null) || (thearray == 'undefined') ) return i;
	}
	return thearray.length;
}
function pushstack(thearray, newval) {
	arraysize = stacksize(thearray);
	thearray[arraysize] = newval;
}
function popstack(thearray) {
	arraysize = stacksize(thearray);
	theval = thearray[arraysize - 1];
	delete thearray[arraysize - 1];
	return theval;
}
function CheckAll(fmobj) {
	for (var i=0;i<fmobj.elements.length;i++) {
		var e = fmobj.elements[i];
		if ((e.name != 'allbox') && (e.type=='checkbox') && (!e.disabled)) {
			e.checked = fmobj.allbox.checked;
		}
	}
}
function HighlightAll(str) {
    if (document.all){
        var rng = document.body.createTextRange();
        rng.moveToElementText(str);
        rng.scrollIntoView();
        rng.select();
        rng.execCommand("Copy");
        rng.collapse(false);
		setTimeout("window.status=''",1800)
    }
}
function redirlocate(object) {
	if(object.options[object.selectedIndex].value != '') {
		window.location = (object.options[object.selectedIndex].value);
	}
}

function SelectTag(){
	var target = my_getbyid('selectall').checked;
	if (target == true)
	{
		SelectAll();
	} else {
		NoneAll();
	}
}
function SelectAll(){
	var rows = document.modform.getElementsByTagName('tr');
	var unique_id;
	var marked_row = new Array;
    var checkbox;
	for ( var i = 0; i < rows.length; i++ ) {
        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
                if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                    rows[i].className += ' marked';
                    marked_row[unique_id] = true;
                }
            }
	    }
	}
}
function NoneAll(){
	var rows = document.modform.getElementsByTagName('tr');
    var unique_id;
    var checkbox;
	var marked_row = new Array;
	for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;
            rows[i].className = rows[i].className.replace(' marked', '');
            marked_row[unique_id] = false;
        }
	}

	return true;
}
function check_e_client(imgurl){
	var email = my_getbyid("email").value;
	var emailconfirm = my_getbyid("emailconfirm").value;
	if (email != emailconfirm) {
		my_getbyid("isok_email_firm").innerHTML = "<span style='color:red;position:absolute;'><img src='./images/"+imgurl+"/note_error.gif' /> "+lang_g['g_check_email']+"</span>";
	} else {
		my_getbyid("isok_email_firm").innerHTML = "<span style='color:red;position:absolute;'><img src='./images/"+imgurl+"/note_ok.gif' /></span>";
	}
}
function check_p_client(imgurl){
	var password = my_getbyid('password').value;
	var passwordconfirm = my_getbyid('passwordconfirm').value;
	if (password != passwordconfirm) {
		my_getbyid("isok_password").innerHTML = "<span style='color:red;position:absolute;'><img src='./images/"+imgurl+"/note_error.gif' /> "+lang_g['g_check_password']+"</span>";
	} else {
		my_getbyid("isok_password").innerHTML = "<span style='color:red;position:absolute;'><img src='./images/"+imgurl+"/note_ok.gif' /></span>";
	}
}
function calculate_byte( sTargetStr ) { 
	var sTmpStr, sTmpChar; 
	var nOriginLen = 0; 
	var nStrLength = 0; 

	sTmpStr = new String(sTargetStr); 
	nOriginLen = sTmpStr.length; 

		for ( var i=0 ; i < nOriginLen ; i++ ) { 
		sTmpChar = sTmpStr.charAt(i); 
			if (escape(sTmpChar).length > 4) { 
			nStrLength += 2; 
			} else if (sTmpChar!='\r') { 
			nStrLength ++; 
			} 
		} 
	return nStrLength; 
}

function select_picturesize(selected_img) {
	if (selected_img == current_picture)
	{
		return;
	} else {
		showHide(selected_img+'_img', current_picture+'_img');
		my_getbyid(selected_img).style.backgroundColor  = '#f6f6f6';
		my_getbyid(selected_img).style.fontSize = '14px';
		my_getbyid(selected_img).style.fontWeight = 'bold';
		my_getbyid(current_picture).style.backgroundColor  = '';
		my_getbyid(current_picture).style.fontSize = '';
		my_getbyid(current_picture).style.fontWeight = '';
		current_picture = selected_img;
	}
}
