//<![CDATA[
function adjustFrame() {
	if (document.getElementById('column_center') && document.getElementById('column_left')) {
		document.getElementById('column_center').style.height = "auto";
		
		var hL = document.getElementById('column_left').offsetHeight;
		var hC = document.getElementById('column_center').offsetHeight + 40;
		var nC = 0;
		
		if (hL > hC) nC = hL;
		if (hC > nC) nC = hC;
		
		document.getElementById('column_center').style.height = nC+"px";
	}
}

function isUsername(string,minlength,maxlength) {
	var valid = '/^[a-z][-a-z0-9_]{'+(minlength-1)+','+(maxlength-1)+'}$/';
	
	if (!minlength) minlength = 1;
	if (!maxlength) maxlength = 255;
	
	var result = (valid.test(string) && (string.length >= minlength) && (string.length <= maxlength));
	
	return result;
}

function isEmail(string) {
   if (!string) return false;
   if ((string.indexOf(".") < 1) && (string.indexOf("@") < 1)) return false;
   var iChars = "*|,\":<>[]{}`\';()&$#%";

   for (var i = 0; i < string.length; i++) {
      if (iChars.indexOf(string.charAt(i)) != -1)
         return false;
   }
   return true;
}

function isAlphaNumeric(string) {
   if (!string) return false;
   if (string == " ") return false;
   
   var iChars = "*|,\":<>[]{}`\';()@&$#%";

   for (var i = 0; i < string.length; i++) {
      if (iChars.indexOf(string.charAt(i)) != -1)
         return false;
   }
   return true;
}

// change button style
function selOn(ctrl) {
	ctrl.style.cursor = 'pointer';
	ctrl.style.backgroundColor = 'ButtonFace';
	ctrl.style.borderColor = 'ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight';
}

function selOff(ctrl) {
	ctrl.style.cursor = 'pointer';
	ctrl.style.borderColor = 'ButtonFace';  
	ctrl.style.backgroundColor = 'transparent';
}

function selDown(ctrl) {
	ctrl.style.cursor = 'pointer';
	ctrl.style.borderColor = 'ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow';
	ctrl.style.backgroundColor = 'ButtonFace';
}

//	layout functions
function displayCurrentDate() {
	var day = Array('Minggu','Senin','Selasa','Rabu','Kamis','Jumat','Sabtu');
	var month = Array('Januari','Februari','Maret','April','Mei','Juni','Juli','Agustus','September','Oktober','November','Desember');
	
	var now = new Date();
	var dw = now.getDay();
	var dn = now.getDate();
	var mn = now.getMonth();
	var yn = now.getFullYear();
	
	display = day[dw] + ',&nbsp;' + dn + '&nbsp;' + month[mn] + ',&nbsp;' + yn;
	document.writeln(display);
}

function getURL(url,query) {
	window.location = url+'?'+query;
}

function open_window(s_url, s_name, s_prop) {
  if (!(s_prop)) s_prop = 'dependent=1,resizable=yes,scrollbars=yes,width=400,height=500'
  window.open(s_url, s_name, s_prop)
}

function copy_to_parent(s_elm, s_val) {
  eval('window.opener.frm.' + s_elm + ".value = '" + s_val + "'");
}

function confirm_action(target, vs_dialog, vs_href) {
	if (confirm(vs_dialog)) {
		target.window.location.href = vs_href;
	}
	return true;
}

function popWin(code) {
	var winName = 'popup';
	var features = 'resizable=yes,scrollbars=yes,toolbar=no';
	var settings = 'height=200';
	settings += ',width=200,';
	settings += features;
	
	var theURL = 'popup.php?img=';
	theURL += code;
	
	MM_openBrWindow(theURL,winName,settings);
}


function NewWindow(mypage,myname,w,h,scroll){
var win = null;
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}


function viewPic(img)
{ picfile=new Image(); picfile.src=(img); fileCheck(img); }

function fileCheck(img)
{ if((picfile.width!=0)&&(picfile.height!=0))
	{ makeWindow(img); }
	else { funzione="fileCheck('"+img+"')"; intervallo=setTimeout(funzione,50); }
}

function makeWindow(img)
{ ht=picfile.height+20; wd=picfile.width+20;
  var args="height="+ht+",innerHeight="+ht;
	args+=",width="+wd+",innerWidth="+wd;
	if (window.screen)
	{ var avht=screen.availHeight; var avwd=screen.availWidth;
		var xcen=(avwd-wd)/2; var ycen=(avht-ht)/2;
		args+=",left="+xcen+",screenX="+xcen;
		args+=",top="+ycen+",screenY="+ycen+",resizable=1,scrollbars=0"; 
	}
  return window.open(img, '', args); 
}

function enviar(url){
    window.opener.location=url;
 }
//]]>