function popwin(lokasi,feat) {
	var wtgl;
	wtgl=window.open(lokasi,'',feat+', toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes');
	return;
}

function popwin2(lokasi,feat) {
	var wtgl;
	wtgl=window.open(lokasi,'',feat+', toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no');
	return;
}

function popwin3(lokasi,feat) {
	var wtgl;
	wtgl=window.open(lokasi,'',feat+', toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes');
	return;
}

function funcDetail(username) {
	popwin('detail.php?username='+username, 'width=420, height=560');
}

function funcProfile(username) {
	popwin('shortprofile.php?username='+username, 'width=420, height=450');
}

function funcMessage(username) {
	popwin('message.php?username='+username, 'width=420, height=450');
}

function funcOpenNewWindow(filename,wWidth,wHeight) {
	popwin(filename, 'width='+wWidth+', height='+wHeight);
}

function funcViewPhoto(username) {
	popwin('view_photo.php?id='+username, 'width=480, height=560');
}

function funcViewPhoto2(username,membertype) {
	if (membertype == '2') {
		popwin('view_photo.php?id='+username, 'width=480, height=560');
	} else {
		alert('HANYA UNTUK GOLD MEMBER!\nGold Member dapat melihat foto ukuran sebenarnya / foto lainnya.');
	}
}

function funcAdminViewProfile(username) {
	popwin('user_profile.php?username='+username, 'width=380, height=520');
}

function funcAdminViewPhoto(username) {
	popwin('user_photo.php?id='+username, 'width=480, height=560');
}

function funcHotlist(hotuser) {
	popwin2('add_hotlist.php?hotuser='+hotuser, 'width=350, height=100');
}

function isEmail(emailAddress) {
	var result;
	var re = /^[\_\-\.0-9a-zA-Z]+\@([0-9a-zA-Z][0-9a-zA-Z]+\.)+[a-zA-Z]{2,4}$/;
	var r = emailAddress.match(re);
	result = ((r != null) ? true : false);
	return(result);
}

function isAlphanumeric(theString) {
	var result;
	var re1 = /[A-Za-z0-9_]{3,}/;
	var re2 = /[^A-Za-z0-9_]/;
	var r1 = theString.match(re1);
	var r2 = theString.match(re2);
	result = ((r1 == null) ? false : true) && ((r2 == null) ? true : false);
	return(result);
}

function isNumeric(theString) {
	var result;
	var re1 = /[0-9]{2,}/;
	var re2 = /[^0-9]/;
	var r1 = theString.match(re1);
	var r2 = theString.match(re2);
	result = ((r1 == null) ? false : true) && ((r2 == null) ? true : false);
	return(result);
}

function isNumeric2(theString) {
	var result;
	var re1 = /[0-9+-]{5,}/;
	var re2 = /[^0-9+-]/;
	var r1 = theString.match(re1);
	var r2 = theString.match(re2);
	result = ((r1 == null) ? false : true) && ((r2 == null) ? true : false);
	return(result);
}

function isNumeric3(theString) {
	var result;
	var re1 = /[0-9]{1,}/;
	var re2 = /[^0-9]/;
	var r1 = theString.match(re1);
	var r2 = theString.match(re2);
	result = ((r1 == null) ? false : true) && ((r2 == null) ? true : false);
	return(result);
}

function isNumeric4(theString) {
	var result;
	var re1 = /[0-9]{4,}/;
	var re2 = /[^0-9]/;
	var r1 = theString.match(re1);
	var r2 = theString.match(re2);
	result = ((r1 == null) ? false : true) && ((r2 == null) ? true : false);
	return(result);
}

function isNumeric5(theString) {
	var result;
	var re1 = /[0-9.]{1,}/;
	var re2 = /[^0-9.]/;
	var r1 = theString.match(re1);
	var r2 = theString.match(re2);
	result = ((r1 == null) ? false : true) && ((r2 == null) ? true : false);
	return(result);
}

function FineWordLength(theString,maxLength) {
	var nString = theString.length;
	var arraySentence = theString.split('\n');
	var nSentence = arraySentence.length;
	
	if (nSentence > 0) {
		for (i=0; i<=(nSentence-1); i++) {
			var arrayWord;
			var nWord;
			arrayWord = arraySentence[i].split(' ');
			nWord = arrayWord.length;
			for (j=0; j<=(nWord-1); j++) {
				if (arrayWord[j].length > maxLength) {
					return arrayWord[j];
				}
			}
		}
	}
	return "";
}

function howManyWords(theString) {
	var nString = theString.length;
	var arraySentence = theString.split('\n');
	var nSentence = arraySentence.length;
	var result = 0;
	
	if (nSentence > 0) {
		for (i=0; i<=(nSentence-1); i++) {
			if (arraySentence[i].length > 1) {
				result = result + arraySentence[i].split(' ').length;
			}
		}
	}
	return result;
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function trim(str) {
	return str.replace(/^\s+|\s+$/g,'');
}
