// JavaScript Document
function getXml(){
if(window.ActiveXObject){
	return new ActiveXObject('Microsoft.XMLHTTP');
}else if(window.XMLHttpRequest){
	return new XMLHttpRequest();
}else alert('Can not create XMlhttpRequest');
}
var xml=getXml();
var timestamp = new Date();
function createRequest(elmID, page){
	//document.getElementById('party_tab1').style.background='url(images/tab2_01.jpg) bottom no-repeat;'; 
	var obj=document.getElementById(elmID);
	obj.innerHTML='<img src="images/lbloading.gif" align="absmiddle" /> loading, please wait...';
	if(xml.readyState==0 || xml.readyState==4){
		xml.open('GET',page,true);
		xml.onreadystatechange=function(){
			if(xml.readyState==4 && xml.status==200){
				obj.innerHTML=xml.responseText;
			}
		}
		xml.send(null);
	}
}
var xhtml = getXmlHttpRequestObject();
function showUpdateX(pi){
	document.getElementById('contentx').innerHTML='<div align="center"><img src="images/lbloading.gif" align="absmiddle" /> loading, please wait...</div>';
	//doRequest('get', 'include/customer/get_profile.php?ui='+pi, 'text', 'content_max');
	$.ajax({
		url:'/administration/include/customer/get_profile.php?ui='+pi,
		cache:false,
		success:function(data){
			$("#content_max").html(data);
		}
	});
}
function getEmployeX(pi){
	//var pi=document.getElementById('cus_id_xxx').innerHTML;
	document.getElementById('contentx').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="100" align="center" valign="middle"><img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" /></td>' +
		'</tr>' +
		' </table>';
	document.getElementById('content2').innerHTML='';
	document.getElementById('tab').style.background='url(images/tab/tab_02.jpg) left bottom no-repeat';
	doRequest('get','include/customer/get_employe.php?pi='+pi,'text','contentx');
}
function getCarrierX(){
	document.getElementById('tab').style.background='url(images/tab/tab_03.jpg) left bottom no-repeat';
	var pi=document.getElementById('cus_id_xxx').innerHTML;
	document.getElementById('content2').innerHTML='';
	document.getElementById('contentx').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="100" align="center" valign="middle"><img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" /></td>' +
		'</tr>' +
		' </table>';
	doRequest('get','include/customer/get_carrier.php?pi='+pi,'text','contentx');
}
function getAgentX(){
	var pi=document.getElementById('cus_id_xxx').innerHTML;
	document.getElementById('content2').innerHTML='';
	document.getElementById('tab').style.background='url(images/tab/tab_04.jpg) left bottom no-repeat';
	document.getElementById('contentx').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="100" align="center" valign="middle"><img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" /></td>' +
		'</tr>' +
		' </table>';
	doRequest('get','include/customer/get_agent.php?pi='+pi,'text','contentx');
}

function doUpdateX(){
		if(!validateCustomerRequiredField()){
			return false;
		}
		var gender='';
		if(document.form_prof.gender[0].checked){
		gender=document.form_prof.gender[0].value;	
		}else if(document.form_prof.gender[1].checked){
			gender=document.form_prof.gender[1].value;
		}
		var name=document.getElementById('name').value+'~'+document.getElementById('last_name').value;
		var param = 'party_id=' + document.getElementById('party_id').value;
		if ($("input[name='lowFull']:checked").val() == '1') {
			param += '&company=' + escape(document.getElementById('company').value);
		}else{
			param += '&company=' + escape(document.getElementById('underName').value);
		}
		param +='&name='+escape(name);
		
		param +='&contact_mech_mail='+document.getElementById('email_id').value;
		param +='&email='+document.getElementById('email').value;
		param +='&b_state='+escape(document.getElementById('bstate').value);
		param +='&s_state='+document.getElementById('sstate').value;
		param +='&contact_mech_bill='+document.getElementById('bill_id').value;
		param +='&b_address1='+escape(document.getElementById('badd1').value);
		param +='&b_address2='+escape(document.getElementById('badd2').value);
		param +='&b_city='+escape(document.getElementById('bcity').value);
		param +='&b_zip='+document.getElementById('bzip').value;
		param +='&b_geo='+document.getElementById('bcountry').value;
		param +='&contact_mech_ship='+document.getElementById('ship_id').value;
		param +='&s_address1='+escape(document.getElementById('sadd1').value);
		param +='&s_address2='+escape(document.getElementById('sadd2').value);
		param +='&s_city='+escape(document.getElementById('scity').value);
		param +='&s_zip='+document.getElementById('szip').value;
		param +='&s_geo='+document.getElementById('scountry').value;
		param +='&contact_mech_tlp='+document.getElementById('phone_id').value;
		param +='&country_tlp='+document.getElementById('p1').value;
		param +='&area_tlp='+document.getElementById('p2').value;
		param +='&number_tlp='+document.getElementById('p3').value;
		param +='&contact_mech_mobile='+document.getElementById('mobile_id').value;
		param +='&country_mobile='+document.getElementById('m1').value;
		param +='&area_mobile='+document.getElementById('m2').value;
		param +='&number_mobile='+document.getElementById('m3').value;
		param +='&contact_mech_fax='+document.getElementById('fax_id').value;
		param +='&country_fax='+document.getElementById('f1').value;
		param +='&area_fax='+document.getElementById('f2').value;
		param +='&number_fax='+document.getElementById('f3').value;
		param +='&contact_mech_web='+document.getElementById('web_id').value;
		param +='&website='+document.getElementById('website').value;
		param +='&password='+document.getElementById('password').value;
		param +='&password1='+document.getElementById('password1').value;
		param +='&user_id='+document.getElementById('user_id').value;
		param +='&action='+document.getElementById('action').value;
		param+='&bali_id='+document.getElementById('bali_id').value;
		param+='&country_bali='+document.getElementById('b1').value;
		param+='&area_bali='+document.getElementById('b2').value;
		param+='&number_bali='+document.getElementById('b3').value;
		param+='&discount='+document.getElementById('disc').value;
		var class_pty='';;
		for (var i=0; i < document.form_prof.class_pty.length; i++){
			if (document.form_prof.class_pty[i].checked){
					class_pty=document.form_prof.class_pty[i].value;
			}
		}
		param +='&class_pty='+class_pty;
		
		var pos='';
			if(document.getElementById('c_emp').checked){
				pos+=document.getElementById('c_emp').value+'-';
			}
			if(document.getElementById('c_man').checked){
				pos+=document.getElementById('c_man').value+'-';
			}
			if(document.getElementById('c_buyer').checked){
				pos+=document.getElementById('c_buyer').value+'-';
			}
			if(document.getElementById('c_owner').checked){
				pos+=document.getElementById('c_owner').value+'-';
			}
			if(document.getElementById('c_sale').checked){
				pos+=document.getElementById('c_sale').value+'-';
			}
					
		param +='&pos='+pos;
		param +='&gender='+gender;
		param+='&party_remark='+escape(document.getElementById('party_remark').value);
		param+='&remark_id='+document.getElementById('remark_id').value;
		for(var i=1;i<parseInt(document.getElementById('jml_instant').value);i++){
			param+='&'+document.getElementById('idinstant'+i).value+'='+escape(document.getElementById('instant'+i).value);
			param+='&'+document.getElementById('idinstant'+i).value+'Id='+document.getElementById('idinstantmech'+i).value;
		}
		param+='&jmlinstant='+document.getElementById('jml_instant').value;
		var jmlemail=parseInt(document.getElementById('jumlahEmail').value);
		var eml='';
		for(var i=0;i<jmlemail;i++){
			eml+=document.getElementById('email'+i).value+'#'+document.getElementById('emailId'+i).value+'~';
		}
		param+='&emailData='+eml;
		//OFFICE ADDRESS
		param+='&officeAdd='+escape(document.getElementById('oadd1').value)+'~'+escape(document.getElementById('oadd2').value)+'~'+escape(document.getElementById('ocity').value)+'~'+escape(document.getElementById('ozip').value)+'~'+escape(document.getElementById('ostate').value)+'~'+escape(document.getElementById('ocountry').value)+'~'+escape(document.getElementById('off_id').value);
		//tambahan data shop add
		param+='&shopLuasTotal='+escape($("#shopLuasTotal").val())+'&shopTerass='+escape($("#shopTerass").val())+'&own='+escape($("input[name='own']:checked").val());
		param+='&openingFromDate='+$("#openingFromDate").val()+'&openingToDate='+$("#openingToDate").val()+'&openingAllDate='+$("#openingAllDate:checked").val();
		param+='&shopContact='+escape($("#shopContact").val())+'&shop_name='+escape($("#shop_name").val());
		param+='&phoneShop='+escape($("#shopP1").val())+'~'+escape($("#shopP2").val())+'~'+escape($("#shopP3").val());
		param+='&location='+escape($("#location2").val());
		param+="&locationQ="+($("input[name='location1']:checked").val()!=undefined?$("input[name='location1']:checked").val():'');
		param+='&atLocal='+escape($("#atLocal").val());
		param+='&atTourism='+escape($("#atTourism").val());
		//informasi tambahan
		param+='&siretNumber='+escape($('#siretNumber').val())+'&vatNumber='+escape($('#vatNumber').val());
		param+='&lowFull='+$("input[name='lowFull']:checked").val();
		param+='&h1='+$("#h1").val()+"&h2="+$("#h2").val()+'&h3='+$("#h3").val()+'&home_id='+$("#home_id").val();
		param+='&contactEmail='+$("#contactEmail").val()+"&contactEmailId="+$("#contactEmailId").val();
		//expanded billing add
		param+='&bName='+escape($("#bName").val());
		//console.log($("#bName").val());
		param+='&bp1='+$("#bp1").val()+'&bp2='+$("#bp2").val()+'&bp3='+$("#bp3").val()+'&bp_id='+$("#bp_id").val();
		param+='&bpy1='+$("#bpy1").val()+'&bpy2='+$("#bpy2").val()+'&bpy3='+$("#bpy3").val()+'&bpy_id='+$("#bpy_id").val();
		param+='&bf1='+$("#bf1").val()+'&bf2='+$("#bf2").val()+'&bf3='+$("#bf3").val()+"&bf_id="+$("#bf_id").val();
		//expanded shipping add
		param+='&sName='+escape($("#sName").val());
		param+='&spd1='+$("#spd1").val()+'&spd2='+$("#spd2").val()+'&spd3='+$("#spd3").val()+'&spd_id='+$("#spd_id").val();
		//param+='&spo1='+$("#spo1").val()+"&spo2="+$("#spo2").val()+'&spo3='+$("#spo3").val()+'&spo_id='+$("#spo_id").val();
		param+='&sf1='+$("#sf1").val()+'&sf2='+$("#sf2").val()+'&sf3='+$("#sf3").val()+'&sf_id='+$("#sf_id").val();
		//selling way
		param+='&marketFrom='+$("#marketFrom").val()+'&marketTo='+$("#marketTo").val();
		param+='&marketAll='+($("#marketAll:checked").val()!=undefined?$("#marketAll:checked").val():'N');
		param+='&fairFrom='+$("#fairFrom").val()+'&fairTo='+$("#fairTo").val();
		param+='&fairAll='+($("#fairAll:checked").val()!=undefined?$("#fairAll:checked").val():'N');
		param+='&doorFrom='+$("#doorFrom").val()+'&doorTo='+$("#doorTo").val();
		param+='&doorAll='+($("#doorAll:checked").val()!=undefined?$("#doorAll:checked").val():'N');
		param+='&councilFrom='+$("#councilFrom").val()+'&councilTo='+$("#councilTo").val();
		param+='&councilAll='+($("#councilAll:checked").val()!=undefined?$("#councilAll:checked").val():'N');
		param+='&originStore='+ (document.getElementById('originStore') ? document.getElementById('originStore').value : '');
		var ui=document.getElementById('userid').value;
		document.getElementById('contentx').innerHTML='<img src="images/lbloading.gif" alt="loading" width="32" height="32">';
		$.post('/administration/include/customer/get_profile.php?ui='+ui,param,function(data){
			$("#content_max").html(data);
		});
		
		
		
}

