// JavaScript Document
function getXMLHttp(){
if(window.ActiveXObject){
	return new ActiveXObject('Microsoft.XMLHTTP');
}else if(window.XMLHttpRequest){
	return new XMLHttpRequest();
}else alert("Can not create XMLHttpRequest");
}
var xmlhttp=getXMLHttp();
var xhtml=getXMLHttp();
var sendReq=getXMLHttp();

var ShipAddress1 = "";
var ShipAddress2 = "";
var ShipCity = "";
var ShipCountry = "";
var ShipState = "";
var ShipStateIndex = 0;
var ShipZip = "";
var alert_icon='<img src="images/alert/alert.gif" alt="Alert" align="absmiddle" width="85" height="80" />';
var confirm_icon='<img src="images/alert/confirm.gif" alt="Alert" align="absmiddle" width="85" height="80" />';

//var ShipFirst = "";
//var ShipLast = "";
//var ShipEmail = "";
//var ShipCompany = "";
//var ShipTelephone = "";

function InitSaveVariables(form4) {
ShipAddress1 = form4.sadd1.value;
ShipAddress2 = form4.sadd2.value;
ShipCity = form4.scity.value;
ShipCountry = form4.scountry.value;
ShipStateIndex = form4.sstate.selectedIndex;
ShipState = form4.sstate.value;
ShipZip = form4.szip.value;

//ShipFirst = form.ShipFirst.value;
//ShipLast = form.ShipLast.value;
//ShipEmail = form.ShipEmail.value;
//ShipCompany = form.ShipCompany.value;
//ShipTelephone = form.ShipTelephone.value;
}

function ShipToBillPerson(form4) {
	
if (form4.copy.checked) {
	
InitSaveVariables(form4);
//alert(form1.badd1.value);
form4.sadd1.value = form4.badd1.value;
form4.sadd2.value = form4.badd2.value;
form4.scity.value = form4.bcity.value;
form4.scountry.value = form4.bcountry.value;
form4.sstate.value = form4.bstate.value;
form4.szip.value = form4.bzip.value;

//form.ShipFirst.value = form.BillFirst.value;
//form.ShipLast.value = form.BillLast.value;
//form.ShipEmail.value = form.BillEmail.value;
//form.ShipCompany.value = form.BillCompany.value;
//form.ShipTelephone.value = form.BillTelephone.value;
}
else 
{
form4.sadd1.value = ShipAddress1;
form4.sadd2.value = ShipAddress2;
form4.scity.value = ShipCity;
form4.scountry.value = ShipCountry;
form4.sstate.value = ShipState;
form4.szip.value = ShipZip;  

//form.ShipFirst.value = ShipFirst;
//form.ShipLast.value = ShipLast;
//form.ShipEmail.value = ShipEmail;
//form.ShipCompany.value = ShipCompany;
//form.ShipTelephone.value = ShipTelephone;
   }
}

function tab_change(active){
	var tab1='tab';
	var tab2='tab';
	var tab3='tab';
	var tab4='tab';
	var tab5='tab';
	if(active==1) tab1='tab_active';
	if(active==2) tab2='tab_active';
	if(active==3) tab3='tab_active';
	if(active==4) tab4='tab_active';
	if(active==5) tab5='tab_active';
document.getElementById('tabx').innerHTML='<div class="'+tab1+'"><a href="member-history.php?act=profile">Customer Information</a></div>'+
'<div class="'+tab2+'"><a href="#" onclick="tab_change(2); getContact(); return false">Other Contacts</a></div>'+
'<div class="'+tab3+'"><a href="#" onclick="tab_change(3); return false">Carrier</a></div>'+
'<div class="'+tab4+'"><a href="#" onclick="tab_change(4); return false">Agent</a></div>'+
'<div class="'+tab5+'"><a href="#" onclick="tab_change(5); return false">Add Logo</a></div>';
//alert(document.getElementById('tabx').innerHTML);
}

function showAlert(){
	//document.getElementById('prd_qty').value='';
var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }

var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }


var winl=(viewportwidth-300)/2;
var wint=(viewportheight-400)/2+scrOfY;


//document.getElementById('numeric_pad').style.left=winl+'px';
//document.getElementById('numeric_pad').style.top=wint+'px';
//document.getElementById('numeric_pad').style.display='block';
ph=new Array();
ph=getPageSizeWithScroll();
if(ph[1]<viewportheight) ph[1]=viewportheight;
document.getElementById('alert').style.height=viewportheight+'px';
document.getElementById('alert').style.width=(viewportwidth-20)+'px';
document.getElementById('alert').style.display='block';
document.getElementById('alert').style.top=scrOfY+'px';
}

function getContact(){
if(xmlhttp.readyState==0 || xmlhttp.readyState==4){
	document.getElementById('tabx').style.background='url(images/tab_02.gif) left top no-repeat';
	document.getElementById('content_profile').innerHTML='<div align="center"><img src="images/loading3.gif" alt="loading" /></div>'
	xmlhttp.open('get','include/profile/get_contact.php',true);
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			if(xmlhttp.status==200){
				document.getElementById('content_profile').innerHTML=xmlhttp.responseText;
			}else alert("Error : "+xmlhttp.statusText);
		}
	}
	xmlhttp.send(null);
}
}
function getCarrier(){
if(xmlhttp.readyState==0 || xmlhttp.readyState==4){
	document.getElementById('tabx').style.background='url(images/tab_03.gif) left top no-repeat';
	document.getElementById('content_profile').innerHTML='<div align="center"><img src="images/loading3.gif" alt="loading" /></div>'
	xmlhttp.open('get','include/profile/get_carrier.php',true);
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			if(xmlhttp.status==200){
				document.getElementById('content_profile').innerHTML=xmlhttp.responseText;
			}else alert("Error : "+xmlhttp.statusText);
		}
	}
	xmlhttp.send(null);
}
}
function getAgent(){
if(xmlhttp.readyState==0 || xmlhttp.readyState==4){
	document.getElementById('tabx').style.background='url(images/tab_04.gif) left top no-repeat';
	document.getElementById('content_profile').innerHTML='<div align="center"><img src="images/loading3.gif" alt="loading" /></div>'
	xmlhttp.open('get','include/profile/get_agent.php',true);
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			if(xmlhttp.status==200){
				document.getElementById('content_profile').innerHTML=xmlhttp.responseText;
			}else alert("Error : "+xmlhttp.statusText);
		}
	}
	xmlhttp.send(null);
}
}
function getLogo(){
if(xmlhttp.readyState==0 || xmlhttp.readyState==4){
	document.getElementById('tabx').style.background='url(images/tab_05.gif) left top no-repeat';
	document.getElementById('content_profile').innerHTML='<div align="center"><img src="images/loading3.gif" alt="loading" /></div>'
	xmlhttp.open('get','include/profile/logo.php',true);
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			if(xmlhttp.status==200){
				document.getElementById('content_profile').innerHTML=xmlhttp.responseText;
			}else alert("Error : "+xmlhttp.statusText);
		}
	}
	xmlhttp.send(null);
}
}
function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	return arrayPageSizeWithScroll;
}
function showDialog4(title){
document.getElementById('content_profile').style.display='none';
var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }

var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }


var winl=(viewportwidth-800)/2;
var wint=(viewportheight-500)/2+scrOfY;


/*document.getElementById('pic').style.left=winl+'px';
document.getElementById('pic').style.top=wint+'px';
document.getElementById('pic').style.display='block';*/
ph=new Array();
ph=getPageSizeWithScroll();
if(ph[1]<viewportheight) ph[1]=viewportheight;
document.getElementById('maximize').style.height=viewportheight+'px';
document.getElementById('maximize').style.width=(ph[0])+'px';
document.getElementById('maximize1').style.height=viewportheight+'px';
document.getElementById('maximize1').style.width=(ph[0])+'px';
//alert(ph[0]);
//alert(ph[1]);
document.getElementById('xxt').style.height = (viewportheight-15) + 'px';
document.getElementById('xxt2').style.height=(viewportheight - 45) + 'px';
//document.getElementById('xxt').style.margin='5px auto';
document.getElementById('slide').style.display='none';
/*document.getElementById('xx3').innerHTML='<a href="#" onclick="document.getElementById(\'maximize\').style.display=\'none\'; document.getElementById(\'blok_frame\').style.display=\'none\'; return false;" style="color:red; text-decoration:none;"><img src="images/pos/close.jpg" alt="close" title="close" border="0" align="absmiddle" width="25" height="25" /></a>&nbsp;&nbsp;</span>';*/
document.getElementById('xxt').style.width='98%';
document.getElementById('maximizex').style.display='block';
document.getElementById('title_pack').innerHTML=title;
document.getElementById('content_maxt').scrollTop=0;
}

