<!--
// fungsi untuk melakukan on mouse over image
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function launch_url(url, windowname, width, height)
{
	var remote = window.open(url, windowname, 'toolbar=yes, status=yes, scrollbars=yes, resizable=yes, width=' + width + ', height=' + height);
	if (remote == null)
		remote.opener = window;
	remote.opener.name = 'center';
	remote.focus();
}

// fungsi subscribe newsletter
function do_submit_newsletter()
{
	
	var obj = document.form_newsletter;
	var msg = '';

	if (obj.txt_user_email.value.length == 0)
	{
		msg += '\n:: Please enter user email';
	}

	if (msg != '')
	{
		window.alert('Information' + msg);
	}
	else
	{
		alert(obj.web_path);
		open_popup_window(obj.web_path.value+'newsletter.php?em='+obj.txt_user_email.value,'newsletter','640','480');
	}
}

/*************************************************************************/
// fungsi user login
function do_user_login()
{
	
	var obj = document.form_login;
	var msg = '';

	if (obj.txt_user_name.value.length == 0)
	{
		msg += '\n:: Please enter user id';
	}

	if (obj.txt_user_password.value.length == 0)
	{
		msg += '\n:: Please enter password';
	}

	if (msg != '')
	{
		window.alert('Information' + msg);
	}
	else
	{
		obj.action = 'login_resp.php';
		obj.submit();
	}
}

// fungsi user login nsp1212
function do_user_login_nsp1212()
{
	
	var obj = document.form_login;
	var msg = '';

	if (obj.txt_user_name.value.length == 0)
	{
		msg += '\n:: Please enter user id';
	}

	if (obj.txt_user_password.value.length == 0)
	{
		msg += '\n:: Please enter password';
	}

	if (msg != '')
	{
		window.alert('Information' + msg);
	}
	else
	{
		obj.action = 'login_resp_nsp1212.php';
		obj.submit();
	}
}

// fungsi register account baru
function do_register_account(url_prefix)
{
	window.opener.location.href = url_prefix + 'beforelogin.php';
	window.close();
}

function onEnter(value){
		if (window.event.keyCode==13){

			mapping_search(value,'nsp');
			
			return true;
		} 

		return false;

}

function onEnterHeader(value){
		if (window.event.keyCode==13){

			mapping_search_header(value,'nsp');
			
			return true;
		} 

		return false;

}

// fungsi open popup window
function open_popup_window(url,windowname,width,height)
{
	var remote = window.open(url, windowname, 'toolbar=yes, status=yes, resizable=yes, scrollbars=yes, width=' + width + ', height=' + height);
	if (remote == null)
		remote.opener = window;
	remote.opener.name = 'center';
	remote.focus();
}

function searchdownload(paramtype)
{
	var obj = document.form_search_new;
	if (paramtype == 'src'){
		obj.action = 'download_nsp.php?sec=nsc&k=' + obj.txt_keyword.value + '&st=1';	
	}
	else{
		obj.action = 'download_nsp.php?sec=cat&ct=' + obj.txt_category.value + '&sb=' + obj.txt_sort_by.value + '&st=1';
	}	
	obj.submit();
}

function searchdownload_event(paramtype)
{
	var obj = document.form_search_new;
	if (paramtype == 'src'){
		obj.action = 'download_nsp.php?sec=unik&k=' + obj.txt_keyword.value + '&st=1';	
	}
	else{
		obj.action = 'download_nsp.php?sec=unik&ct=' + obj.txt_category.value + '&sb=' + obj.txt_sort_by.value + '&st=1';
	}	
	obj.submit();
}

function searchdownload_idd_as(paramtype)
{
	var obj = document.form_search_new;
	if (paramtype == 'src'){
		obj.action = 'download_idd.php?sec=as&k=' + obj.txt_keyword.value + '&st=1';	
	}
	else{
		obj.action = 'download_idd.php?sec=as&ct=' + obj.txt_category.value + '&sb=' + obj.txt_sort_by.value + '&st=1';
	}	
	obj.submit();
}

function searchdownload_voip_tb2(paramtype)
{
	var obj = document.form_search_new;
	if (paramtype == 'src'){
		obj.action = 'download_voip2.php?sec=tb&k=' + obj.txt_keyword.value + '&st=1';	
	}
	else{
		obj.action = 'download_voip2.php?sec=tb&ct=' + obj.txt_category.value + '&sb=' + obj.txt_sort_by.value + '&st=1';
	}	
	obj.submit();
}

function searchdownload_voip_sbs2(paramtype)
{
	var obj = document.form_search_new;
	if (paramtype == 'src'){
		obj.action = 'download_voip2.php?sec=sbs2&k=' + obj.txt_keyword.value + '&st=1';	
	}
	else{
		obj.action = 'download_voip2.php?sec=sbs2&ct=' + obj.txt_category.value + '&sb=' + obj.txt_sort_by.value + '&st=1';
	}	
	obj.submit();
}