function showSelCarrier(){
	showDialog4('Back To Previous Screen');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/customer/add_carrier2.php?company='+document.getElementById('hide_comp').innerHTML,'text','content_maxt');
}

function viewNewCarrier(){
	showDialog4('Back to Previous Screen');
	document.getElementById('content_maxt').innerHTML='<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="500" align="center" valign="middle"><img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" /></td>' +
		'</tr>' +
		' </table>';
	//document.getElementById('content_maxt').innerHTML='testing';
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		
		sendReq.open("POST", 'include/customer/add_carrier.php', true);
		sendReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		sendReq.onreadystatechange = function(){
			//document.getElementById('savex').style.display='none';
			if(sendReq.readyState==4 && sendReq.status==200)
			document.getElementById('content_maxt').innerHTML=sendReq.responseText;
		}
		sendReq.send('company='+document.getElementById('hide_comp').innerHTML);
	}
}
function viewNewContact(){
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		sendReq.open("POST", 'include/customer/add_contact.php', true);
		sendReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		sendReq.onreadystatechange = function(){
			//document.getElementById('savex').style.display='none';
			if(sendReq.readyState==4 && sendReq.status==200){
				showDialog4('Back to Previous Screen');
			document.getElementById('content_maxt').innerHTML=sendReq.responseText;
			}
		}
		sendReq.send('company='+document.getElementById('hide_comp').innerHTML);
	}
}
function showSelAgent(){
	showDialog4('Back To Previous Screen');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/customer/add_agent2.php','text','content_maxt');
}
function viewNewAgent(){
	showDialog4('Back To Previous Screen');
	document.getElementById('content_maxt').innerHTML='<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="500" align="center" valign="middle"><img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" /></td>' +
		'</tr>' +
		' </table>';
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		sendReq.open("POST", 'include/customer/add_agent.php', true);
		sendReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		sendReq.onreadystatechange = function(){
			//document.getElementById('savex').style.display='none';
			if(sendReq.readyState==4 && sendReq.status==200)
			document.getElementById('content_maxt').innerHTML=sendReq.responseText;
		}
		sendReq.send('company='+document.getElementById('hide_comp').innerHTML);
	}
}
function viewMoreWeb(party){
	//showDialog2('Back To Customer Page');
	$("body").append('<div id="content_save_new"></div>');
	document.getElementById('content_save_new').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	$("#content_save_new").dialog({
		autoOpen:false,
		modal:true,
		title:'Customer Management - Moobbie',
		bgiframe:true,
		width:500,
		close:function(){
			$("#content_save_new").remove();
		},
		open:function(){
			doRequest('get','include/customer/view_more_web.php?pi='+party,'text','content_save_new');
		}
	});
	$("#content_save_new").dialog('open');
	//doRequest('get','include/customer/view_more_web.php?pi='+party,'text','content_save');
}
function viewMoreShipping(party){
	showDialog4('Back To Customer Page');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/customer/view_more_shipping.php?pi='+party,'text','content_maxt');
}
function viewMoreEmail(party){
	showDialog4('Back To Customer Page');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/customer/view_more_email.php?pi='+party,'text','content_maxt');
}
function viewMorePhone(party){
	showDialog4('Back To Customer Page');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/customer/view_more_phone.php?pi='+party,'text','content_maxt');
}
function addEmailN(party){
	showDialog4('Back To Customer Page');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/customer/more_email.php?pi='+party,'text','content_maxt');
}
function addWebN(party){
	//showDialog2('Back To Customer Page');
	$("body").append('<div id="content_save_new"></div>');
	document.getElementById('content_save_new').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	$("#content_save_new").dialog({
		autoOpen:false,
		modal:true,
		title:'Customer Management - Moobbie',
		bgiframe:true,
		width:500,
		close:function(){
			$("#content_save_new").remove();
		},
		open:function(){
			doRequest('get','include/customer/more_web.php?pi='+party,'text','content_save_new');
		}
	});
	$("#content_save_new").dialog('open');
}
function addPhoneN(party){
	showDialog4('Back To Customer Page');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/customer/more_phone.php?pi='+party,'text','content_maxt');
}
function addShippingN(party){
	showDialog4('Back To Customer Page');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/customer/more_shipping.php?pi='+party,'text','content_maxt');
}

function saveEmailN(party,x){
	document.getElementById('loading1').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('POST','include/customer/more_email.php?pi='+party,true);
		xhtml.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200){
				document.getElementById('content_maxt').innerHTML=xhtml.responseText;
				alert('New Email has been saved.');
				showUpdateX(party);
			}
		}
		var param='party_id='+party;
		param+='&jenis='+document.getElementById('jenis'+x).value;
		param+='&email='+document.getElementById('temail'+x).value;
		param+='&act=save';
		xhtml.send(param);
	}
}
function delEmail(kode,party){
	var pil=confirm('Are you sure to delete this email?');
	if (pil==true){
		document.getElementById('loading1').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" />';
		doRequest('get','include/customer/view_more_email.php?pi='+party+'&kode='+kode+'&act=rem','text','content_maxt');
	}
}
function saveWebsite(party){
	if(document.getElementById('tweb').value==''){
		alertMsg('Please Input Website first!','');
	}else{
		if(xhtml.readyState==4 || xhtml.readyState==0){
			document.getElementById('loading1').innerHTML = '<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
			xhtml.open('POST','include/customer/more_web.php?pi='+party,true);
			xhtml.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			xhtml.onreadystatechange=function(){
				if(xhtml.readyState==4 && xhtml.status==200){
					document.getElementById('content_save_new').innerHTML=xhtml.responseText;
					alert('New Website address has been saved.');
					showUpdateX(party);
					$("#content_save_new").dialog('close');
				}
			}
			var param='party_id='+party;
			param+='&website='+document.getElementById('tweb').value;
			param+='&act=save';
			xhtml.send(param);			
		}
	}
}
function delWeb(kode,party){
	var pil=confirm('Are you sure to delete this Website?');
	if(pil==true){
	document.getElementById('content_save_new').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	//doRequest('get','include/pos/view_more_web.php?pi='+party+'&kode='+kode+'&act=rem','text','content_save');
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('GET','include/customer/view_more_web.php?pi='+party+'&kode='+kode+'&act=rem',true);
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200){
				document.getElementById('content_save_new').innerHTML=xhtml.responseText;
				showUpdateX(party);
			}
		}
		xhtml.send(null);
	}
	}
}
function editEmailN(kode,party,x){
	document.getElementById('loading1').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('GET','include/customer/view_more_email.php?pi='+party+'&kode='+kode+'&act=edit&email='+document.getElementById('editemail'+x).value,true);
		xhtml.onreadystatechange=function(){
			if (xhtml.readyState == 4 && xhtml.status == 200) {
				document.getElementById('content_maxt').innerHTML = xhtml.responseText;
				showUpdateX(party);
			}
		}
		xhtml.send(null);
	}
}