function showDialog(){
if(document.getElementById('content_profile')) document.getElementById('content_profile').style.display='none';
if(document.getElementById('slide')) document.getElementById('slide').style.display='none';
var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }

var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }


var winl=(viewportwidth-800)/2;
var wint=(viewportheight-500)/2+scrOfY;


/*document.getElementById('pic').style.left=winl+'px';
document.getElementById('pic').style.top=wint+'px';
document.getElementById('pic').style.display='block';*/
ph=new Array();
ph=getPageSizeWithScroll();
if(ph[1]<viewportheight) ph[1]=viewportheight;
document.getElementById('maximize').style.height=viewportheight+'px';
document.getElementById('maximize').style.width=ph[0]+'px';
document.getElementById('maximize1').style.height=viewportheight+'px';
document.getElementById('maximize1').style.width=ph[0]+'px';
//alert(ph[0]);
//alert(ph[1]);
//alert(viewportheight);
document.getElementById('xx').style.height = (viewportheight-15) + 'px';
document.getElementById('xx2').style.height=(viewportheight - 155) + 'px';
/*if (890 <= (viewportheight - 30)) {
	document.getElementById('xx').style.height = '890px';
	document.getElementById('xx2').style.height='770px';
	max_h=890;
	
}
else {
	document.getElementById('xx').style.height = (viewportheight - 45) + 'px';
	document.getElementById('xx2').style.height=(viewportheight - 189) + 'px';
	max_h=viewportheight - 45;
}*/

document.getElementById('xx').style.margin='5px auto';
document.getElementById('xx').style.width='98%';
document.getElementById('xx2').style.backgroundColor='#65aff8';
document.getElementById('maximize').style.display='block';
document.getElementById('content_max').scrollTop=0;
}

function viewMoreEmail(){
	showDialog4('Back To Main Screen');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading3.gif"  alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/profile/view_more_email.php','text','content_maxt');
}
function yesDelEmail(kode,party){
	document.getElementById('loading1').innerHTML='<img src="images/loading3.gif"  alt="loading" />';
	doRequest('get','include/profile/view_more_email.php?pi='+party+'&kode='+kode+'&act=rem','text','content_maxt');
}
function delEmail(kode,party){
	var yes='yesDelEmail(\''+kode+'\',\''+party+'\')';
	confirmMsg('Are you sure to delete this email?',yes,'','');
}
function editEmailN(kode,x){
	document.getElementById('loading1').innerHTML='<img src="images/loading3.gif" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('GET','include/profile/view_more_email.php?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 addEmailN(){
	showDialog4('Back To Main Screen');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading3.gif"  alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/profile/more_email.php','text','content_maxt');
}
function saveEmailN(x){
	document.getElementById('loading1').innerHTML='<img src="images/loading3.gif"  alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('POST','include/profile/more_email.php',true);
		xhtml.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200){
				if (xhtml.responseText != 'gagal') {
					document.getElementById('content_maxt').innerHTML = xhtml.responseText;
					alertMsg('L&rsquo;email a &eacute;t&eacute;  sauv&eacute;.','');
				//showUpdateX(party);
				}else{
					alertMsg('Adresse email non valide','');
					document.getElementById('loading1').innerHTML='';
				}
			}
		}
		
		var param='jenis='+document.getElementById('jenis'+x).value;
		param+='&email='+document.getElementById('temail'+x).value;
		param+='&act=save';
		xhtml.send(param);
	}
}
function viewMorePhone(){
	showDialog4('Back To Main Screen');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading3.gif"  alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/profile/view_more_phone.php','text','content_maxt');
}
function yesDelPhone(kode){
	document.getElementById('loading1').innerHTML='<img src="images/loading3.gif"  alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/profile/view_more_phone.php?kode='+kode+'&act=rem','text','content_maxt');
}
function delPhone(kode){
	var yes='yesDelPhone(\''+kode+'\')';
	confirmMsg('Are you sure to delete this Phone number?',yes,'','');
}
function editPhoneN(kode,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/profile/view_more_phone.php?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 addPhoneN(){
	showDialog4('Back To Main Screen');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading3.gif"  alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/profile/more_phone.php','text','content_maxt');
}
function savePhoneN(x){
	document.getElementById('loading1').innerHTML='<img src="images/loading3.gif" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('POST','include/profile/more_phone.php',true);
		xhtml.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200){
				if (xhtml.responseText != 'gagal') {
					document.getElementById('content_maxt').innerHTML = xhtml.responseText;
					alertMsg('Le nouveau  num&eacute;ro de t&eacute;l&eacute;phone a &eacute;t&eacute; sauv&eacute;.','');
				}else{
					alertMsg('Erreur dans le num&eacute;ro de  t&eacute;l&eacute;phone','');
					document.getElementById('loading1').innerHTML='';
					//doRequest('get','include/profile/more_phone.php','text','content_maxt');
				}
				//showUpdateX(party);
			}
		}
		
		var 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 addShipN(){
	showDialog4('Back To Main Screen');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading3.gif"  alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/profile/more_shipping.php','text','content_maxt');
}
function viewMoreShip(){
	showDialog4('Back To Main Screen');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading3.gif"  alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/profile/view_more_shipping.php','text','content_maxt');
}