function searchdownload_voip_tb(paramtype)
{
	var obj = document.form_search_new;
	if (paramtype == 'src'){
		obj.action = 'download_voip.php?sec=tb&k=' + obj.txt_keyword.value + '&st=1';	
	}
	else{
		obj.action = 'download_voip.php?sec=tb&ct=' + obj.txt_category.value + '&sb=' + obj.txt_sort_by.value + '&st=1';
	}	
	obj.submit();
}

function searchdownload_voip_db(paramtype)
{
	var obj = document.form_search_new;
	if (paramtype == 'src'){
		obj.action = 'download_voip.php?sec=db&k=' + obj.txt_keyword.value + '&st=1';	
	}
	else{
		obj.action = 'download_voip.php?sec=db&ct=' + obj.txt_category.value + '&sb=' + obj.txt_sort_by.value + '&st=1';
	}	
	obj.submit();
}

function searchdownload_voip_sb(paramtype)
{
	var obj = document.form_search_new;
	if (paramtype == 'src'){
		obj.action = 'download_voip.php?sec=sb&k=' + obj.txt_keyword.value + '&st=1';	
	}
	else{
		obj.action = 'download_voip.php?sec=sb&ct=' + obj.txt_category.value + '&sb=' + obj.txt_sort_by.value + '&st=1';
	}	
	obj.submit();
}

function searchdownload_voip_ve(paramtype)
{
	var obj = document.form_search_new;
	if (paramtype == 'src'){
		obj.action = 'download_voip.php?sec=ve&k=' + obj.txt_keyword.value + '&st=1';	
	}
	else{
		obj.action = 'download_voip.php?sec=ve&ct=' + obj.txt_category.value + '&sb=' + obj.txt_sort_by.value + '&st=1';
	}	
	obj.submit();
}

// fungsi mapping search header
function mapping_search_header(url_prefix,section)
{
	var obj = document.form_search;
	switch(section)
	{
		case 'nsp':
			obj.action = url_prefix + 'download/download_nsp1212.php?sec=nsc&k=' + obj.txt_keyword.value + '&st=1';
			break;
		default:
			obj.action = url_prefix + 'search.php?k=' + obj.txt_keyword.value + '&st=1';
			break;
	}
	obj.submit();
}

// fungsi mapping search
function mapping_search(url_prefix,section)
{
	var obj = document.form_search_new;
	switch(section)
	{
		case 'nsp':
			obj.action = url_prefix + 'download/index.php?id=ZG93bmxvYWQtNA==&sc_id=4&k=' + obj.txt_keyword.value + '&st=1';
			break;
		default:
			obj.action = url_prefix + 'download/index.php?id=ZG93bmxvYWQtNA==&sc_id=4&k=' + obj.txt_keyword.value + '&st=1';
			break;
	}
	obj.submit();
}

// fungsi mapping phone brand setting
function mapping_phone_brand_setting(url, query_string)
{
	var obj = document.form_setting;
	
	if (obj.txt_brand.value.length > 0 && obj.txt_brand.value != '' && obj.txt_brand.value != '0')
	{
		if (obj.chk3G.checked){
			window.location.href = url + '?' + query_string + '&brand=' + obj.txt_brand.value + '&serv=3G';
		}else{
			window.location.href = url + '?' + query_string + '&brand=' + obj.txt_brand.value;
		}
	}else{
		if (obj.chk3G.checked){
			window.location.href = url + '?serv=3G';
		}else{
			window.location.href = url;	
		}
	}
		
}

// fungsi mapping phone brand setting with 3G Compatible
function mapping_phone_brand_3G(url, query_string)
{
	mapping_phone_brand_setting(url, query_string);
}

// fungsi mapping phone type setting
function mapping_phone_type_setting(url, query_string)
{
	var obj = document.form_setting;
	var msg = '';

	if (obj.txt_brand.value.length == 0)
	{
		msg += '\n:: Please select phone brand';
	}

	if (obj.txt_type.value.length == 0)
	{
		msg += '\n:: Please select phone type';
	}

	if (msg != '')
	{
		window.alert('Information:' + msg);
	}
	else
	{
		window.location.href = url + '?' + query_string + '&brand=' + obj.txt_brand.value + '&type=' + obj.txt_type.value;;
	}
}

// fungsi navigasi rbt category
function go_navigate_rbt_category()
{
	var obj = document.form_rbt_category;
	var msg = '';

	obj.action = obj.txt_path.value + obj.txt_group.value + '/index.php?id=' + obj.txt_id.value + '&sc_id=' + obj.txt_section.value + '&ct=' + obj.txt_category.value + '&sb=' + obj.txt_sort_by.value;
	obj.submit();
}



//Untuk mendeteksi penekanan tombol enter pada suatu filed dan melakukan aksi yang diinginkan
function detectEnter(eventObj, procName){
	var keyCode
	if (document.all){
		keyCode = eventObj.keyCode ;
	}else{
		keyCode = eventObj.which ;
	}
	if (keyCode == 13){
		eval(procName) ;
	}
}