function editWebN(kode,party,x){	
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('GET','include/customer/view_more_web.php?pi='+party+'&kode='+kode+'&act=edit&website='+document.getElementById('editweb'+x).value,true);
		xhtml.onreadystatechange=function(){
			if (xhtml.readyState == 4 && xhtml.status == 200) {
				document.getElementById('content_save_new').innerHTML = xhtml.responseText;
				showUpdateX(party);
			}
		}
		xhtml.send(null);
	}
	document.getElementById('content_save_new').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
}
function savePhoneN(party,x){
	document.getElementById('loading1').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('POST','include/customer/more_phone.php?pi='+party,true);
		xhtml.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200){
				document.getElementById('content_maxt').innerHTML=xhtml.responseText;
				alert('New Phone Number has been saved.');
				showUpdateX(party);
			}
		}
		var param='party_id='+party;
		param+='&jenis='+document.getElementById('jenis'+x).value;
		param+='&ta='+document.getElementById('ta'+x).value;
		param+='&tc='+document.getElementById('tc'+x).value;
		param+='&tp='+document.getElementById('tp'+x).value;
		param+='&act=save';
		xhtml.send(param);
	}
}
function delPhone(kode,party){
	var pil=confirm('Are you sure to delete this Phone number?');
	if(pil==true){
		document.getElementById('loading1').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
		doRequest('get','include/customer/view_more_phone.php?pi='+party+'&kode='+kode+'&act=rem','text','content_maxt');
	}
}
function editPhoneN(kode,party,x){
	document.getElementById('loading1').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('GET','include/customer/view_more_phone.php?pi='+party+'&kode='+kode+'&act=edit&ta='+document.getElementById('ta'+x).value+'&tc='+document.getElementById('tc'+x).value+'&tp='+document.getElementById('tp'+x).value,true);
		xhtml.onreadystatechange=function(){
			if (xhtml.readyState == 4 && xhtml.status == 200) {
				document.getElementById('content_maxt').innerHTML = xhtml.responseText;
				showUpdateX(party);
			}
		}
		xhtml.send(null);
	}
}
function saveShippingN(party){
	if(document.getElementById('toname').value==''){
		alert('Please Input To Name first!','');
	}else
	if (document.getElementById('tadd1').value == '') {
	alert('Please Input Address first!','');
	}else if(document.getElementById('tcity').value==''){
		alert('Please Input City first!','');
	}else if(document.getElementById('tzip').value==''){
		alert('Please Input Zip Code first!','');
	}else if(document.getElementById('tcountry').value==''){
		alert('Please Select Country first!','');
	}
	else {
		document.getElementById('loading1').innerHTML = '<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
		if (xhtml.readyState == 4 || xhtml.readyState == 0) {
			xhtml.open('POST', 'include/customer/more_shipping.php?pi=' + party, true);
			xhtml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xhtml.onreadystatechange = function(){
				if (xhtml.readyState == 4 && xhtml.status == 200) {
					document.getElementById('content_maxt').innerHTML = xhtml.responseText;
					alert('New Shipping Address has been saved.');
					showUpdateX(party);
					document.getElementById('maximizex').style.display = 'none';
				}
			}
			var param = 'party_id=' + party;
			param += '&tadd1=' + escape(document.getElementById('tadd1').value);
			param += '&tadd2=' + escape(document.getElementById('tadd2').value);
			param += '&tcity=' + escape(document.getElementById('tcity').value);
			param += '&tzip=' + document.getElementById('tzip').value;
			param += '&tcountry=' + document.getElementById('tcountry').value;
			param += '&tstate=' + document.getElementById('tstate').value;
			param += '&act=save';
			param+='&attname='+escape(document.getElementById('tattn_name').value);
			param+='&toname='+escape(document.getElementById('toname').value);
			xhtml.send(param);
		}
	}
}
function editShippingN(party,x){
	if(document.getElementById('toname'+x).value==''){
		alert('Please Input To Name first!','');
	}else
	if (document.getElementById('tadd1'+x).value == '') {
	alert('Please Input Address first!','');
	}else if(document.getElementById('tcity'+x).value==''){
		alert('Please Input City first!','');
	}else if(document.getElementById('tzip'+x).value==''){
		alert('Please Input Zip Code first!','');
	}else if(document.getElementById('tcountry'+x).value==''){
		alert('Please Select Country first!','');
	}
	else {
		document.getElementById('loading1').innerHTML = '<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
		if (xhtml.readyState == 4 || xhtml.readyState == 0) {
			xhtml.open('POST', 'include/customer/view_more_shipping.php?pi=' + party, true);
			xhtml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xhtml.onreadystatechange = function(){
				if (xhtml.readyState == 4 && xhtml.status == 200) {
					document.getElementById('content_maxt').innerHTML = xhtml.responseText;
					showUpdateX(party);
				}
			}
			var param = 'party_id=' + party;
			param += '&tadd1=' + escape(document.getElementById('tadd1'+x).value);
			param += '&tadd2=' + escape(document.getElementById('tadd2'+x).value);
			param += '&tcity=' + escape(document.getElementById('tcity'+x).value);
			param += '&tzip=' + document.getElementById('tzip'+x).value;
			param += '&tcountry=' + document.getElementById('tcountry'+x).value;
			param += '&tstate=' + document.getElementById('tstate'+x).value;
			param += '&act=edit';
			param+='&attname='+escape(document.getElementById('tattn_name'+x).value);
			param+='&toname='+escape(document.getElementById('toname'+x).value);
			param+='&ship_id='+escape(document.getElementById('tship_id'+x).value);
			xhtml.send(param);
		}
	}
}
function delShip(kode,party){
	var pil=confirm('Are you sure to delete this Shipping Address?');
	if(pil==true){
	document.getElementById('loading1').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" />';
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('GET','include/customer/view_more_shipping.php?pi='+party+'&kode='+kode+'&act=rem',true);
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200){
				document.getElementById('content_maxt').innerHTML=xhtml.responseText;
				showUpdateX(party);
			}
		}
		xhtml.send(null);
	}
	}
}
function getPicture(){
	showDialog4('Back to Customer Screen');
	if(xhtml.readyState==4 || xhtml.readyState==0){
		document.getElementById('content_maxt').innerHTML='<img src="images/loading.gif" alt="Loading" width="30" height="30" align="absmiddle" />Loading....';
		xhtml.open('GET','/administration/include/customer/picture.php?pi='+document.getElementById('cus_id_xxx').innerHTML,true);
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200){
			 	//document.getElementById('contentx').innerHTML=xhtml.getAllResponseHeaders();
				//document.getElementById('tab').style.background='url(images/pos/picture_03.jpg) left bottom no-repeat';
				document.getElementById('content_maxt').innerHTML=xhtml.responseText;
				//document.getElementById('content2').innerHTML='';
			}
		}
		xhtml.send(null);
	}
}
function getPicturex(){
	if(xhtml.readyState==4 || xhtml.readyState==0){
		document.getElementById('content_maxt').innerHTML='<img src="images/loading.gif" alt="Loading" width="30" height="30" align="absmiddle" />Loading....';
		xhtml.open('GET','include/customer/picture.php?pi='+document.getElementById('cus_id_xxx').innerHTML,true);
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200){
			 	//document.getElementById('contentx').innerHTML=xhtml.getAllResponseHeaders();
				//document.getElementById('tab').style.background='url(images/pos/picture_03.jpg) left bottom no-repeat';
				document.getElementById('content_maxt').innerHTML=xhtml.responseText;
				showUpdateX(document.getElementById('cus_id_xxx').innerHTML);
				//document.getElementById('content2').innerHTML='';
			}
		}
		xhtml.send(null);
	}
}