function editShippingN(x){
	var filterzip=/^\d{5}$|^\d{5}-\d{4}$/;
	if(document.getElementById('toname'+x).value==''){
		alertMsg('SVP saisissez Au Nom de!','');
	}else
	if (document.getElementById('tadd1'+x).value == '') {
	alertMsg('SVP saisissez l&rsquo;adresse!','');
	}else if(document.getElementById('tcity'+x).value==''){
		alertMsg('SVP saisissez la ville!','');
	}else if(document.getElementById('tzip'+x).value==''){
		alertMsg('SVP saisissez le code postal!','');
	}else if(!filterzip.test(document.getElementById('tzip'+x).value)){
		alertMsg('code postal invalide');
	}else if(document.getElementById('tcountry'+x).value==''){
		alertMsg('SVP choisissez le pays!','');
	}
	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/profile/view_more_shipping.php', 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 = 'tadd1=' + document.getElementById('tadd1'+x).value;
			param += '&tadd2=' + document.getElementById('tadd2'+x).value;
			param += '&tcity=' + 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='+document.getElementById('tattn_name'+x).value;
			param+='&toname='+document.getElementById('toname'+x).value;
			param+='&ship_id='+document.getElementById('tship_id'+x).value;
			xhtml.send(param);
		}
	}
}
function yesDelShip(kode){
	document.getElementById('loading1').innerHTML='<img src="images/loading3.gif"  alt="loading" />';
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('GET','include/profile/view_more_shipping.php?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 delShip(kode){
	var yes='yesDelShip(\''+kode+'\')';
	confirmMsg('Are you sure to delete this Shipping Address?',yes,'','');
}
function saveShippingN(){
	var filterzip=/^\d{5}$|^\d{5}-\d{4}$/;
	if(document.getElementById('toname').value==''){
		alertMsg('SVP saisissez Au Nom de!','');
	}else
	if (document.getElementById('tadd1').value == '') {
	alertMsg('SVP saisissez l&rsquo;adresse!','');
	}else if(document.getElementById('tcity').value==''){
		alertMsg('SVP saisissez la ville!','');
	}else if(document.getElementById('tzip').value==''){
		alertMsg('SVP saisissez le code postal!','');
	}else if(!filterzip.test(document.getElementById('tzip').value)){
		alertMsg('code postal invalide');
	}else if(document.getElementById('tcountry').value==''){
		alertMsg('SVP choisissez le pays!','');
	}
	else {
		document.getElementById('loading1').innerHTML = '<img src="images/loading3.gif" alt="loading" />';
		if (xhtml.readyState == 4 || xhtml.readyState == 0) {
			xhtml.open('POST', 'include/profile/more_shipping.php', 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;
					alertMsg('Nouvelle adresse d\'exp&eacute;dition a &eacute;t&eacute; sauv&eacute;.','');
					//showUpdateX(party);
					document.getElementById('maximizex').style.display = 'none';
					document.getElementById('content_profile').style.display='block';
					document.getElementById('slide').style.display='block';
				}
			}
			var param = 'tadd1=' + document.getElementById('tadd1').value;
			param += '&tadd2=' + document.getElementById('tadd2').value;
			param += '&tcity=' + 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='+document.getElementById('tattn_name').value;
			param+='&toname='+document.getElementById('toname').value;
			xhtml.send(param);
		}
	}
}
function getPicture(){
	showDialog4('Back To Main Screen');
	if(xhtml.readyState==4 || xhtml.readyState==0){
		document.getElementById('content_maxt').innerHTML='<img src="images/loading3.gif" alt="Loading" align="absmiddle" />Loading....';
		xhtml.open('GET','include/profile/picture.php',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/loading3.gif" alt="Loading"  align="absmiddle" />Loading....';
		xhtml.open('GET','include/profile/picture.php',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;
				window.location.href='member-history.php?act=profile';
				//document.getElementById('content2').innerHTML='';
			}
		}
		xhtml.send(null);
	}
}
function doUpdate(){
	//act=document.getElementById('act').value;
	//alert('test1');
	var gender='';
		if(document.updates.gender[0].checked){
		gender=document.updates.gender[0].value;	
		}else if(document.updates.gender[1].checked){
			gender=document.updates.gender[1].value;
		}
	
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		sendReq.open("POST", 'member-history.php?ui='+document.getElementById('party_id').value, true);
		sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		sendReq.onreadystatechange = function(){
			if(sendReq.readyState==4 && sendReq.status==200){
				alertMsg('Votre profile a &eacute;t&eacute; mis &agrave;  jour','');
				window.location.href='member-history.php?act=profile';
			}
		}
		var param = 'party_id=' + document.getElementById('party_id').value;
		param += '&company='+document.getElementById('company').value;
		param +='&name='+document.getElementById('fname').value+'~'+document.getElementById('lname').value;
		param +='&contact_mech_mail='+document.getElementById('email_id').value;
		param +='&email='+document.getElementById('email').value;
		param +='&b_state='+document.getElementById('bstate').value;
		param +='&s_state='+document.getElementById('sstate').value;
		param +='&contact_mech_bill='+document.getElementById('bill_id').value;
		param +='&b_address1='+document.getElementById('badd1').value;
		param +='&b_address2='+document.getElementById('badd2').value;
		param +='&b_city='+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='+document.getElementById('sadd1').value;
		param +='&s_address2='+document.getElementById('sadd2').value;
		param +='&s_city='+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('psw1').value;
		param +='&password1='+document.getElementById('psw2').value;
		param +='&user_id='+document.getElementById('user_id').value;
		param +='&action=update_profile';
		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='';
		//alert('test2');
		for (var i=0; i < document.form1.class_pty.length; i++){
			if (document.form1.class_pty[i].checked){
					class_pty=document.form1.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;	
				
		//alert('gender'+gender);
		sendReq.send(param);
		document.getElementById('content_profile').innerHTML='<div align="center"><img src="images/loading3.gif" alt="loading" > <br>Please Wait....</div>';
	}	
}
function viewNewContact(){
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		showDialog4('Back to Main Screen');
		document.getElementById('content_maxt').innerHTML='<div align="center"><img src="images/loading3.gif" alt="loading" > <br>Please Wait....</div>';
		sendReq.open("POST", 'include/profile/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){
			document.getElementById('content_maxt').innerHTML=sendReq.responseText;
			}
		}
		sendReq.send(null);
	}
}
function saveContact(){
	//alert('test');
	var gender='';
		if(document.form_gen.gender[0].checked){
		gender=document.form_gen.gender[0].value;	
		}else if(document.form_gen.gender[1].checked){
			gender=document.form_gen.gender[1].value;
		}
	var filter=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if(gender==''){
		alertMsg('SVP selectionnez votre  civilit&eacute;!',''); return false;
	}else if(document.getElementById('fname').value==''){
		alertMsg('SVP saisissez votre pr&eacute;nom!',''); return false;
	}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) {
		alertMsg('SVP choisissez une position dans la compagnie',''); return false;
	}else if(document.getElementById('email').value==''){
		alertMsg('SVP saisissez votre adresse email!',''); 
		document.getElementById('email').focus(); return false;
	}else if(!filter.test(document.getElementById('email').value)){
		alertMsg('Adresse email non valide','');
		document.getElementById('email').foucs(); return false;
	}/*else if(document.getElementById('psw1').value==''){
		alertMsg('Please input password!','');
		document.getElementById('psw1').focus(); return false;
	}else if(document.getElementById('psw2').value==''){
		alertMsg('Please input confirm password!','');
		document.getElementById('psw2').focus(); return false;
	}else if(document.getElementById('psw1').value!=document.getElementById('psw2').value){
		alertMsg('Password and Confirm password must be the same!','');
		document.getElementById('psw1').focus(); return false;
	}*/else if(document.getElementById('p1').value=='' || document.getElementById('p2').value=='' || document.getElementById('p3').value=='' ){
		alertMsg('SVP saisissez votre num&eacute;ro  de t&eacute;l&eacute;phone!','');
		document.getElementById('p1').focus(); 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/profile/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);
					document.getElementById('pi').value = sendReq.responseText.replace(/<div>/,"");
					document.getElementById('text_load').innerHTML='Uploading Picture';
					document.frm_logo.submit();
					return true;
				}
			}
			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 param = 'gender=' + gender;
			param += '&fname=' + document.getElementById('fname').value;
			param += '&lname=' + document.getElementById('lname').value;
			param += '&email=' + document.getElementById('email').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+='&pos='+pos;
			sendReq.send(param);
			//document.getElementById('contentx').style.display = 'none';
		}
	}
}
function afterAddContact(){
	getContact();
	document.getElementById('maximizex').style.display='none';
	document.getElementById('content_profile').style.display='block'; 
	document.getElementById('slide').style.display='block';
}
function yesDelEmp(kode){
	var vl = document.getElementById('hide_pito' + kode).value;
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		sendReq.open("POST", 'include/profile/get_contact.php', true);
		sendReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		sendReq.onreadystatechange = function(){
			if (sendReq.status == 200 && sendReq.readyState == 4) 
				document.getElementById('content_profile').innerHTML = sendReq.responseText;
		}
		sendReq.send('act=del&party_id_from=' + document.getElementById('cus_id_xxx').innerHTML + '&party_id_to=' + vl);
	}
}
function delEmp(kode){
	var yes='yesDelEmp(\''+kode+'\')';
	confirmMsg("Are you sure to delete this contact?",yes,'','');
}
function yesDelCarrier(kode){
	var vl=document.getElementById('hide_pito'+kode).value;
		document.getElementById('loadingx').innerHTML='<img src="images/loading3.gif" alt="loading" >';
		if(sendReq.readyState==4 || sendReq.readyState==0){
			sendReq.open("POST",'include/profile/get_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_profile').innerHTML=sendReq.responseText;
			}
			sendReq.send('act=del&party_id_from='+document.getElementById('cus_id_xxx').innerHTML+'&party_id_to='+vl);
		}
}
function delCarrier(kode){
	var yes='yesDelCarrier(\''+kode+'\')';
	confirmMsg("Are you sure to delete this carrier?",yes,'','');
}
function showSelCarrier(){
	showDialog4('Back To Main Screen');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading3.gif" alt="loading"  />';
	doRequest('get','include/profile/add_carrier2.php','text','content_maxt');
}
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('SVP choisissez une option pour votre recherche!','');
	}
	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 saveSelCarrier(kode){
	if(document.getElementById('pt_id'+kode).innerHTML==''){
		alertMsg('SVP choisissez un transporteur!','');
	}else{
		if(sendReq.readyState==4 || sendReq.readyState==0){
		sendReq.open("POST", 'include/profile/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;
				getCarrier();
				document.getElementById('maximizex').style.display = 'none';
				document.getElementById('content_profile').style.display='block'; 
				document.getElementById('slide').style.display='block';
			}
		}
		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 showSelCarrier2(kode){
	document.getElementById('content_maxt').innerHTML+='<img src="images/loading3.gif"  alt="loading" />';
	doRequest('get','include/profile/add_carrier2.php?search='+kode,'text','content_maxt');
}
function viewNewCarrier(){
	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/loading3.gif" alt="loading"  /></td>' +
		'</tr>' +
		' </table>';
	//document.getElementById('content_maxt').innerHTML='testing';
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		
		sendReq.open("POST", 'include/profile/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(null);
	}
}
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;
		}
		//alert('test');
	var filter=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if(gender==''){
		alertMsg('SVP selectionnez votre  civilit&eacute;!','');
	}else if(document.getElementById('fname').value==''){
		alertMsg('SVP saisissez votre pr&eacute;nom!','');
	}else if(document.getElementById('email').value==''){
		alertMsg('SVP saisissez votre adresse email!','');
		document.getElementById('email').focus();
	}else if(!filter.test(document.getElementById('email').value)){
		alertMsg('SVP v&eacute;rifiez  votre adresse email','');
		document.getElementById('email').foucs();
	}/*else if(document.getElementById('psw1').value==''){
		alertMsg('Please input password!','');
		document.getElementById('psw1').focus();
	}else if(document.getElementById('psw2').value==''){
		alertMsg('Please input confirm password!','');
		document.getElementById('psw2').focus();
	}else if(document.getElementById('psw1').value!=document.getElementById('psw2').value){
		alertMsg('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=='' ){
		alertMsg('SVP saisissez votre num&eacute;ro  de t&eacute;l&eacute;phone!','');
		document.getElementById('p1').focus();
	}else if(document.getElementById('company').value==''){
		alertMsg('SVP saisissez le nom de votre conpagnie!','');
	}else if(document.getElementById('badd1').value==''){
		alertMsg('SVP saisissez une adresse','');
	}else if(document.getElementById('bcity').value==''){
		alertMsg('SVP saisissez la ville','');
	}else if(document.getElementById('bzip').value==''){
		alertMsg('SVP saisissez le code postal','');
	}else if(document.getElementById('bcountry').value==''){
		alertMsg("SVP choisissez le pays!",'');
	}else{
		if(sendReq.readyState==4 || sendReq.readyState==0){
			sendReq.open("POST","include/profile/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;
					getCarrier();
				//document.getElementById('maximizex').style.display = 'none';
				//document.getElementById('content_profile').style.display='block'; 
				//document.getElementById('slide').style.display='block';
				}
			}
			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;
			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/loading3.gif"  alt="loading" /></td>' +
		'</tr>' +
		' </table>';
		}
	}	
}
function showSelAgent(){
	showDialog4('Back To Main Screen');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading3.gif" alt="loading" style="filter:alpha(opacity=100); opacity:1;" />';
	doRequest('get','include/profile/add_agent2.php','text','content_maxt');
}
function yesDelAgent(kode){
	var vl=document.getElementById('hide_pito'+kode).value;
		if(sendReq.readyState==4 || sendReq.readyState==0){
			sendReq.open("POST",'include/profile/get_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_profile').innerHTML = sendReq.responseText;
				}
			}
			sendReq.send('act=del&party_id_from='+document.getElementById('cus_id_xxx').innerHTML+'&party_id_to='+vl);
			document.getElementById('content_profile').innerHTML='<img src="images/loading3.gif" alt="loading" />';
		}
}
function delAgent(kode){
	var yes='yesDelAgent(\''+kode+'\')';
	confirmMsg("Are you sure to delete?",yes,'','');
}
function viewNewAgent(){
	showDialog4('Back to main 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/loading3.gif"  alt="loading"  /></td>' +
		'</tr>' +
		' </table>';
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		sendReq.open("POST", 'include/profile/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;
		}
		sendReq.send(null);
	}
}
function showSelAgent2(kode){
	document.getElementById('content_maxt').innerHTML+='<img src="images/loading3.gif"  alt="loading"  />';
	doRequest('get','include/profile/add_agent2.php?search='+kode,'text','content_maxt');
}
function saveSelAgent(kode){
	if(document.getElementById('pt_id'+kode).innerHTML==''){
		alertMsg('SVP choisissez un agent!','');
	}else{
		if(sendReq.readyState==4 || sendReq.readyState==0){
		sendReq.open("POST", 'include/profile/add_agent2.php', true);
		sendReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		sendReq.onreadystatechange = function(){
			document.getElementById('content_maxt').innerHTML=sendReq.responseText;
			getAgent();	
			document.getElementById('maximizex').style.display='none';
			document.getElementById('content_profile').style.display='block'; 
			document.getElementById('slide').style.display='block';
		}
		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/loading3.gif" alt="loading" /></td>' +
		'</tr>' +
		' </table>';
		}
		
	}
}
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==''){
		alertMsg('SVP selectionnez votre  civilit&eacute;!','');
	}else if(document.getElementById('fname').value==''){
		alertMsg('SVP saisissez votre pr&eacute;nom!','');
	}else if(document.getElementById('email').value==''){
		alertMsg('SVP saisissez votre adresse email!','');
		document.getElementById('email').focus();
	}else if(!filter.test(document.getElementById('email').value)){
		alertMsg('SVP v&eacute;rifiez  votre adresse email','');
		document.getElementById('email').focus();
	}/*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=='' ){
		alertMsg('SVP saisissez votre num&eacute;ro  de t&eacute;l&eacute;phone!','');
		document.getElementById('p1').focus();
	}else if(document.getElementById('company').value==''){
		alertMsg('SVP saisissez le nom de votre conpagnie!','');
	}else if(document.getElementById('badd1').value==''){
		alertMsg('SVP saisissez une adresse','');
	}else if(document.getElementById('bcity').value==''){
		alertMsg('SVP saisissez la ville','');
	}else if(document.getElementById('bzip').value==''){
		alertMsg('SVP saisissez le code postal','');
	}else if(document.getElementById('bcountry').value==''){
		alertMsg("SVP choisissez le pays!",'');
	}else{
		if(sendReq.readyState==4 || sendReq.readyState==0){
			sendReq.open("POST","include/profile/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;
					getAgent();	
					//document.getElementById('maximizex').style.display='none';
					//document.getElementById('content_profile').style.display='block'; 
					//document.getElementById('slide').style.display='block';
				}
			}
			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;
			//alert('test');
			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/loading3.gif" alt="loading"  /></td>' +
		'</tr>' +
		' </table>';
		}
	}
}
function getLogoX(){
	if(xhtml.readyState==4 || xhtml.readyState==0){
		document.getElementById('content_profile').innerHTML='<div align="center"><img src="images/loading3.gif" alt="Loading"  align="absmiddle" /> Loading....</div>';
		xhtml.open('GET','include/profile/logo.php',true);
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200){
				//document.getElementById('tab').style.background='url(images/pos/logo_03.jpg) left bottom no-repeat';
				document.getElementById('content_profile').innerHTML=xhtml.responseText;
			}
		}
		xhtml.send(null);
	}
}
function viewOrder(kode){
	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/profile/view_order_2_copy.php?oi='+kode,'text','content_maxt');
}

function viewTempOrder(){
	document.getElementById('tabx').style.background='url(images/tab_01b.gif) left top no-repeat';
	document.getElementById('content_profile').innerHTML='<div align="center"><img src="images/loading3.gif" alt="loading" align="absmiddle" /></div>';
	doRequest('get','include/profile/open_order.php','text','content_profile');
}
function continueOrderX(productStoreId){
	if(sendReq.readyState==4 || sendReq.readyState==0){
		showDialog();
		document.getElementById('content_max').innerHTML='<div align="center"><img src="images/loading3.gif" alt="loading" align="absmiddle" /></div>';
		sendReq.open('GET','include/profile/continue_order.php?productStoreId=' + productStoreId,true);
		sendReq.onreadystatechange=function(){
			if(sendReq.readyState==4){
				if(sendReq.status==200){
					document.getElementById('maximizex').style.display='none';
					window.location.href='online_shop.php';
					//document.getElementById('content_profile').innerHTML=sendReq.responseText;
					//showOrderDetail();
				}else{
					alert("Error : "+sendReq.statusText);
				}
			}
		}
		sendReq.send(null);
	}
}

function showOrderDetail(){
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		showDialog();
		document.getElementById('content_max').innerHTML='<div align="center"><img src="images/loading3.gif" alt="loading" align="absmiddle" /></div>';
		sendReq.open('GET','include/profile/get_oder.php',true);
		sendReq.onreadystatechange=function(){
			if(sendReq.readyState==4){
				if(sendReq.status==200){
					document.getElementById('content_max').innerHTML=sendReq.responseText;
					document.getElementById('buttonx').innerHTML='<div align="right" style="padding-right:20px;"><button onclick="saveOrder(); return false;">Save Order</button><button onclick="showShipment(); return false;">Finalize Order</button></div>';
				}else
				alert("Error : "+sendReq.statusText);
			}
		}
		sendReq.send(null);
	}
}

function showOrderDetail2(){
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		showDialog4('Back to main screen');
		
		document.getElementById('content_maxt').innerHTML='<div align="center"><img src="images/loading3.gif" alt="loading" align="absmiddle" /></div>';
		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;
					
					//document.getElementById('buttonx').innerHTML='<div align="right" style="padding-right:20px;"><button onclick="saveOrder(); return false;">Save Order</button><button onclick="showShipment(); return false;">Finalize Order</button></div>';
				}else
				alert("Error : "+sendReq.statusText);
			}
		}
		sendReq.send(null);
	}
}

function showOrderDetail3(productStoreId){
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		showDialog();
		document.getElementById('buttonx').innerHTML='';
		document.getElementById('content_max').innerHTML='<div align="center"><img src="images/loading3.gif" alt="loading" align="absmiddle" /></div>';
		sendReq.open('GET','include/profile/open_order.php?productStoreId='+productStoreId,true);
		sendReq.onreadystatechange=function(){
			if(sendReq.readyState==4){
				if(sendReq.status==200){
					document.getElementById('content_max').innerHTML=sendReq.responseText;
					
				}else
				alert("Error : "+sendReq.statusText);
			}
		}
		sendReq.send(null);
	}
}

function onUpdateCal(){
	document.getElementById('show_d2').innerHTML=document.getElementById('show_d1').innerHTML;
}
function onUpdateCal2(){
	document.getElementById('show_d1').innerHTML=document.getElementById('show_d2').innerHTML;
}
/*function onUpdateCal(){
	document.getElementById('show_d2').innerHTML=document.getElementById('show_d1').innerHTML;
}*/
function createCalender1(){
    Calendar.setup({
        inputField     :    "f_date_d",     // id of the input field
        ifFormat       :    "%Y-%m-%d",     // format of the input field (even if hidden, this format will be honored)
        displayArea    :    "show_d1",       // ID of the span where the date is to be shown
        daFormat       :    "%A, %B %d, %Y",// format of the displayed date
        button         :    "f_trigger_e",  // trigger button (well, IMG in our case)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true,
		onUpdate       :    onUpdateCal
    });
}
function createCalender2(){
    Calendar.setup({
        inputField     :    "f_date_d",     // id of the input field
        ifFormat       :    "%Y-%m-%d",     // format of the input field (even if hidden, this format will be honored)
        displayArea    :    "show_d2",       // ID of the span where the date is to be shown
        daFormat       :    "%A, %B %d, %Y",// format of the displayed date
        button         :    "f_trigger_e2",  // trigger button (well, IMG in our case)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true,
		onUpdate       :    onUpdateCal2
    });
}
function changeDelDate(){
	if (document.getElementById('new_del_date')) {
		doRequest('get', 'include/profile/change_deldate.php?date=' + document.getElementById('f_date_d').value+'&act=show', 'text', 'new_del_date');
	}
	else {
		doRequest('get', 'include/profile/change_deldate.php?date=' + document.getElementById('f_date_d').value, 'text', 'content_maxt');
	}
}
function showEditBtn(kode){
	document.getElementById('editBtn'+kode).style.display='inline';
}

function yesEditCart(key,kode,inc,qty){
document.getElementById('loading1').innerHTML ='<img src="images/loading3.gif" alt="loading" align="absmiddle" />';
pi = kode;
doRequest('get', 'include/profile/get_oder.php?kode=' + pi + '&vl=' + (qty/inc) + '&act=edit&key='+key+'&inc='+inc, 'text', 'content_max');
}

function editCart(key,kode,inc,b4){
		qty=document.getElementById('prd_qty'+kode).value;
		if (qty > 0) {
			var md=qty%inc;
			if(md!=0){
				if (parseInt(qty) < parseInt(inc)) 
					qty1 = inc;
				else {
					var xx = inc - md;
					qtyx = parseInt(qty) + parseInt(xx);
					var xxx=inc/2;
					var xx1=qty%inc;
					var qty2=qty-xx1;
					if(parseInt(xx)>parseInt(xxx)) qty1=qty2; else qty1=qtyx;
				}
				var yes='qty = '+qty1+';'+
					'document.getElementById(\'prd_qty'+kode+'\').value = qty;';
					yes+='document.getElementById(\'editBtn'+kode+'\').style.display=\'none\';';
					yes+='yesEditCart('+key+',\''+kode+'\','+inc+','+qty1+')';
					var no='document.getElementById(\'prd_qty'+kode+'\').value='+b4;
					no+=';document.getElementById(\'editBtn'+kode+'\').style.display=\'none\'';
					confirmMsg('You can not order ' + qty + ' pcs. This product is sell by ' + inc + ' pcs.<br>You must order in the multiplier of ' + inc + '<br><br>Do you want to order ' + qty1 + ' pcs?',yes,no,'');
					/*if(pil==true){
						document.getElementById('prd_qty'+kode).value = qty;
						document.getElementById('editBtn'+kode).style.display='none';
						yesEditCart(key,kode,inc,qty1);
					}else{
						document.getElementById('prd_qty'+kode).value=b4;
						document.getElementById('editBtn'+kode).style.display='none';
					}*/
			}else{
				yesEditCart(key,kode,inc,qty);
			}
		}
}
function yesdelCart(kode){
	document.getElementById('loading1').innerHTML ='<img src="images/loading3.gif" alt="loading" align="absmiddle" />';
	doRequest('get', 'include/profile/get_oder.php?act=del&index=' + kode, 'text', 'content_max');
}
function delCart(kode){	
	var yes='yesdelCart(\''+kode+'\')';
	confirmMsg("Are you sure that you want to delete this item from your order?",yes,'','');
}
function editRemark(remark,index){
	showDialog4('Back To Order Screen');
	document.getElementById('content_maxt').innerHTML='Loading....';
	doRequest('get','include/profile/edit_remark.php?remark='+remark+'&index='+index,'text','content_maxt');
}
function doEditRemark(index){
document.getElementById('loading1').innerHTML ='<img src="images/loading3.gif" alt="loading" align="absmiddle" />';
doRequest('get','include/profile/get_oder.php?act=remark&index='+index+'&remark='+document.getElementById('eremark').value,'text','content_max');
document.getElementById('maximizex').style.display='none';
}
function popupPacking(kode,index){
		showDialog4('Close Tag Screen');
		document.getElementById('content_maxt').innerHTML = '<div align="center><img src="images/loading3.gif" alt="Loading" /></div>';
		if (sendReq.readyState == 0 || sendReq.readyState == 4) {
			sendReq.open('GET', 'include/profile/get_packing.php?pi=' + kode + '&index=' + index, true);
			sendReq.onreadystatechange = function(){
				if (sendReq.readyState == 4 && sendReq.status == 200) {
					document.getElementById('content_maxt').innerHTML = sendReq.responseText;
				}
			}
			sendReq.send(null);
		}
}
function editPack(index,kode){
	document.getElementById('maximizex').style.display = 'none';
	document.getElementById('content_maxt').innerHTML = '<div align="center><img src="images/loading3.gif" alt="Loding" /></div>';
	doRequest('get', 'include/profile/get_oder.php?act=pack&index=' + index + '&packing=' + kode, 'text', 'content_max');
}
function yesSaveOrder(){
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		document.getElementById('content_max').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="120" align="center" valign="middle"><img src="images/loading3.gif"  alt="loading" /><br><strong>Please Wait...<br>Your order is saving.<br><font color="red">Do not click anything.</font></strong></td>' +
		'</tr>' +
		' </table>';
		sendReq.open('GET','include/profile/save_order.php?act=save',true);
		sendReq.onreadystatechange=function(){
			if(sendReq.readyState==4){
				if(sendReq.status==200){
					doRequest('get', 'include/profile/get_oder.php', 'text', 'content_max');
					//document.getElementById('content_max').innerHTML=sendReq.responseText;
					alertMsg('Votre commande a &eacute;t&eacute;  sauvegard&eacute;e','');
				}else{
					alert('Error : '+sendReq.statusText);
				}
			}
		}
		sendReq.send(null);
		
	}
}
function saveOrder(){
	confirmMsg("En sauvant votre commande, vous la gardez en m&eacute;moire. Vous pourrez.\n\
    Vous pourrez l'&eacute;diter ou ajouter des nouveaux produits lorsque vous vous reconnecterez plus tard\n\
<br>Etes vous sur de vouloir sauver votre commande?\n\
<br>Choisissez Oui pour sauvez votre commande ou Non pour annuler.",'yesSaveOrder()','','');
}
function continueOrder(productStoreId){
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		document.getElementById('content_max').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
		'<tr>' +
		'<td height="120" align="center" valign="middle"><img src="images/loading3.gif"  alt="loading" /><br><strong>Please Wait...<br>Your order is saving.<br><font color="red">Do not click anything.</font></strong></td>' +
		'</tr>' +
		' </table>';
		sendReq.open('GET','include/profile/save_order.php?act=save',true);
		sendReq.onreadystatechange=function(){
			if(sendReq.readyState==4){
				if(sendReq.status==200){
					//doRequest('get', 'include/profile/get_oder.php', 'text', 'content_max');
					//document.getElementById('content_max').innerHTML=sendReq.responseText;
					//alert('You order has been saved');
					continueOrderX(productStoreId);
				}else{
					alert('Error : '+sendReq.statusText);
				}
			}
		}
		sendReq.send(null);
		
	}
}
function yesAddCart(kode,form){
	document.getElementById('jmlprd'+kode).value=qty1;
	document.getElementById('jumlahproduk'+kode).value=qty1/document.getElementById('hide_prd_qty'+kode).value;
	addCartx(kode,form);
}
function addCartx(kode,form){
		qty=document.getElementById('jmlprd'+kode).value;
		if (qty > 0) {
			var md = qty % document.getElementById('hide_prd_qty' + kode).value;
			if (md != 0) {
				if (parseInt(qty) < parseInt(document.getElementById('hide_prd_qty'+kode).value)) {
					qty1 = document.getElementById('hide_prd_qty'+kode).value;
				}
				else {
					var xx = document.getElementById('hide_prd_qty'+kode).value - md;
					qtyx = parseInt(qty) + parseInt(xx);
					var xx1=document.getElementById('jmlprd'+kode).value%document.getElementById('hide_prd_qty'+kode).value;
					var qty2=document.getElementById('jmlprd'+kode).value-xx1;
					var xxx = document.getElementById('hide_prd_qty'+kode).value / 2;
					if(parseInt(xx)>xxx) qty1=qty2; else qty1=qtyx;				
				}
				var yes='yesAddCart(\''+kode+'\',\''+form+'\')';
				var no='document.getElementById(\'jmlprd'+kode+'\').value=\'\'';
				confirmMsg('Vous ne pouvez pas commander ' + qty + ' pcs. Ce produit est vendu par ' + document.getElementById('hide_prd_qty' + kode).value + ' pcs.<br>Vous devez choisir un multiple de ' + document.getElementById('hide_prd_qty' + kode).value + '<br><br>Voulez-vous commander ' + qty1 + ' pcs?',yes,no,'');
			}else{
				document.getElementById('jumlahproduk'+kode).value=qty/document.getElementById('hide_prd_qty'+kode).value;
				document.getElementById('formx'+kode).submit();
			}
		}else{
			alertMsg('SVP saisissez la  quantit&eacute; que vous souhaitez!','');
		}
}
function yesShipment(){
	if(xhtml.readyState==4 || xhtml.readyState==0){
			document.getElementById('content_max').innerHTML = '<div align="center"><img src="images/loading3.gif" alt="Loading" /></div>';
			xhtml.open('GET','include/profile/shipment.php',true);
			xhtml.onreadystatechange=function(){
				if(xhtml.readyState==4){
					if(xhtml.status==200){
						document.getElementById('content_max').innerHTML=xhtml.responseText;
						document.getElementById('buttonx').innerHTML='<div align="right" style="padding-right:20px;"><button onclick="showOrderDetail(); return false;">Back</button><button onclick="showRemark(); return false;">Continue</button></div>';
					}else{
						alert('There was a problem with the request : '+xhtml.statusText,'');
					}
				}
			}
			xhtml.send(null);
		}
}
function showShipment(){
	if (!document.getElementById('f_date_d')) {
	 yesShipment();
	}
	else {
		if (parseFloat(document.getElementById('total_orderx').value) >= parseFloat(document.getElementById('minimum_order').value)) {
			confirmMsg("Ne  Finalisez votre commande que si vous etes sur de l&rsquo;avoir  termin&eacute;e. <br><br> Il ne sera plus possible de la modifier plus tard. <br><br> Pressez Oui pour la finaliser maintenant ou Non pour la finaliser plus tard.", 'yesShipment()', '', '');
		}else{
			alertMsg('Le montant minimum de commande sur notre site internet est de '+document.getElementById('minimum_order').value+' euros. Merci','');
		}
	}
}
function showValidBtnN(x){
	var max=document.getElementById('max_valid').value;
	for(i=0;i<max;i++){
		document.getElementById('valid'+i).style.display='none';
		document.getElementById('is_show'+i).value='N';
	}
	document.getElementById('valid'+x).style.display='block';
	document.getElementById('is_show'+x).value='Y';
}
function validShipAddress(x){
	showValidBtnN(x);
	var mech=document.getElementById('mech'+x).value;
	document.getElementById('shipmentx').innerHTML=document.getElementById('ship_value'+x).innerHTML;
	document.getElementById('shipmentx2').value=mech;
	document.getElementById('shipmentx3').style.display='block';
	if((document.getElementById('alertshipment').innerHTML=='' || document.getElementById('alertshipment').innerHTML=='Choisissez un transporteur SVP') && document.getElementById('carrierx3').style.display=='none'){
		document.getElementById('alertshipment').innerHTML='Choisissez un transporteur SVP';
	}else{
		document.getElementById('alertshipment').style.display='none';
		document.getElementById('shipmentvalid').style.display='block';
		document.getElementById('alertshipment').innerHTML='';
	}
}
function showValidBtnCar(x){
	var max=document.getElementById('validx').value;
	for(i=0;i<max;i++){
		document.getElementById('valid_car'+i).style.display='none';
		document.getElementById('is_showc'+i).value='N';
	}
	document.getElementById('valid_car'+x).style.display='block';
	document.getElementById('is_showc'+x).value='Y';
}
function validShipCarrier(x){
	showValidBtnCar(x);
	var mech=document.getElementById('carr_id'+x).value; //alert(mech);
	document.getElementById('carrierx').innerHTML=document.getElementById('car_value'+x).innerHTML;
	document.getElementById('carrierx2').value=mech;
	document.getElementById('carrierx3').style.display='block';
	if((document.getElementById('alertshipment').innerHTML=='' || document.getElementById('alertshipment').innerHTML=="Choisissez l'adresse de livraison SVP") && document.getElementById('shipmentx3').style.display=='none'){
		document.getElementById('alertshipment').innerHTML="Choisissez l'adresse de livraison SVP";
	}else{
		document.getElementById('alertshipment').style.display='none';
		document.getElementById('shipmentvalid').style.display='block';
		document.getElementById('alertshipment').innerHTML='';
	}
}
function shipmentvalidate(){
	var mech=document.getElementById('shipmentx2').value;
	document.getElementById('shipmentvalid').innerHTML='<img src="images/lbloading.gif" alt="loading" width="32" height="32" align="absmiddle"> loading...';
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('GET','include/profile/shipment.php?to=valid&mech_id='+mech,true);
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200){
				//document.getElementById('content_max').innerHTML=xhtml.responseText;
				validTheCarrier();
			}
		}
		xhtml.send(null);
	}
}
function validTheCarrier(){
	var mech=document.getElementById('carrierx2').value;
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('GET','include/profile/shipment.php?to=valid2&mech_id='+mech,true);
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200){
				document.getElementById('content_max').innerHTML=xhtml.responseText;
				//display next step
				showRemark();
			}
		}
		xhtml.send(null);
	}
}