function checkPass(){
	var obj = document.formPass ;
	var msg = "";
	if(obj.oldPass.value == "") {
		msg= "Silakan isi Old Password";
		obj.oldPass.focus();
	} else
	if(obj.newPass1.value == "") {
		msg= "Silakan isi New Password";
		obj.newPass1.focus();
	} else
	if(obj.newPass2.value == "") {
		msg= "Silahkan isi ReType New Password";
		obj.newPass2.focus();
	} else
	if(obj.newPass1.value!=obj.newPass2.value){
		msg= "New Password dengan ReType New Password harus sama";
		obj.newPass1.select();
	}
	if (msg != ""){
		msg = msg ;
		window.alert(msg) ;
	}
	else{

		obj.action = "update_pass.php";
		obj.submit() ;
	}
}

function checkProfile(){
	var obj = document.formProfile ;
	obj.action = "update_profile.php";
	obj.submit() ;
}

function checkStateProfile(){
	var obj = document.formProfile ;
	if(obj.action == ""){
		return false;
	}
}

function checkStatePass(){
	var obj = document.formPass ;
	if(obj.action == ""){
		return false;
	}
}

/*************************************************************************/
function trim(item){
	  var tmp = "";
	  var item_length = item.value.length;
	  var item_length_minus_1 = item.value.length - 1;
	  for (index = 0; index < item_length; index++)
	  {
		if (item.value.charAt(index) != ' ')
		{
		  tmp += item.value.charAt(index);
		}
		else
		{
		  if (tmp.length > 0)
		  {
			if ((item.value.charAt(index+1) != ' ') && (index != item_length_minus_1))
			{
			  tmp += item.value.charAt(index);
			}
		  }
		}
	  }
	  return (tmp) ;
	}

function checkInput(){
	var obj = document.formInput;
	var msg = "" ;
	if (trim(obj.select) == ""){
		msg = msg + "\n- Please choose your Phone Model" ;
	}
		if (msg != ""){
		msg = "Alert list :" + msg ;
		window.alert(msg) ;
	}
	else{
		obj.action = 'kirim.php';
		obj.submit() ;
	}
}


/*********************************MMB****************************************/
function checkInputMMBSave() {	
	var limit = 115;
	missinginfo = "";
	if (document.fmycontent.sADN.value == "") {
		missinginfo += "\n     -  ADN";
	}
	if (document.fmycontent.keyword1.value == "") {
		missinginfo += "\n     -  Keyword I";
	}
	if (document.fmycontent.content.value == "") {
		missinginfo += "\n     -  Content Message";
	}
	if(document.fmycontent.content.value.length > limit) {
     	alert('Too much characters in the content box! Max 115 characters');
     	document.fmycontent.content.focus();
     	return false; }	
	if (missinginfo != "") {
		missinginfo ="Please fill in this field below :\n" +
		missinginfo + "\n\nPlease re-enter and submit again!";
		alert(missinginfo);
		//return false;
	}
	else 
	{
	document.fmycontent.action = 'download_mmb_save.php';
	document.fmycontent.submit();
	}
}

function checkInputMMBUpdate() {	
	var limit = 115;
	missinginfo = "";
	if (document.fmycontent.sADN.value == "") {
		missinginfo += "\n     -  ADN";
	}
	if (document.fmycontent.keyword1.value == "") {
		missinginfo += "\n     -  Keyword I";
	}
	if (document.fmycontent.content.value == "") {
		missinginfo += "\n     -  Content Message";
	}
	if(document.fmycontent.content.value.length > limit) {
     	alert('Too much characters in the content box! Max 115 characters');
     	document.fmycontent.content.focus();
     	return false; }	
	if (missinginfo != "") {
		missinginfo ="Please fill in this field below :\n" +
		missinginfo + "\n\nPlease re-enter and submit again!";
		alert(missinginfo);
		//return false;
	}
	else 
	{
	document.fmycontent.action = 'download_mmb_update.php';
	document.fmycontent.submit();
	}
}

function checkState(){
	var obj = document.fmycontent ;
	if(obj.action == ""){
		return false;
	}
}

function update() {
	var old = document.fmycontent.counter.value;
	document.fmycontent.counter.value=document.fmycontent.content.value.length;
	if(document.fmycontent.counter.value > limit && old <= limit) {
		alert('Too much characters in the content box! Max 115 characters');
		if(document.styleSheets) {
			document.fmycontent.counter.style.fontWeight = 'bold';
			document.fmycontent.counter.style.color = '#ff0000'; 
		} 
	}else if(document.fmycontent.counter.value <= limit && old > limit && document.styleSheets ) {
		document.fmycontent.counter.style.fontWeight = 'normal';
		document.fmycontent.counter.style.color = '#000000'; 
	} 
}

function confirmDelete(){
	if(confirm('Are you sure to delete?')==1){
		return true; 
	} 
	return false;
}
//-->