function delEmp(kode){
	var pil=confirm("Are you sure to delete this contact?");
	if(pil==true){
		var vl = document.getElementById('hide_pito' + kode).value;
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		sendReq.open("POST", 'include/customer/get_employe.php?pi=' + document.getElementById('cus_id_xxx').innerHTML, true);
		sendReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		sendReq.onreadystatechange = function(){
			if (sendReq.status == 200 && sendReq.readyState == 4) 
				document.getElementById('otherCOntactDialog').innerHTML = sendReq.responseText;
		}
		sendReq.send('act=del&party_id_from=' + document.getElementById('cus_id_xxx').innerHTML + '&party_id_to=' + vl);
	}
	}	
}
function saveContact(){
	var gender=$("#addCOntactDialog input[name='gender']:checked").val()== undefined?'':$("#addCOntactDialog input[name='gender']:checked").val();
	//alert(gender);
	//return false;
	var filter=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if(gender==''){
		alert('Please Select gender!',''); return false;
	}else if($('#addCOntactDialog #fname').val()==''){
		alert('Please Input First Name!',''); return false;
	}else if ($('#addCOntactDialog #c_owner').get(0).checked == false && $('#addCOntactDialog #c_man').get(0).checked == false && $('#addCOntactDialog #c_emp').get(0).checked == false && $('#addCOntactDialog #c_buyer').get(0).checked == false && $('#addCOntactDialog #c_sale').get(0).checked == false) {
		alert('Please choose possition in company',''); return false;
	}
	else {
		$('#addCOntactDialog #contact_pic').get(0).style.display='none';
		$('#addCOntactDialog #contact_load').get(0).style.display='block';
		if (sendReq.readyState == 4 || sendReq.readyState == 0) {
			sendReq.open("POST", "include/customer/add_contact.php", true)
			sendReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			sendReq.onreadystatechange = function(){
				if (sendReq.readyState == 4 && sendReq.status == 200) {
					//alert(sendReq.responseText);
					$('#addCOntactDialog #pi').val(sendReq.responseText.replace(/<div align="left">/,""));
					$('#addCOntactDialog #text_load').get(0).innerHTML='Uploading Picture';
					$('#addCOntactDialog #frm_logo').submit();
					return true;
				}
			}
			var pos='';
			if($('#addCOntactDialog #c_emp').get(0).checked){
				pos+=$('#addCOntactDialog #c_emp').val()+'-';
			}
			if($('#addCOntactDialog #c_man').get(0).checked){
				pos+=$('#addCOntactDialog #c_man').val()+'-';
			}
			if($('#addCOntactDialog #c_buyer').get(0).checked){
				pos+=$('#addCOntactDialog #c_buyer').val()+'-';
			}
			if($('#addCOntactDialog #c_owner').get(0).checked){
				pos+=$('#addCOntactDialog #c_owner').val()+'-';
			}
			if($('#addCOntactDialog #c_sale').get(0).checked){
				pos+=$('#addCOntactDialog #c_sale').val()+'-';
			}
			var param = 'gender=' + gender;
			param += '&fname=' + $('#addCOntactDialog #fname').val();
			param += '&lname=' + $('#addCOntactDialog #lname').val();
			param += '&email=' + $('#addCOntactDialog #email').val();
			//param += '&psw=' + $('#addCOntactDialog #psw1').val();
			param += '&country_phone=' + $('#addCOntactDialog #p1').val();
			param += '&area_phone=' + $('#addCOntactDialog #p2').val();
			param += '&number_phone=' + $('#addCOntactDialog #p3').val();
			param += '&mobile_country=' + $('#addCOntactDialog #m1').val();
			param += '&mobile_area=' + $('#addCOntactDialog #m2').val();
			param += '&mobile_number=' + $('#addCOntactDialog #m3').val();
			param += '&bali_country=' + $('#addCOntactDialog #b1').val();
			param += '&bali_area=' + $('#addCOntactDialog #b2').val();
			param += '&bali_number=' + $('#addCOntactDialog #b3').val();
			//param += '&fax_country=' + $('#addCOntactDialog #f1').val();
			//param += '&fax_area=' + $('#addCOntactDialog #f2').val();
			//param += '&fax_number=' + $('#addCOntactDialog #f3').val();
			param += '&act=save';
			param += '&party_id_from=' + document.getElementById('cus_id_xxx').innerHTML;
			param+='&pos='+pos;
			for(var i=1;i<parseInt($('#addCOntactDialog #jml_instant').val());i++){
				param+='&'+$('#addCOntactDialog #idinstant'+i).val()+'='+$('#addCOntactDialog #instant'+i).val();
			}
			param+='&jmlinstant='+$('#addCOntactDialog #jml_instant').val();
			param+='&party_remark='+escape($('#addCOntactDialog #remark').val());
			sendReq.send(param);
			//document.getElementById('contentx').style.display = 'none';
		}
	}
}
function editCarrier(x){
	showDialog4('Back to previous screen');
	var pi=document.getElementById('hide_pito'+x).value;
	document.getElementById('content_maxt').innerHTML='<div align="center"><img alt="loading" src="images/pos/loading_img.gif" /></div>';
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('GET','include/customer/edit_carrier.php?edit='+pi,true);
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4){
				if(xhtml.status==200){
					document.getElementById('content_maxt').innerHTML=xhtml.responseText;
					document.getElementById('content_maxt').innerHTML=xhtml.responseText;
					var tab=new createTab(Array('Carrier Info','Other Contacts'),'moobbietab');
					tab.setAction(Array('editCarrier(\''+x+'\')','viewPartyRelation(\''+pi+'\',\'EMPLOYMENT\',\'carrier\')'));
					tab.initTab();
				}else{
					alert('Error In Making Request : '+xhtml.statusText,'');
				}
			}
		}
		xhtml.send(null);
	}
}
function delCarrier(kode){
	var pil=confirm("Are you sure to delete this carrier?");
	if(pil==true){
		var vl=document.getElementById('hide_pito'+kode).value;
		if(sendReq.readyState==4 || sendReq.readyState==0){
			sendReq.open("POST",'include/customer/get_carrier.php?pi='+document.getElementById('cus_id_xxx').innerHTML,true);
			sendReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			sendReq.onreadystatechange=function(){
				if(sendReq.readyState==4 && sendReq.status==200)
				document.getElementById('contentx').innerHTML=sendReq.responseText;
			}
			sendReq.send('act=del&party_id_from='+document.getElementById('cus_id_xxx').innerHTML+'&party_id_to='+vl);
		}
	}
}
function editCarrierN(party){
	//alert('test');
	var gender='';
		if(document.form_car.gender[0].checked){
		gender=document.form_car.gender[0].value;	
		}else if(document.form_car.gender[1].checked){
			gender=document.form_car.gender[1].value;
		}
		//alert('test');
	var filter=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if(gender==''){
		alert('Please Select gender!','');
	}else if(document.getElementById('fname').value==''){
		alert('Please Input First Name!','');
	}/*else if(document.getElementById('email').value==''){
		alert('Please input email address!','');
		document.getElementById('email').focus();
	}*/else if(!filter.test(document.getElementById('email').value) && document.getElementById('email').value!=''){
		alert('Please input the correct email','');
		document.getElementById('email').foucs();
	}else if(document.getElementById('psw1').value==''){
		alert('Please input password!','');
		document.getElementById('psw1').focus();
	}else if(document.getElementById('psw2').value==''){
		alert('Please input confirm password!','');
		document.getElementById('psw2').focus();
	}else if(document.getElementById('psw1').value!=document.getElementById('psw2').value){
		alert('Password and Confirm password must be the same!','');
		document.getElementById('psw1').focus();
	}/*else if(document.getElementById('p1').value=='' || document.getElementById('p2').value=='' || document.getElementById('p3').value=='' ){
		alert('Please input phone number!','');
		document.getElementById('p1').focus();
	}*/else if(document.getElementById('company').value==''){
		alert('Please input company name!','');
	}/*else if(document.getElementById('badd1').value==''){
		alert('Please input address','');
	}else if(document.getElementById('bcity').value==''){
		alert('Please input city','');
	}else if(document.getElementById('bzip').value==''){
		alert('Please input postal code','');
	}else if(document.getElementById('bcountry').value==''){
		alert("Please select country!",'');
	}*/else{
		if(sendReq.readyState==4 || sendReq.readyState==0){
			sendReq.open("POST","include/customer/edit_carrier.php?edit="+party,true);			
			sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			sendReq.onreadystatechange=function(){
				if (sendReq.readyState == 4 && sendReq.status == 200) {
					document.getElementById('content_maxt').innerHTML = sendReq.responseText;
					getCarrierX();
					var tab=new createTab(Array('Carrier Info','Other Contacts'),'moobbietab');
					tab.setAction(Array('editCarrier(\''+party+'\')','viewPartyRelation(\''+party+'\',\'EMPLOYMENT\',\'carrier\')'));
					tab.initTab();	
				}
			}
			var param='gender='+gender;
			param+='&fname='+escape(document.getElementById('fname').value);
			param+='&lname='+escape(document.getElementById('lname').value);
			param+='&email='+document.getElementById('email').value;
			param+='&psw='+escape(document.getElementById('psw1').value);
			param+='&country_phone='+document.getElementById('p1').value;
			param+='&area_phone='+document.getElementById('p2').value;
			param+='&number_phone='+document.getElementById('p3').value;
			param+='&mobile_country='+document.getElementById('m1').value;
			param+='&mobile_area='+document.getElementById('m2').value;
			param+='&mobile_number='+document.getElementById('m3').value;
			param+='&bali_country='+document.getElementById('b1').value;
			param+='&bali_area='+document.getElementById('b2').value;
			param+='&bali_number='+document.getElementById('b3').value;
			param+='&fax_country='+document.getElementById('f1').value;
			param+='&fax_area='+document.getElementById('f2').value;
			param+='&fax_number='+document.getElementById('f3').value;
			param+='&party='+party;
			param+='&company='+escape(document.getElementById('company').value);
			param+='&address1='+escape(document.getElementById('badd1').value);
			param+='&address2='+escape(document.getElementById('badd2').value);
			param+='&city='+escape(document.getElementById('bcity').value);
			param+='&state='+document.getElementById('bstate').value;
			param+='&zip='+escape(document.getElementById('bzip').value);
			param+='&country='+document.getElementById('bcountry').value;
			param+='&web='+document.getElementById('tweb').value;
			param+='&user_login='+document.getElementById('userlogin').value;
			param+='&email_id='+document.getElementById('email_id').value;
			param+='&phone_id='+document.getElementById('phone_id').value;
			param+='&mob_id='+document.getElementById('mob_id').value;
			param+='&bali_id='+document.getElementById('bali_id').value;
			param+='&fax_id='+document.getElementById('fax_id').value;
			param+='&web_id='+document.getElementById('web_id').value;
			param+='&add_id='+document.getElementById('add_id').value;
			param+='&act=edit';
			for(var i=1;i<parseInt(document.getElementById('jml_instant').value);i++){
				param+='&'+document.getElementById('idinstant'+i).value+'='+document.getElementById('instant'+i).value;
				param+='&'+document.getElementById('idinstant'+i).value+'Id='+document.getElementById('idinstantmech'+i).value;
			}
			param+='&jmlinstant='+document.getElementById('jml_instant').value;
			var jmlemail=parseInt(document.getElementById('jumlahEmail').value);
			var eml='';
			for(var i=0;i<jmlemail;i++){
				eml+=document.getElementById('email'+i).value+'#'+document.getElementById('emailId'+i).value+'~';
			}
			param+='&emailData='+eml;
			param+='&party_remark='+escape(document.getElementById('remark').value);
			param+='&noteId='+document.getElementById('noteId').value;
			sendReq.send(param);
			document.getElementById('content_maxt').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="100" align="center" valign="middle"><img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" /></td>' +
		'</tr>' +
		' </table>';
		}
	}	
}
function saveCarrier(){
	var gender='';
		if(document.form_car.gender[0].checked){
		gender=document.form_car.gender[0].value;	
		}else if(document.form_car.gender[1].checked){
			gender=document.form_car.gender[1].value;
		}
	var filter=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	var message = new MoobbieVanilaMessage('alert');
	message.setTitle('Customer Management - Moobbie');
	message.setOkAction();
	if(gender==''){
		message.setContent('Please select gender!');
		message.show();
		return false;
	}else if(document.getElementById('fname').value==''){
		message.setContent('Please input first name!');
		message.show();
		return false;
	}/*else if(document.getElementById('email').value==''){
		alert('Please input email address!','');
		document.getElementById('email').focus();
	}*/else if(!filter.test(document.getElementById('email').value) && document.getElementById('email').value!=''){
		alert('Please input the correct email','');
		document.getElementById('email').foucs();
		return false;
	}else if(document.getElementById('psw1').value==''){
		message.setContent('Please input password!');
		message.show();
		document.getElementById('psw1').focus();
		return false;
	}else if(document.getElementById('psw2').value==''){
		message.setContent('Please input confirm password!');
		message.show();
		document.getElementById('psw2').focus();
		return false;
	}else if(document.getElementById('psw1').value!=document.getElementById('psw2').value){
		message.setContent('Password and confirm password must be the same!');
		message.show();
		document.getElementById('psw1').focus();
		return false;
	}/*else if(document.getElementById('p1').value=='' || document.getElementById('p2').value=='' || document.getElementById('p3').value=='' ){
		alert('Please input phone number!','');
		document.getElementById('p1').focus();
	}*/else if(document.getElementById('company').value==''){
		message.setContent('Please input company name!');
		message.show();
		return false;
	}/*else if(document.getElementById('badd1').value==''){
		alert('Please input address','');
	}else if(document.getElementById('bcity').value==''){
		alert('Please input city','');
	}else if(document.getElementById('bzip').value==''){
		alert('Please input postal code','');
	}else if(document.getElementById('bcountry').value==''){
		alert("Please select country!",'');
	}*/else{
		if(sendReq.readyState==4 || sendReq.readyState==0){
			sendReq.open("POST","include/customer/add_carrier.php",true);
			sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			sendReq.onreadystatechange=function(){
				if (sendReq.readyState == 4 && sendReq.status == 200) {
					document.getElementById('content_maxt').innerHTML = sendReq.responseText;
					getCarrierX();
					document.getElementById('maximizex').style.display = 'none';
				}
			}
			var param='gender='+gender;
			param+='&fname='+escape(document.getElementById('fname').value);
			param+='&lname='+escape(document.getElementById('lname').value);
			param+='&email='+document.getElementById('email').value;
			param+='&psw='+escape(document.getElementById('psw1').value);
			param+='&country_phone='+document.getElementById('p1').value;
			param+='&area_phone='+document.getElementById('p2').value;
			param+='&number_phone='+document.getElementById('p3').value;
			param+='&mobile_country='+document.getElementById('m1').value;
			param+='&mobile_area='+document.getElementById('m2').value;
			param+='&mobile_number='+document.getElementById('m3').value;
			param+='&bali_country='+document.getElementById('b1').value;
			param+='&bali_area='+document.getElementById('b2').value;
			param+='&bali_number='+document.getElementById('b3').value;
			param+='&fax_country='+document.getElementById('f1').value;
			param+='&fax_area='+document.getElementById('f2').value;
			param+='&fax_number='+document.getElementById('f3').value;
			param+='&act=save';
			param+='&party_id_from='+document.getElementById('cus_id_xxx').innerHTML;
			param+='&company='+escape(document.getElementById('company').value);
			param+='&address1='+escape(document.getElementById('badd1').value);
			param+='&address2='+escape(document.getElementById('badd2').value);
			param+='&city='+escape(document.getElementById('bcity').value);
			param+='&state='+document.getElementById('bstate').value;
			param+='&zip='+escape(document.getElementById('bzip').value);
			param+='&country='+document.getElementById('bcountry').value;
			param+='&web='+document.getElementById('tweb').value;
			for(var i=1;i<parseInt(document.getElementById('jml_instant').value);i++){
				param+='&'+document.getElementById('idinstant'+i).value+'='+document.getElementById('instant'+i).value;
			}
			param+='&jmlinstant='+document.getElementById('jml_instant').value;
			param+='&party_remark='+escape(document.getElementById('remark').value);
			sendReq.send(param);
			document.getElementById('content_maxt').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="100" align="center" valign="middle"><img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" /></td>' +
		'</tr>' +
		' </table>';
		}
	}
	message.hide();	
}
function searchCarrierX(page){
	if (document.getElementById('c_comp').checked == false && document.getElementById('c_name1').checked==false && document.getElementById('c_car_id').checked==false  && document.getElementById('c_count').checked==false) {
	alertMsg('Please choose search by option!','');
	}
	else {
		var cust_id='N';
		var cust_name='N';
		var comp='N';
		var count='N';

		var t_custid='';
		var t_custnm='';
		var t_comp='';
		var t_count='';		
		if(document.getElementById('c_car_id').checked==true){
			
			cust_id='Y';
			t_custid=document.getElementById('t_car_id').value;
		}
		if(document.getElementById('c_name1').checked==true){
			
			cust_name='Y';
			t_custnm=document.getElementById('t_name1').value;
			
		}
		if(document.getElementById('c_comp').checked==true){
			
			comp='Y';
			t_comp=document.getElementById('t_comp').value;
		}
		if(document.getElementById('c_count').checked==true){
			t_count=document.getElementById('t_count').value;
			count='Y';
		}
				
		if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		sendReq.open("POST", page, true);
		sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		sendReq.onreadystatechange = function(){
			if(sendReq.readyState==4 && sendReq.status==200){
				document.getElementById('content_maxt').innerHTML=sendReq.responseText;
			}	
		}
		var param = 'cust_id=' + cust_id;
		param += '&t_custid='+t_custid;
		param +='&cust_name='+cust_name;
		param +='&t_custnm='+t_custnm;
		param +='&comp='+comp;
		param +='&t_comp='+t_comp;
		param+='&count='+count;
		param+='&t_count='+t_count;
		param +='&act=search';
				
		sendReq.send(param);
		document.getElementById('loading').innerHTML='<img src="images/lbloading.gif" alt="loading" width="32" height="32">';
		
	}	
	}
}
function showSelCarrier2(kode){
	document.getElementById('content_maxt').innerHTML+='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/customer/add_carrier2.php?search='+kode,'text','content_maxt');
}
function saveSelCarrier(kode){
	if(document.getElementById('pt_id'+kode).innerHTML==''){
		alert('Please Select Carrier!');
	}else{
		if(sendReq.readyState==4 || sendReq.readyState==0){
		sendReq.open("POST", 'include/customer/add_carrier2.php', true);
		sendReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		sendReq.onreadystatechange = function(){
			if (sendReq.readyState == 4 && sendReq.status == 200) {
				document.getElementById('content_maxt').innerHTML = sendReq.responseText;
				getCarrierX();
				document.getElementById('maximizex').style.display = 'none';
			}
		}
		sendReq.send("act=add&party_id_from="+document.getElementById('cus_id_xxx').innerHTML+'&party_id_to='+document.getElementById('pt_id'+kode).innerHTML);		
		}
		document.getElementById('content_maxt').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	}
}
function saveAgent(){
	var gender='';
		if(document.form_agent.gender[0].checked){
		gender=document.form_agent.gender[0].value;	
		}else if(document.form_agent.gender[1].checked){
			gender=document.form_agent.gender[1].value;
		}
	var filter=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if(gender==''){
		alert('Please Select gender!');
	}else if(document.getElementById('fname').value==''){
		alert('Please Input First Name!');
	}else if(document.getElementById('email').value==''){
		alert('Please input email address!');
		document.getElementById('email').focus();
	}else if(!filter.test(document.getElementById('email').value)){
		alert('Please input the correct email');
		document.getElementById('email').foucs();
	}else if(document.getElementById('psw1').value==''){
		alert('Please input password!');
		document.getElementById('psw1').focus();
	}else if(document.getElementById('psw2').value==''){
		alert('Please input confirm password!');
		document.getElementById('psw2').focus();
	}else if(document.getElementById('psw1').value!=document.getElementById('psw2').value){
		alert('Password and Confirm password must be the same!');
		document.getElementById('psw1').focus();
	}else if(document.getElementById('p1').value=='' || document.getElementById('p2').value=='' || document.getElementById('p3').value=='' ){
		alert('Please input phone number!');
		document.getElementById('p1').focus();
	}else if(document.getElementById('company').value==''){
		alert('Please input company name!');
	}else if(document.getElementById('badd1').value==''){
		alert('Please input address');
	}else if(document.getElementById('bcity').value==''){
		alert('Please input city');
	}else if(document.getElementById('bzip').value==''){
		alert('Please input postal code');
	}else if(document.getElementById('bcountry').value==''){
		alert("Please select country!");
	}else{
		if(sendReq.readyState==4 || sendReq.readyState==0){
			sendReq.open("POST","include/customer/add_agent.php",true);
			sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			sendReq.onreadystatechange=function(){
				if (sendReq.readyState == 4 && sendReq.status == 200) {
					document.getElementById('content_maxt').innerHTML = sendReq.responseText;
					getAgentX();
					document.getElementById('maximizex').style.display = 'none';
				}
			}
			var param='gender='+gender;
			param+='&fname='+document.getElementById('fname').value;
			param+='&lname='+document.getElementById('lname').value;
			param+='&email='+document.getElementById('email').value;
			param+='&psw='+document.getElementById('psw1').value;
			param+='&country_phone='+document.getElementById('p1').value;
			param+='&area_phone='+document.getElementById('p2').value;
			param+='&number_phone='+document.getElementById('p3').value;
			param+='&mobile_country='+document.getElementById('m1').value;
			param+='&mobile_area='+document.getElementById('m2').value;
			param+='&mobile_number='+document.getElementById('m3').value;
			param+='&bali_country='+document.getElementById('b1').value;
			param+='&bali_area='+document.getElementById('b2').value;
			param+='&bali_number='+document.getElementById('b3').value;
			param+='&fax_country='+document.getElementById('f1').value;
			param+='&fax_area='+document.getElementById('f2').value;
			param+='&fax_number='+document.getElementById('f3').value;
			param+='&act=save';
			param+='&party_id_from='+document.getElementById('cus_id_xxx').innerHTML;
			param+='&company='+document.getElementById('company').value;
			param+='&address1='+document.getElementById('badd1').value;
			param+='&address2='+document.getElementById('badd2').value;
			param+='&city='+document.getElementById('bcity').value;
			param+='&state='+document.getElementById('bstate').value;
			param+='&zip='+document.getElementById('bzip').value;
			param+='&country='+document.getElementById('bcountry').value;
			param+='&web='+document.getElementById('tweb').value;
			for(var i=1;i<parseInt(document.getElementById('jml_instant').value);i++){
				param+='&'+document.getElementById('idinstant'+i).value+'='+document.getElementById('instant'+i).value;
			}
			param+='&jmlinstant='+document.getElementById('jml_instant').value;
			param+='&party_remark='+escape(document.getElementById('remark').value);
			sendReq.send(param);
			document.getElementById('content_maxt').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="100" align="center" valign="middle"><img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" /></td>' +
		'</tr>' +
		' </table>';
		}
	}
}
function showSelAgent2(kode){
	document.getElementById('content_maxt').innerHTML+='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/customer/add_agent2.php?search='+kode,'text','content_maxt');
}
function saveSelAgent(kode){
	if(document.getElementById('pt_id'+kode).innerHTML==''){
		alert('Please Select Agent!');
	}else{
		if(sendReq.readyState==4 || sendReq.readyState==0){
		sendReq.open("POST", 'include/customer/add_agent2.php', true);
		sendReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		sendReq.onreadystatechange = function(){
			document.getElementById('content_maxt').innerHTML=sendReq.responseText;
			getAgentX();	
			document.getElementById('maximizex').style.display='none';
		}
		sendReq.send("act=add&party_id_from="+document.getElementById('cus_id_xxx').innerHTML+'&party_id_to='+document.getElementById('pt_id'+kode).innerHTML);
		document.getElementById('content_maxt').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="100" align="center" valign="middle"><img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" /></td>' +
		'</tr>' +
		' </table>';
		}
		
	}
}
function delAgent(kode){
	var pil=confirm("Are you sure to delete?");
	if(pil==true){
		var vl=document.getElementById('hide_pito'+kode).value;
		if(sendReq.readyState==4 || sendReq.readyState==0){
			sendReq.open("POST",'include/customer/get_agent.php?pi='+document.getElementById('cus_id_xxx').innerHTML,true);
			sendReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			sendReq.onreadystatechange=function(){
				if (sendReq.readyState == 4 && sendReq.status == 200) {
					document.getElementById('contentx').innerHTML = sendReq.responseText;
				}
			}
			sendReq.send('act=del&party_id_from='+document.getElementById('cus_id_xxx').innerHTML+'&party_id_to='+vl);
			document.getElementById('contentx').innerHTML='<img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
		}
	}
}
function newCusX(){
	showDialogX();
	document.getElementById('content_max').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="100" align="center" valign="middle"><img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" /></td>' +
		'</tr>' +
		' </table>';
	doRequest('get','include/customer/new_customer.php','text','content_max','',function(){
		if(window.location.href.search(/administration/)==-1){
			$('#btnsave').val(__("Continue Your Registration"));
		}
	});
}