function validTheCarrier2(){
	var mech='';
	mech=document.getElementById('carrier_lam').value;
	document.getElementById('loading2').innerHTML='<img src="images/loading3.gif" alt="loading" />';
	if(xhtml.readyState==4 || xhtml.readyState==0){
		if(document.getElementById('carrier_lam').checked) 
		xhtml.open('GET','include/profile/get_carrier.php?act=add&party_id_to='+mech,true);
		else
		xhtml.open('GET','include/profile/get_carrier.php?act=del2&party_id_to='+mech,true);
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200){
				document.getElementById('content_profile').innerHTML=xhtml.responseText;
			}
		}
		xhtml.send(null);
	}
}

function addShippingN1(party){
	showDialog4('Back To Previous screen');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading3.gif" alt="loading" />';
	doRequest('get','include/profile/more_shipping1.php?pi='+party,'text','content_maxt');
}
function saveShippingN1(party){
	var filterzip=/^\d{5}$|^\d{5}-\d{4}$/;
	if(document.getElementById('toname').value==''){
		alertMsg('SVP saisissez Au Nom de!','');
	}else
	if (document.getElementById('tadd1').value == '') {
	alertMsg('SVP saisissez l&rsquo;adresse!','');
	}else if(document.getElementById('tcity').value==''){
		alertMsg('SVP saisissez la ville!','');
	}else if(document.getElementById('tzip').value==''){
		alertMsg('SVP saisissez le code postal!','');
	}else if(!filterzip.test(document.getElementById('tzip').value)){
		alertMsg('code postal invalide!','');
	}else if(document.getElementById('tcountry').value==''){
		alertMsg('SVP choisissez le pays!','');
	}
	else {
		document.getElementById('loading1').innerHTML = '<img src="images/loading3.gif"  alt="loading" />';
		if (xhtml.readyState == 4 || xhtml.readyState == 0) {
			xhtml.open('POST', 'include/profile/more_shipping1.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;
					alertMsg('Nouvelle adresse d\'exp&eacute;dition a &eacute;t&eacute; sauv&eacute;.','');
					showShipment();
					document.getElementById('maximizex').style.display = 'none';
				}
			}
			var param = 'party_id=' + party;
			param += '&tadd1=' + document.getElementById('tadd1').value;
			param += '&tadd2=' + document.getElementById('tadd2').value;
			param += '&tcity=' + 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='+document.getElementById('tattn_name').value;
			param+='&toname='+document.getElementById('toname').value;
			xhtml.send(param);
		}
	}
}
function showSelCarrierN(){
	showDialog4("Back to previous Screen");
	document.getElementById('content_maxt').innerHTML='<img src="images/loading3.gif" alt="loading" />';
	if(xhtml.readyState==4 || xhtml.readyState==0){
		xhtml.open('GET','include/profile/add_carrier4.php',true);
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4 && xhtml.status==200)
			document.getElementById('content_maxt').innerHTML=xhtml.responseText;
		}
		xhtml.send(null);
	}
}
function showSelCarrier3(kode){
	document.getElementById('content_maxt').innerHTML+='<img src="images/loading3.gif" alt="loading"  />';
	doRequest('get','include/profile/add_carrier4.php?search='+kode,'text','content_maxt');
}
function saveSelCarrierN(kode){
	if(document.getElementById('pt_id'+kode).innerHTML==''){
		alertMsg('SVP choisissez un transporteur!','');
	}else{
		if(sendReq.readyState==4 || sendReq.readyState==0){
		sendReq.open("POST", 'include/profile/add_carrier4.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;
				showShipment();
				document.getElementById('maximizex').style.display = 'none';
				//alertMsg(sendReq.responseText,'');
			}
		}
		sendReq.send('act=add&party_id_to='+document.getElementById('pt_id'+kode).innerHTML);
			
		}
		
	}
}
function addNewCarrierN(){
	showDialog4('Back to Previous Screen');
	document.getElementById('content_maxt').innerHTML='<img src="images/loading3.gif"  alt="loading"  />';
	if (sendReq.readyState == 4 || sendReq.readyState == 0) {
		sendReq.open("GET", 'include/profile/add_carrier3.php', true);
		sendReq.onreadystatechange = function(){
			if(sendReq.readyState==4 && sendReq.status==200)
			document.getElementById('content_maxt').innerHTML=sendReq.responseText;
		}
		sendReq.send(null);
	}
}
function saveCarrierN(){
	var gender='';
		if(document.form1.gender[0].checked){
		gender=document.form1.gender[0].value;	
		}else if(document.form1.gender[1].checked){
			gender=document.form1.gender[1].value;
		}
	var filter=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if(gender==''){
		alertMsg('SVP selectionnez votre  civilit&eacute;!','');
	}else if(document.getElementById('fname').value==''){
		alertMsg('SVP saisissez votre pr&eacute;nom!','');
	}else if(document.getElementById('email').value==''){
		alertMsg('SVP saisissez votre adresse email!','');
		document.getElementById('email').focus();
	}else if(!filter.test(document.getElementById('email').value)){
		alertMsg('SVP v&eacute;rifiez  votre adresse email','');
		document.getElementById('email').foucs();
	}/*else if(document.getElementById('psw1').value==''){
		alertMsg('Please input password!','');
		document.getElementById('psw1').focus();
	}else if(document.getElementById('psw2').value==''){
		alertMsg('Please input confirm password!','');
		document.getElementById('psw2').focus();
	}else if(document.getElementById('psw1').value!=document.getElementById('psw2').value){
		alertMsg('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=='' ){
		alertMsg('SVP saisissez votre num&eacute;ro  de t&eacute;l&eacute;phone!','');
		document.getElementById('p1').focus();
	}else if(document.getElementById('company').value==''){
		alertMsg('SVP saisissez le nom de votre conpagnie!','');
	}else if(document.getElementById('badd1').value==''){
		alertMsg('SVP saisissez une adresse','');
	}else if(document.getElementById('bcity').value==''){
		alertMsg('SVP saisissez la ville','');
	}else if(document.getElementById('bzip').value==''){
		alertMsg('SVP saisissez le code postal','');
	}else if(document.getElementById('bcountry').value==''){
		alertMsg("SVP choisissez le pays!",'');
	}else{
		if(sendReq.readyState==4 || sendReq.readyState==0){
			sendReq.open("POST","include/profile/add_carrier3.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;
					showShipment();
					document.getElementById('maximizex').style.display = 'none';
					alertMsg('Nouveau transporteur enregistr&eacute;!','');
				}
			}
			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;
			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/loading3.gif"  alt="loading" /></td>' +
		'</tr>' +
		' </table>';
		}
	}	
}
function showRemark(){
	if(document.getElementById('shipping_mech_id').value==''){
		alertMsg("SVP choisissez une adresse de livraison!",'');
	}else if(document.getElementById('carrier_mech_id').value==''){
		alertMsg('SVP choisissez une adresse de livraison!','');
	}else{
		var ship=document.getElementById('shipping_mech_id').value;
		var car=document.getElementById('carrier_mech_id').value;
		document.getElementById('content_max').innerHTML = '<div align="center"><img src="images/loading3.gif" alt="Loading" /></div>';
		if(sendReq.readyState==0 || sendReq.readyState==4){
			sendReq.open('GET','include/profile/add_note.php',true);
			sendReq.onreadystatechange=function(){
				if(sendReq.readyState==4){
					if(sendReq.status==200){
						document.getElementById('content_max').innerHTML=sendReq.responseText;
						document.getElementById('buttonx').innerHTML='<div align="right" style="padding-right:20px;"><button onclick="showShipment(); return false;">Back</button><button onclick="saveNote(); return false;">Create Order</button></div>';		
					}else{
						alert("Error : "+sendReq.statusText);
					}
				}
			}
			sendReq.send(null);
		}
	}
}
function saveNote(){
		var note=document.getElementById('note') ? document.getElementById('note').value : '';
		document.getElementById('content_max').innerHTML = '<div align="center"><img src="images/loading3.gif" alt="loading" /></div>';
		if(xhtml.readyState==4 || xhtml.readyState==0){
			xhtml.open('POST','include/profile/add_note.php',true);
			xhtml.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			xhtml.onreadystatechange=function(){
				if(xhtml.readyState==4 && xhtml.status==200){
					//document.getElementById('content_max').innerHTML=xhtml.responseText;
					//window.location.href='system/process/create_order_sys.php?confirm=fix_order';
					doRequest('get','system/process/create_order_sys.php','text','content_max');
					document.getElementById('buttonx').innerHTML='<div align="right" style="padding-right:20px;"><button onclick="PrintOrder(); return false;">Print</button><button onclick="window.location.href=\'shopping_cart.php?confirm=fix_order\'; return false;">Close</button><input type="hidden" name="hid_indi" id="hid_ind" /></div>';
					document.getElementById('xx3').innerHTML='';		
				}
			}
			xhtml.send('note='+escape(note)+'&act=add');
		}
}

function getOrderHist(){
if(xhtml.readyState==4 || xhtml.readyState==0){
	document.getElementById('tabx').style.background='url(images/tab_06.gif) left top no-repeat';
	document.getElementById('content_profile').innerHTML = '<div align="center"><img src="images/loading3.gif" alt="loading" /></div>';
	xhtml.open('GET','include/profile/order_history.php',true);
	xhtml.onreadystatechange=function(){
		if(xhtml.readyState==4 && xhtml.status==200){
			document.getElementById('content_profile').innerHTML=xhtml.responseText;
		}
	}
	xhtml.send(null);
}
}
function getInfo(){
	document.getElementById('content_profile').innerHTML = '<div align="center"><img src="images/loading3.gif" alt="loading" /></div>';
	window.location.href='member-history.php?act=profile';
}
function editContact(x){
	var party=document.getElementById('hide_pito'+x).value;
	showDialog4('Back to previous screen');
	document.getElementById('content_maxt').innerHTML='<div align="center"><img src="images/loading3.gif" alt="loading" align="absmiddle" /></div>';
	doRequest('get','include/profile/edit_contact.php?view='+party,'text','content_maxt');
}
function saveEditContact(){
	var gender='';
		if(document.form_gen.gender[0].checked){
		gender=document.form_gen.gender[0].value;	
		}else if(document.form_gen.gender[1].checked){
			gender=document.form_gen.gender[1].value;
		}
	var filter=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if(gender==''){
		alertMsg('SVP selectionnez votre  civilit&eacute;!',''); return false;
	}else if(document.getElementById('fname').value==''){
		alertMsg('SVP saisissez votre pr&eacute;nom!',''); return false;
	}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) {
		alertMsg('SVP choisissez une position dans la compagnie',''); return false;
	}else if(document.getElementById('email').value==''){
		alertMsg('SVP saisissez votre adresse email!',''); 
		document.getElementById('email').focus(); return false;
	}else if(!filter.test(document.getElementById('email').value)){
		alertMsg('SVP v&eacute;rifiez  votre adresse email','');
		document.getElementById('email').foucs(); return false;
	}/*else if(document.getElementById('psw1').value==''){
		alertMsg('Please input password!','');
		document.getElementById('psw1').focus(); return false;
	}else if(document.getElementById('psw2').value==''){
		alertMsg('Please input confirm password!','');
		document.getElementById('psw2').focus(); return false;
	}else if(document.getElementById('psw1').value!=document.getElementById('psw2').value){
		alertMsg('Password and Confirm password must be the same!','');
		document.getElementById('psw1').focus(); return false;
	}*/else if(document.getElementById('p1').value=='' || document.getElementById('p2').value=='' || document.getElementById('p3').value=='' ){
		alertMsg('SVP saisissez votre num&eacute;ro  de t&eacute;l&eacute;phone!','');
		document.getElementById('p1').focus(); 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/profile/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';
					document.frm_logo.submit();
				}
			}
			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 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=edit';
			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+='&email_id='+document.getElementById('email_id').value;
			param+='&pos='+pos;
			param+='&party='+document.getElementById('pi').value;
			//param+='&user_login='+document.getElementById('userlogin').value;
			sendReq.send(param);
		}
	}
}
function afterAddContact1(party){
	getContact();
	doRequest('get','include/profile/edit_contact.php?view='+party,'text','content_maxt');
}
function alertMsg(msg,title){
	if(title!='')
	document.getElementById('title_alert').innerHTML=title;
	else
	document.getElementById('title_alert').innerHTML='Lambada Jewelry';
	document.getElementById('alert_icon').innerHTML=alert_icon;
	document.getElementById('alert_msg').innerHTML=msg;
	document.getElementById('alert_button').innerHTML='<input type="image" name="imageField" src="images/alert/ok_yellow.gif" onclick="document.getElementById(\'alert\').style.display=\'none\'; return false;" />';
	showAlert();
}
function confirmMsg(msg,yes,no,title){
	if(title!='')
	document.getElementById('title_alert').innerHTML=title;
	else
	document.getElementById('title_alert').innerHTML='Lambada Jewelry';
	if (no != '') {
		no += ';';
		//alert(no)
	}
	document.getElementById('alert_icon').innerHTML=confirm_icon;
	document.getElementById('alert_msg').innerHTML=msg;
	document.getElementById('alert_button').innerHTML='<input type="image" name="imageField" src="images/alert/yes_yellow.gif" onclick="document.getElementById(\'alert\').style.display=\'none\'; '+yes+';return false;" /><input type="image" name="imageField" src="images/alert/no_yellow.gif" onclick="document.getElementById(\'alert\').style.display=\'none\'; '+no+' return false;" />';
	showAlert();
}
function PrintOrder()
{
NewWindow('system/process/order_print.php','print_order',800,600,'yes');
}
function getState(con,div,sel,sel1){
	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/profile/getGeoState.php?geo='+con+'&id='+sel+'&sel='+sel1,true);
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4){
				if(xhtml.status==200){
					doc.innerHTML=xhtml.responseText;
				}
			}
		}
		xhtml.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/profile/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 readMore(page){
	if(xhtml.readyState==4 || xhtml.readyState==0){
		showDialog4('Back to main screen');
		var doc=document.getElementById('content_maxt');
		doc.innerHTML='<div align="center"><img src="administration/images/pos/loading3.gif" alt="loading" /></div>';
		xhtml.open('GET',page,true);
		xhtml.onreadystatechange=function(){
			if(xhtml.readyState==4){
				if(xhtml.status==200){
					doc.innerHTML=xhtml.responseText;	
				}
			}
		}
		xhtml.send(null);
	}
}
function seeOrderInfoOver(){
	var orderInfo=document.getElementById('order_info');
	if (window.location.href.search(/online_shop.php/) != -1 || window.location.href.search(/product_detail/)!=-1) {
		orderInfo.style.background = "url(images/info_031_o.gif) bottom left no-repeat";
	}
	else {
		orderInfo.style.background = "url(images/info_031.gif) bottom left no-repeat";
	}
	document.getElementById('shop_cart_div').innerHTML='&nbsp;';
	document.getElementById('top_shop_cart').style.display='block';
	document.getElementById('bottom_shop_cart').style.display='block';
}
function seeOrderInfoOut(){
	var orderInfo=document.getElementById('order_info');
	if (window.location.href.search(/online_shop.php/) != -1 || window.location.href.search(/product_detail/)!=-1) {
		orderInfo.style.background = "url(images/info_03_o.gif) bottom left no-repeat";
	}
	else {
		orderInfo.style.background = "url(images/info_03.gif) bottom left no-repeat";
	}
	var text=document.getElementById('info_text').value;
	document.getElementById('shop_cart_div').innerHTML='<a href="#see_order_info" style="color:#ffffff; font-size:14px;" onmouseover="seeOrderInfoOver();"><strong>'+text+'</strong></a>';
	document.getElementById('top_shop_cart').style.display='none';
	document.getElementById('bottom_shop_cart').style.display='none';
}