function doSubmitX(){
	var isAdmin=document.getElementById('isAdmin').value;
	
	var gender=$("input[name='gender']:checked").val();
	var class_pty=$("input[name='class_pty']:checked").val();
	
	var pos='';
			if(document.getElementById('c_emp').checked){
				pos+=document.getElementById('c_emp').value+'-';
			}
			if(document.getElementById('c_man').checked){
				pos+=document.getElementById('c_man').value+'-';
			}
			if(document.getElementById('c_buyer').checked){
				pos+=document.getElementById('c_buyer').value+'-';
			}
			if(document.getElementById('c_owner').checked){
				pos+=document.getElementById('c_owner').value+'-';
			}
			if(document.getElementById('c_sale').checked){
				pos+=document.getElementById('c_sale').value+'-';
			}
	
	var filter=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if(gender== undefined){
		alert(__('Please select gender'));	
	}else if(document.getElementById('name').value==''){
		alert(__('Please input First name'));
		document.getElementById('name').focus();
	}else if(document.getElementById('company').value=='' && $("#underName").val()==''){
		alert(__('Please input company name'));
		document.getElementById('company').focus();
	}else if(pos==''){
		alert(__("Please select position"));
	}else if(class_pty== undefined){
		alert(__("Please select classification"));
	}else if(document.getElementById('email').value=='' && isAdmin=='N'){
		alert(__('Please input email address'));
		document.getElementById('email').focus();
	}else if(!filter.test(document.getElementById('email').value) && isAdmin=='N'){
		alert(__('Please input the correct email'));
		document.getElementById('email').foucs();
	}else if(document.getElementById('password').value==''){
		alert(__('Please input password'));
		document.getElementById('password').focus();
	}else if(document.getElementById('password1').value==''){
		alert(__('Please input confirm password'));
		document.getElementById('password1').focus();
	}else if(document.getElementById('password').value!=document.getElementById('password1').value){
		alert(__('Password and Confirm password must be the same'),'');
		document.getElementById('password').focus();
	}else if(document.getElementById('p1').value=='' || document.getElementById('p2').value=='' || document.getElementById('p3').value=='' ){
		alert(__('Please input phone number'),'');
		document.getElementById('p1').focus();
	}else if(document.getElementById('badd1').value==''){
		alert(__('Please input Billing address 1'),'');
		document.getElementById('badd1').focus();
	}else if(document.getElementById('bcity').value==''){
		alert(__('Please input Billing address city'),'');
		document.getElementById('bcity').focus();
	}else if(document.getElementById('bzip').value==''){
		alert(__('Please input billing address zip code'),'');
		document.getElementById('bzip').focus();
	}else if(document.getElementById('bcountry').value==''){
		alert(__('Please input billing address country'),'');
		document.getElementById('bcountry').focus();
	}else if(document.getElementById('sadd1').value==''){
		alert(__('Please input shipping address 1'),'');
		document.getElementById('sadd1').focus();
	}else if(document.getElementById('scity').value==''){
		alert(__('Please input shipping address city'),'');
		document.getElementById('scity').focus();
	}else if(document.getElementById('szip').value==''){
		alert(__('Please input shipping address zip code'),'');
		document.getElementById('szip').focus();
	}else if(document.getElementById('scountry').value==''){
		alert(__('Please input shipping address country'),'');
		document.getElementById('scountry').focus();
	}else if (document.getElementById('c_owner').checked == false && document.getElementById('c_man').checked == false && document.getElementById('c_emp').checked == false && document.getElementById('c_buyer').checked == false && document.getElementById('c_sale').checked == false) {
		alert(__('Please choose position in company'),'');
	}else{
	doSave1X();
	}
}

function newCusxxX(){
showDialog2('Back to previous screen','');
document.getElementById('content_save').innerHTML='<div  style="height:200px; margin:auto;" align="center">'+
'<span id="text_loadx" style="font-size:18px; font-weight:bold;">Saving new customer</span><br />'+
'<img src="images/pos/loading3.gif" alt="loading" width="208" height="13" /><br />'+
'<strong>Please wait...<br />'+
'<span style="color:red;">Don not click anything</span></strong>'+
'</div>';
}
function affterSaveLogoX(){
	document.getElementById('text_loadx').innerHTML=__('Uploading Picture');
	document.frm_logo1.submit();
}
function afterSavePictureX(party){
	document.getElementById('savex').style.display='none';
	document.getElementById('content_max').innerHTML='<div align="center"><img src="images/lbloading.gif" alt="loading" width="32" height="32"></div>';
	//if(window.location.href.search(/administration/)!=-1){
		doRequest('get','include/customer/get_profile.php?ui='+party,'text','content_max');
	/*}else{
		window.location.href='member-area.php?msg=1';
	}*/
}

function doSave1X(){
	newCusxxX();
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		sendReq.open("POST", 'include/customer/new_customer.php', true);
		sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		sendReq.onreadystatechange = function(){
			if(sendReq.readyState==4 && sendReq.status==200){
				if (sendReq.responseText.search(/User/) < 0) {
					
					document.getElementById('pi').value = sendReq.responseText;
					document.getElementById('pix').value = sendReq.responseText;
					document.getElementById('text_loadx').innerHTML=__('Uploading Logo');
					document.frm_logo.submit();
					
				}else{
					$("#savex").hide();
					alert(sendReq.responseText+"\nPlease input another email!");
					$("#email").focus();
				}
			}
		}
		
		var param = 'username=' + escape(document.getElementById('email').value);
		param += '&firstname='+escape(document.getElementById('name').value);
		param +='&lastname='+escape(document.getElementById('last_name').value);
		if ($("input[name='lowFull']:checked").val() == '1') {
			param += '&company=' + escape(document.getElementById('company').value);
		}else{
			param += '&company=' + escape(document.getElementById('underName').value);
		}
		param +='&phone_country='+document.getElementById('p1').value;
		param +='&phone_area='+document.getElementById('p2').value;
		param +='&phone_number='+document.getElementById('p3').value;
		param +='&password='+escape(document.getElementById('password').value);
		param +='&bill_address1='+escape(document.getElementById('badd1').value);
		param +='&bill_address2='+escape(document.getElementById('badd2').value);
		param +='&bill_city='+escape(document.getElementById('bcity').value);
		param +='&bill_state='+document.getElementById('bstate').value;
		param +='&bill_zip='+escape(document.getElementById('bzip').value);
		param +='&bill_country='+document.getElementById('bcountry').value;
		param +='&ship_address1='+escape(document.getElementById('sadd1').value);
		param +='&ship_address2='+escape(document.getElementById('sadd2').value);
		param +='&ship_city='+escape(document.getElementById('scity').value);
		param +='&ship_state='+document.getElementById('sstate').value;
		param +='&ship_zip='+escape(document.getElementById('szip').value);
		param +='&ship_country='+document.getElementById('scountry').value;
		var gender=$("input[name='gender']:checked").val();
		param +='&gender='+gender;
		param +='&country_fax='+document.getElementById('f1').value;
		param +='&area_fax='+document.getElementById('f2').value;
		param +='&phone_fax='+document.getElementById('f3').value;
		param +='&country_mobile='+document.getElementById('m1').value;
		param +='&area_mobile='+document.getElementById('m2').value;
		param +='&phone_mobile='+document.getElementById('m3').value;
		param +='&website='+escape(document.getElementById('website').value);
		param +='&action='+document.getElementById('action').value;
		param+='&country_bali='+document.getElementById('b1').value;
		param+='&area_bali='+document.getElementById('b2').value;
		param+='&number_bali='+document.getElementById('b3').value;
		var pos='';
			if(document.getElementById('c_emp').checked){
				pos+=document.getElementById('c_emp').value+'-';
			}
			if(document.getElementById('c_man').checked){
				pos+=document.getElementById('c_man').value+'-';
			}
			if(document.getElementById('c_buyer').checked){
				pos+=document.getElementById('c_buyer').value+'-';
			}
			if(document.getElementById('c_owner').checked){
				pos+=document.getElementById('c_owner').value+'-';
			}
			if(document.getElementById('c_sale').checked){
				pos+=document.getElementById('c_sale').value+'-';
			}
		
		var class_pty=$("input[name='class_pty']:checked").val();
		param +='&class_pty='+class_pty;
		param +='&discount='+document.getElementById('disc').value;
		param +='&pos='+pos;
		param+='&party_remark='+escape(document.getElementById('party_remark').value);
		for(var i=1;i<parseInt(document.getElementById('jml_instant').value);i++){
			param+='&'+document.getElementById('idinstant'+i).value+'='+escape(document.getElementById('instant'+i).value);
		}
		param+='&jmlinstant='+document.getElementById('jml_instant').value;
		//OFFICE ADDRESS
		param+='&officeAdd='+escape(document.getElementById('oadd1').value)+'~'+escape(document.getElementById('oadd2').value)+'~'
		+escape(document.getElementById('ocity').value)+'~'+escape(document.getElementById('ozip').value)+'~'
		+escape(document.getElementById('ostate').value)+'~'+escape(document.getElementById('ocountry').value)+'~'
		+escape(document.getElementById('off_id').value);
		//tambahan data shop add
		param+='&shopLuasTotal='+$("#shopLuasTotal").val()+'&shopTerass='+$("#shopTerass").val()+'&own='+$("input[name='own']:checked").val();
		param+='&openingFromDate='+$("#openingFromDate").val()+'&openingToDate='+$("#openingToDate").val()+'&openingAllDate='+$("#openingAllDate:checked").val();
		param+='&shopContact='+escape($("#shopContact").val())+'&shop_name='+escape($("#shop_name").val());
		param+='&phoneShop='+$("#shopP1").val()+'~'+$("#shopP2").val()+'~'+$("#shopP3").val();
		param+='&location='+$("#location2").val();
		param+="&locationQ="+($("input[name='location1']:checked").val()!=undefined?$("input[name='location1']:checked").val():'');
		param+='&atLocal='+$("#atLocal").val();
		param+='&atTourism='+$("#atTourism").val();
		//informasi tambahan
		param+='&siretNumber='+escape($('#siretNumber').val())+'&vatNumber='+escape($('#vatNumber').val());
		param+='&lowFull='+$("input[name='lowFull']:checked").val();
		param+='&h1='+$("#h1").val()+"&h2="+$("#h2").val()+'&h3='+$("#h3").val()+'&home_id='+$("#home_id").val();
		param+='&contactEmail='+$("#contactEmail").val()+"&contactEmailId="+$("#contactEmailId").val();
		//expanded billing add
		param+='&bName='+escape($("#bName").val());
		//console.log($("#bName").val());
		param+='&bp1='+$("#bp1").val()+'&bp2='+$("#bp2").val()+'&bp3='+$("#bp3").val()+'&bp_id='+$("#bp_id").val();
		param+='&bpy1='+$("#bpy1").val()+'&bpy2='+$("#bpy2").val()+'&bpy3='+$("#bpy3").val()+'&bpy_id='+$("#bpy_id").val();
		param+='&bf1='+$("#bf1").val()+'&bf2='+$("#bf2").val()+'&bf3='+$("#bf3").val()+"&bf_id="+$("#bf_id").val();
		//expanded shipping add
		param+='&sName='+escape($("#sName").val());
		param+='&spd1='+$("#spd1").val()+'&spd2='+$("#spd2").val()+'&spd3='+$("#spd3").val()+'&spd_id='+$("#spd_id").val();
		//param+='&spo1='+$("#spo1").val()+"&spo2="+$("#spo2").val()+'&spo3='+$("#spo3").val()+'&spo_id='+$("#spo_id").val();
		param+='&sf1='+$("#sf1").val()+'&sf2='+$("#sf2").val()+'&sf3='+$("#sf3").val()+'&sf_id='+$("#sf_id").val();
		//selling way
		param+='&marketFrom='+$("#marketFrom").val()+'&marketTo='+$("#marketTo").val();
		param+='&marketAll='+($("#marketAll:checked").val()!=undefined?$("#marketAll:checked").val():'N');
		param+='&fairFrom='+$("#fairFrom").val()+'&fairTo='+$("#fairTo").val();
		param+='&fairAll='+($("#fairAll:checked").val()!=undefined?$("#fairAll:checked").val():'N');
		param+='&doorFrom='+$("#doorFrom").val()+'&doorTo='+$("#doorTo").val();
		param+='&doorAll='+($("#doorAll:checked").val()!=undefined?$("#doorAll:checked").val():'N');
		param+='&councilFrom='+$("#councilFrom").val()+'&councilTo='+$("#councilTo").val();
		param+='&councilAll='+($("#councilAll:checked").val()!=undefined?$("#councilAll:checked").val():'N');
		if(window.location.href.search(/administration/)==-1){
			param+='&fromWeb=1';
		}else{
			param+='&fromWeb=0';
		}
		sendReq.send(param);		
	}	
}
function getEmploye(){
	var pi=document.getElementById('cus_id_xxx').innerHTML;
	document.getElementById('contentx').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="100" align="center" valign="middle"><img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" /></td>' +
		'</tr>' +
		' </table>';
	document.getElementById('content2').innerHTML='';
	document.getElementById('tab').style.background='url(images/tab/tab_02.jpg) left bottom no-repeat';
	doRequest('get','include/customer/get_employe.php?pi='+pi,'text','contentx');
}
function afterAddContact(){
	//getEmploye();
	//document.getElementById('maximizex').style.display='none';
	$("#addCOntactDialog").dialog('close');
}
function afterAddContact1(party){
	loadOtherCOntact(document.getElementById('cus_id_xxx').innerHTML);
	doRequest('get','include/customer/edit_contact.php?view='+party,'text','editContact');
}
function getOrderHis(){
	if(xhtml.readyState==4 || xhtml.readyState==0){
		document.getElementById('contentx').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="100" align="center" valign="middle"><img src="images/loading.gif" width="30" height="30" alt="loading" style="filter:alpha(opacity=100); opacity:1;" /></td>' +
		'</tr>' +
		' </table>';
		document.getElementById('tab').style.background='url(images/tab/tab_06.jpg) left bottom no-repeat';
		if (window.location.href.search(/administration/) != -1 || window.location.href.search(/moobbie/) != -1) {
			xhtml.open('GET', '/administration/include/customer/order_history.php', true);
		}else{
			xhtml.open('GET', 'include/profile/order_history.php', true);
		}
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200){
				document.getElementById('contentx').innerHTML=xhtml.responseText;
			}
		}
		xhtml.send(null);
	}
}
function showOrderDetail3(party, store){
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		showDialog4('Back to previous screen');
		document.getElementById('content_maxt').innerHTML='<div align="center"><img src="images/pos/loading3.gif" alt="loading" align="absmiddle" /></div>';
		if (window.location.href.search(/administration/) != -1) {
			sendReq.open('GET', 'include/order/open_order.php?party=' + party + '&timestamp=' + timestamp.getTime()+'&store='+store, true);
		}else{
			sendReq.open('GET','include/profile/open_order.php',true);
		}
		sendReq.onreadystatechange=function(){
			if(sendReq.readyState==4){
				if(sendReq.status==200){
					document.getElementById('content_maxt').innerHTML=sendReq.responseText;
					
				}else
				alert("Error : "+sendReq.statusText);
			}
		}
		sendReq.send(null);
	}
}
function editContact(x){
	var party=document.getElementById('hide_pito'+x).value;
	$("body").append('<div id="editContact"><div align="center"><img src="images/loading.gif" alt="loading" align="absmiddle" /></div></div>');
	$("#editContact").dialog({
		modal:true,
		bgiframe:true,
		autoOpen:false,
		title:'Customer Management &raquo; Edit Other Contact - Moobbie',
		width:$(window).width()-40,
		height:$(window).height()-40,
		open:function(){
			doRequest('get','include/customer/edit_contact.php?view='+party,'text','editContact');
		},
		close:function(){
			$("#editContact").remove();
		},
		buttons:{
			"Close":function(){
				$(this).dialog('close');
			}
		}
	});
	$("#editContact").dialog('open');
}
function saveEditContact(){
	var gender=$("#editContact input[name='gender']:checked").val()== undefined?'':$("#editContact input[name='gender']:checked").val();
	var filter=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if(gender==''){
		alert('Please Select gender!',''); return false;
	}else if(document.getElementById('fname').value==''){
		alert('Please Input First Name!',''); return false;
	}
	else {
		document.getElementById('contact_pic').style.display='none';
		document.getElementById('contact_load').style.display='block';
		if (sendReq.readyState == 4 || sendReq.readyState == 0) {
			sendReq.open("POST", "include/customer/edit_contact.php", true)
			sendReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			sendReq.onreadystatechange = function(){
				if (sendReq.readyState == 4 && sendReq.status == 200) {
					document.getElementById('text_load').innerHTML='Uploading Picture';
					$("#editContact #frm_logo").submit();
				}
			}
			var pos='';
			if($('#editContact #c_emp').get(0).checked){
				pos+=$('#editContact #c_emp').val()+'-';
			}
			if($('#editContact #c_man').get(0).checked){
				pos+=$('#editContact #c_man').val()+'-';
			}
			if($('#editContact #c_buyer').get(0).checked){
				pos+=$('#editContact #c_buyer').val()+'-';
			}
			if($('#editContact #c_owner').get(0).checked){
				pos+=$('#editContact #c_owner').val()+'-';
			}
			if($('#editContact #c_sale').get(0).checked){
				pos+=$('#editContact #c_sale').val()+'-';
			}
			var param = 'gender=' + gender;
			param += '&fname=' + $('#editContact #fname').val();
			param += '&lname=' + $('#editContact #lname').val();
			param += '&email=' + $('#editContact #email').val();
			//param += '&psw=' + $('#editContact #psw1').val();
			param += '&country_phone=' + $('#editContact #p1').val();
			param += '&area_phone=' + $('#editContact #p2').val();
			param += '&number_phone=' + $('#editContact #p3').val();
			param += '&mobile_country=' + $('#editContact #m1').val();
			param += '&mobile_area=' + $('#editContact #m2').val();
			param += '&mobile_number=' + $('#editContact #m3').val();
			param += '&bali_country=' + $('#editContact #b1').val();
			param += '&bali_area=' + $('#editContact #b2').val();
			param += '&bali_number=' + $('#editContact #b3').val();
			//param += '&fax_country=' + document.getElementById('f1').value;
			//param += '&fax_area=' + document.getElementById('f2').value;
			//param += '&fax_number=' + document.getElementById('f3').value;
			param += '&act=edit';
			param+='&phone_id='+$('#editContact #phone_id').val();
			param+='&mob_id='+$('#editContact #mob_id').val();
			param+='&bali_id='+$('#editContact #bali_id').val();
			//param+='&fax_id='+$('#editContact #fax_id').val();
			param+='&email_id='+$('#editContact #email_id').val();
			param+='&pos='+pos;
			param+='&party='+$('#editContact #pi').val();
			param+='&user_login='+$('#editContact #userlogin').val();
			for(var i=1;i<parseInt($('#editContact #jml_instant').val());i++){
				param+='&'+$('#editContact #idinstant'+i).val()+'='+$('#editContact #instant'+i).val();
				param+='&'+$('#editContact #idinstant'+i).val()+'Id='+$('#editContact #idinstantmech'+i).val();
			}
			param+='&jmlinstant='+$('#editContact #jml_instant').val();
			var jmlemail=parseInt($('#editContact #jumlahEmail').val());
			var eml='';
			for(var i=0;i<jmlemail;i++){
				eml+=$('#editContact #email'+i).value+'#'+$('#editContact #emailId'+i).value+'~';
			}
			param+='&party_remark='+escape($('#editContact #remark').val());
			param+='&noteId='+$('#editContact #noteId').val();
			param+='&emailData='+eml;
			sendReq.send(param);
		}
	}
}
function viewOrder(kode,party,cur){
	/*showDialog4('Back To Main Screen');
	document.getElementById('content_maxt').innerHTML='<div align="center"><img src="images/loading3.gif" alt="loading" align="absmiddle" /></div>';
	doRequest('get','include/customer/view_order_2_copy.php?oi='+kode,'text','content_maxt');*/
	NewWindow('include/order_view.php?odn='+kode+'&cr='+cur+'&pi='+party,'order_view',1000,700,'yes');
}
function getState(con,div,sel,sel1){
	if(sendReq.readyState==4 || sendReq.readyState==0){
		var doc=document.getElementById(div);
		doc.innerHTML='<div align="center"><img src="images/lbloading.gif" alt="loading" align="absmiddle" /></div>';
		sendReq.open('GET','include/pos/getGeoState.php?geo='+con+'&id='+sel+'&sel='+sel1,true);
		sendReq.onreadystatechange=function(){
			if(sendReq.readyState==4){
				if(sendReq.status==200){
					doc.innerHTML=sendReq.responseText;
				}
			}
		}
		sendReq.send(null);
	}
}