function showDialog5(title){
	//document.getElementById('main_page').style.display='none';
	var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }

var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }


var winl=(viewportwidth-800)/2;
var wint=(viewportheight-500)/2+scrOfY;


/*document.getElementById('pic').style.left=winl+'px';
document.getElementById('pic').style.top=wint+'px';
document.getElementById('pic').style.display='block';*/
ph=new Array();
ph=getPageSizeWithScroll();
if(ph[1]<viewportheight) ph[1]=viewportheight;
//if(BrowserDetect.browser=='Opera') viewportheight-=15;
document.getElementById('maximizex').style.height=viewportheight+'px';
document.getElementById('maximizex').style.width='100%';
document.getElementById('maximize2').style.height=viewportheight+'px';
document.getElementById('maximize2').style.width=ph[0]+'px';
document.getElementById('xxt').style.height = (viewportheight-115) + 'px';
document.getElementById('xxt2').style.height=(viewportheight - 145) + 'px';
document.getElementById('xxt').style.width='90%';
document.getElementById('maximizex').style.display='block';
document.getElementById('title_pack').innerHTML=title;
document.getElementById('content_maxt').scrollTop=0;
}

function getSPpicture(kode){
document.getElementById('content_maxt').innerHTML='<img src="images/lbloading.gif" alt="loading" />';
doRequest('get', 'include/profile/getpicture.php?pr='+kode, 'text', 'content_maxt');
showDialog5('Back to main screen');
}
function changeUserLogin(user){
	var popup = new MoobbiePopup(600,'','','administration/images/popup/');
	popup.setTitle('Lambada Jewelry');
	var xhtml=getXMLHttp();
	xhtml.open('GET','include/profile/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('userlogin').value){
					document.getElementById('cekuserlogin').innerHTML='<input type="checkbox" name="checkUser" id="checkUser" onclick="useEmail();" /> utiliser l\'adresse email comme nom d\'utilisateur';
				}
				popup.show();
				popup.addButton('Annuler',function(){},true);
			}
		}
	}
	xhtml.send(null);
	
}
function checkUserID(){
	if (document.formUserLogin.newUserLogin.value != '') {
		var popup = new MoobbiePopup(600, '', '', 'administration/images/popup/');
		popup.setTitle('Lambada Jewelry');
		var xhtml = getXMLHttp();
		xhtml.open('GET', 'include/profile/changeUserLogin.php?action=check&userIdnew=' + document.formUserLogin.newUserLogin.value + '&userId=' + document.getElementById('userlogin').value, true);
		xhtml.onreadystatechange = function(){
			if (xhtml.readyState == 4) {
				if (xhtml.status == 200) {
					popup.setContent(xhtml.responseText);
					popup.show();
					popup.popupFooter.innerHTML='';
					popup.addButton('Annuler', function(){
					}, true);
				}
			}
		}
		xhtml.send(null);
	}else{
		alert('SVP Ins�rez votre nouveau nom utilisateur');
	}
}
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, '', '', 'administration/images/popup/');
	popup.hide();
	document.getElementById('userlogin').value=newUser;
}

function viewInvoices(){
	var ajax = getXMLHttp();
	ajax.open('get', 'include/profile/invoice.php', true);
	ajax.onreadystatechange = function(){
		if(ajax.readyState == 4){
			if(ajax.status == 200){
				document.getElementById('contentx').innerHTML = ajax.responseText;
			}			
		}
	}
	ajax.send(null);
}

function displayAcountBalance(){
	var ajax = getXMLHttp();
	ajax.open('get', 'include/profile/accountBalance.php', true);
	ajax.onreadystatechange = function(){
		if(ajax.readyState == 4){
			if(ajax.status == 200){
				document.getElementById('contentx').innerHTML = ajax.responseText;
			}			
		}
	}
	ajax.send(null);
}