function getCountry(con,div,sel){
	//alert (con);
	if(xhtml.readyState==4 || xhtml.readyState==0){
		var doc=document.getElementById(div);
		doc.innerHTML='<div align="center"><img src="images/lbloading.gif" alt="loading" align="absmiddle" /></div>';
		xhtml.open('GET','include/pos/getGeoCountry.php?geo='+con+'&id='+sel+'&sel2='+div,true);
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4){
				if(xhtml.status==200){
					doc.innerHTML=xhtml.responseText;
				}
			}
		}
		xhtml.send(null);
	}
}
function changeUserLogin(user){
	var popup = new MoobbiePopup(600,'','','images/popup/');
	popup.setTitle('Lambada Jewelry');
	var xhtml=getXml();
	xhtml.open('GET','include/customer/changeUserLogin.php?userId='+user,true);
	xhtml.onreadystatechange=function(){
		if(xhtml.readyState==4){
			if(xhtml.status==200){
				popup.setContent(xhtml.responseText);
				if(document.getElementById('email').value!='' && document.getElementById('email').value!=document.getElementById('user_login_id').value){
					document.getElementById('cekuserlogin').innerHTML='<input type="checkbox" name="checkUser" id="checkUser" onclick="useEmail();" /> Use email address as user login';
				}
				popup.show();
				popup.popupFooter.innerHTML='';
				popup.addButton('Cancel',function(){},true);
			}
		}
	}
	xhtml.send(null);
	
}
function checkUserID(){
	if (document.formUserLogin.newUserLogin.value != '') {
		var popup = new MoobbiePopup(600, '', '', 'images/popup/');
		popup.setTitle('Lambada Jewelry');
		var xhtml = getXml();
		xhtml.open('GET', 'include/customer/changeUserLogin.php?action=check&userIdnew=' + escape(document.formUserLogin.newUserLogin.value) + '&userId=' + escape(document.getElementById('user_login_id').value), true);
		xhtml.onreadystatechange = function(){
			if (xhtml.readyState == 4) {
				if (xhtml.status == 200) {
					popup.setContent(xhtml.responseText);
					if(document.getElementById('email').value!='' && document.getElementById('email').value!=document.getElementById('user_login_id').value){
						document.getElementById('cekuserlogin').innerHTML='<input type="checkbox" name="checkUser" id="checkUser" onclick="useEmail();" /> Use email address as user login';
					}
					popup.show();
					popup.popupFooter.innerHTML='';
					popup.addButton('Cancel', function(){
					}, true);
				}
			}
		}
		xhtml.send(null);
	}else{
		alert('Please input your new user login first!');
	}
}
var oldUser;
function useEmail(){
	if(document.formUserLogin.checkUser.checked){
		oldUser=document.formUserLogin.newUserLogin.value;
		document.formUserLogin.newUserLogin.value=document.getElementById('email').value;
		checkUserID();
	}else{
		document.formUserLogin.newUserLogin.value = oldUser;
	}
}
function noChangeUserLogin(){
	document.getElementById('yesNo').style.display='none';
}
function afterChangeUserLogin(newUser){
	var popup = new MoobbiePopup(600, '', '', 'images/popup/');
	popup.hide();
	document.getElementById('user_login_id').value=newUser;
}
function blockAccess(txt,act){
	var message = new MoobbieVanilaMessage('alert');
	message.setTitle(document.title+' - Moobbie');
	message.setContent(txt);
	message.addButton('OK',function(){
		if(act){
			if(typeof act == 'function'){
				act();
			}
		}
	},true);
	message.show();
	return false;
}

