// JavaScript Document
function jq(myid) { 
   return '#' + myid.replace(/(:|\.)/g,'\\$1');
 }
 
function setMaskBackground()
{
	if(document.getElementById("maskLayer")==null)
	{
		  var table1=document.createElement("table");
		 	 table1.setAttribute("id", "maskLayer");
			 table1.setAttribute("width", "100%");
			 table1.setAttribute("border", "0");
			 table1.style.background = "#ccc";	
			 table1.style.display = "none";
			 table1.style.position = "absolute"; 
	     var tbody1=document.createElement("tbody");
		 var tr1=document.createElement("tr");
		 var td1=document.createElement("td");
		 var span1=document.createElement("span");
			 span1.setAttribute("innerHTML", "&nbsp;");
		
		 td1.appendChild(span1);	
		 tr1.appendChild(td1);
		 tbody1.appendChild(tr1);
		 table1.appendChild(tbody1);
		 document.body.appendChild(table1);
		
	}
	//$(jq("maskLayer")).fadeIn(1000);
	document.getElementById("maskLayer").style.height=(getPageHeightSizeWithScroll())+"px";
	document.getElementById("maskLayer").style.top="0px";
	document.getElementById("maskLayer").style.left="0px";
	//document.getElementById("tbTest").style.filter = 'alpha(opacity=50)';
	document.getElementById("maskLayer").className="opacityClass";
	document.getElementById("maskLayer").style.zIndex=50;
	//document.getElementById("maskLayer").style.display="";
	//$(jq("maskLayer")).fadeIn(700);
	//document.getElementById("maskLayer").style.display="";
	$(jq("maskLayer")).show();
	$(jq("maskLayer")).fadeTo(1000, 0.7); 
	//
	//$(jq("maskLayer")).show();
	
	if(document.getElementById("popup"))
	{
		document.getElementById("maskLayer").onclick = null ;
		document.getElementById("maskLayer").onclick = function(){close_create_popup();} ;
	}
	
	
}
function removeMaskBackground()
{
	
	$(jq("maskLayer")).fadeOut(1000);
	//document.getElementById("maskLayer").style.display="none";
	//$(jq("maskLayer")).fadeTo(1000, 0.5); 
}

//---------------------------------------------------------//

function getScrollY() {
  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;
  }
  return  scrOfY ;
}

function getPageHeightSizeWithScroll()
{     
	if (window.innerHeight && window.scrollMaxY) 
	{// Firefox         
		yWithScroll = window.innerHeight + window.scrollMaxY; 
		xWithScroll = window.innerWidth + window.scrollMaxX; 
		
		if(document.documentElement.clientHeight>yWithScroll){yWithScroll=document.documentElement.clientHeight;}
	} 
	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;//alert('f'+document.body.scrollHeight)
		if(document.documentElement.clientHeight>yWithScroll){yWithScroll=document.documentElement.clientHeight;}
	}    
	
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll); 
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );   
	return yWithScroll;
} 

function dateTimeToPopupCalendar(dateTime)
{
	var arrDateTime = dateTime.split(" ");
	var arrDate = arrDateTime[0].split("-");
	var month ;
	switch(arrDate[1])
	{
		case "01":month="Jan";break;
		case "02":month="Feb";break;
		case "03":month="Mar";break;
		case "04":month="Apr";break;
		case "05":month="May";break;
		case "06":month="Jun";break;
		case "07":month="Jul";break;
		case "08":month="Aug";break;
		case "09":month="Sep";break;
		case "10":month="Oct";break;
		case "11":month="Nov";break;
		case "12":month="Dec";break;
	}
	
	return arrDate[2]+" "+month+" "+arrDate[0];
	
}

function popupCalendarToDateSlash(dateTime)
{
	var arrDate = dateTime.split(" ");
	
	var month ;
	switch(arrDate[1])
	{
		case "Jan":month="01";break;
		case "Feb":month="02";break;
		case "Mar":month="03";break;
		case "Apr":month="04";break;
		case "May":month="05";break;
		case "Jun":month="06";break;
		case "Jul":month="07";break;
		case "Aug":month="08";break;
		case "Sep":month="09";break;
		case "Oct":month="10";break;
		case "Nov":month="11";break;
		case "Dec":month="12";break;
	}
	
	return arrDate[0]+"/"+month+"/"+arrDate[2];
	
}

function checkLines(obj,limit,e)
{
	var s = obj.value.split("\r\n");
	tempText = "";
	var a = new Array();
	if(s.length>limit)
	{
		 for (i=0;i<limit;i++) 
		 { 
			a[i] = s[i]
		 }
		obj.value = a.join("\r\n") 
	}
	
	//obj.value = tempText;
}
function checkEmailSyntax(email)
{
	if(email.indexOf ('@',0) == -1 || email.indexOf ('.',0) == -1)
	{
	    return false;
	}
	else
	{
		return true;
	}
} 

// ------ detect browser and set event key -----//
var browser = navigator.appName;
var publicKeyCode = "";
	
if(browser=="Microsoft Internet Explorer")
{
	publicKeyCode = "event.keyCode";
}
else
{
	 publicKeyCode = "evt.which";
}

function onKeyUpTelephoneAndFaxSyntax(obj)
{
	var digit;
	digit=obj.value
	var chkSyntax = true;
	for (var i=0;i<digit.length;i++)
	{
		if (! (digit.charAt(i)>="0" && digit.charAt(i)<="9") && (digit.charAt(i)!="*") && (digit.charAt(i)!="-")  && (digit.charAt(i)!="+") && (digit.charAt(i)!=" ") && (digit.charAt(i)!="/") )
		{ 
		//if ((digit.charAt(i).search(/[a-z]/) == -1)||(digit.charAt(i).search(/[A-Z]/) == -1)){ 
		//obj.value='';
		obj.style.border = "solid 1px #c00";
		chkSyntax = false;
		event.returnValue = false;
		}
	}
	
	if(chkSyntax==true)
	{
		obj.style.border = "solid 1px #ccc";	
	}
	else
	{
		obj.style.border = "solid 1px #c00";	
	}
	
}

function checkTelephoneAndFaxSyntax(obj)
{
	var digit;
	digit=obj.value
	var chkSyntax = true;
	for (var i=0;i<digit.length;i++)
	{
		if (! (digit.charAt(i)>="0" && digit.charAt(i)<="9") && (digit.charAt(i)!="*") && (digit.charAt(i)!="-")  && (digit.charAt(i)!="+") && (digit.charAt(i)!=" ") && (digit.charAt(i)!="/") )
		{ 
		//if ((digit.charAt(i).search(/[a-z]/) == -1)||(digit.charAt(i).search(/[A-Z]/) == -1)){ 
		//obj.value='';
		//obj.style.border = "solid 1px #ff0000";
		chkSyntax = false;
		event.returnValue = false;
		}
	}
	
	if(chkSyntax==true)
	{
		return true;	
	}
	else
	{
		return false;	
	}
	
}


//------------------------------------------//

function showPopupConfirmBox(titleText,headText,confirmButtonText,cancelButtonText,returnFunction)
{
	if(document.getElementById("PopupConfirmBox"))
	{
		document.getElementById("PopupConfirmBox_titleText").innerHTML = titleText;
		document.getElementById("PopupConfirmBox_headText").innerHTML = headText;
		
		document.getElementById("PopupConfirmBox_btnConfirm").value = confirmButtonText;
		document.getElementById("PopupConfirmBox_btnConfirm").onclick = null;
		document.getElementById("PopupConfirmBox_btnConfirm").onclick = function(){eval(""+returnFunction+"(true)")};
		
		document.getElementById("PopupConfirmBox_btnCancel").value = cancelButtonText;
		document.getElementById("PopupConfirmBox_btnCancel").onclick = null;
		document.getElementById("PopupConfirmBox_btnCancel").onclick = function(){eval(""+returnFunction+"(false)")};
		
		document.getElementById("PopupConfirmBox").style.display="";
		document.getElementById("PopupConfirmBox").style.top=( ( (screen.height/2)+getScrollY() - 200 ))+"px";
		document.getElementById("PopupConfirmBox").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupConfirmBox").style.zIndex=150;
	}	
}

function showPopupConfirmBoxFollowMouse(titleText,headText,confirmButtonText,cancelButtonText,returnFunction)
{
	if(document.getElementById("PopupConfirmBox"))
	{
		document.getElementById("PopupConfirmBox_btnConfirm").disabled = false;
		document.getElementById("PopupConfirmBox_btnCancel").disabled = false;
		
		document.getElementById("PopupConfirmBox_titleText").innerHTML = titleText;
		document.getElementById("PopupConfirmBox_headText").innerHTML = headText;
		
		document.getElementById("PopupConfirmBox_btnConfirm").value = confirmButtonText;
		document.getElementById("PopupConfirmBox_btnConfirm").onclick = null;
		document.getElementById("PopupConfirmBox_btnConfirm").onclick = function(){eval(""+returnFunction+"(true)")};
		
		document.getElementById("PopupConfirmBox_btnCancel").value = cancelButtonText;
		document.getElementById("PopupConfirmBox_btnCancel").onclick = null;
		document.getElementById("PopupConfirmBox_btnCancel").onclick = function(){eval(""+returnFunction+"(false)")};
		
		document.getElementById("PopupConfirmBox").style.display="";
		//document.getElementById("PopupConfirmBox").style.top=((screen.height-200)*0.35)+"px";
		//document.getElementById("PopupConfirmBox").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupConfirmBox").style.top=( ( (screen.height/2)+getScrollY() - 200 ))+"px";
		document.getElementById("PopupConfirmBox").style.left=((screen.width+200)*0.25)+"px";
		document.getElementById("PopupConfirmBox").style.zIndex=150;
	}	
}

function hidePopupConfirmBox()
{
	if(document.getElementById("PopupConfirmBox"))
	{
		document.getElementById("PopupConfirmBox").style.display="none";
	}
	
}

function PopupConfirmBox_ShowError()
{
	document.getElementById("PopupConfirmBox_ShowError1").style.display="";
	document.getElementById("PopupConfirmBox_ShowError2").style.display="";
	document.getElementById("PopupConfirmBox_ShowErrorBox").className = "mode_error";
	
}

function PopupConfirmBox_ShowSuccess()
{
	document.getElementById("PopupConfirmBox_ShowError1").style.display="";
	document.getElementById("PopupConfirmBox_ShowError2").style.display="";
	document.getElementById("PopupConfirmBox_ShowErrorBox").className ="mode_success";
	
}

function PopupConfirmBox_CloseError()
{
	document.getElementById("PopupConfirmBox_ShowError1").style.display="none";
	document.getElementById("PopupConfirmBox_ShowError2").style.display="none";
	
	
}

function addChangeLoading(top,left)
{
	if(document.getElementById("preload")==null)
	{
		var img =document.createElement("img");
			img.setAttribute("id", "preload");
			img.src = "images/loading.gif";
			img.style.top = top+"px";
			img.style.left = left+"px";
			img.style.zIndex=1000;
			img.style.position = "absolute";
			document.body.appendChild(img);
			
	}
}



function removeChangeLoading()
{
	if(document.getElementById("preload")!=null)
	{
		//document.getElementById("preload")=null;
		document.body.removeChild(document.getElementById("preload"));
	}
}
function chkchar(obj){
var digit;
digit=obj.value
for (var i=0;i<digit.length;i++){
if (! (digit.charAt(i)>="0" &&digit.charAt(i)<="9") ){ 
//if ((digit.charAt(i).search(/[a-z]/) == -1)||(digit.charAt(i).search(/[A-Z]/) == -1)){ 
obj.value=''
event.returnValue = false;
}
}
}

function getPercent(value,percent)
{
	var returnValue = 0;
	returnValue = ((percent/100)*value).toFixed(2);
	return returnValue;
}

function SelectOption(ObjName,NValue)
{
	
	var objCount = document.getElementById(ObjName).options.length;
	
	for(i=0;i<=objCount-1;i++)
	{
		if(document.getElementById(ObjName)[i].text == NValue)
		{
			document.getElementById(ObjName).selectedIndex = i;
			break;
		}
	}
	
}

function SelectOptionValue(ObjName,NValue)
{
	
	var objCount = document.getElementById(ObjName).options.length;
	
	for(i=0;i<=objCount-1;i++)
	{
		if(document.getElementById(ObjName)[i].value == NValue)
		{
			document.getElementById(ObjName).selectedIndex = i;
			break;
		}
	}
	
}

function getOptionTextFromValue(ObjName,NValue)
{
	
	var objCount = document.getElementById(ObjName).options.length;
	var opText = "";
	
	for(i=0;i<=objCount-1;i++)
	{
		if(document.getElementById(ObjName)[i].value == NValue)
		{
			//document.getElementById(ObjName).selectedIndex = i;
			opText = document.getElementById(ObjName)[i].text;
			break;
		}
	}
	
	return opText;
}

function getIndexValueFromValue(ObjName,NValue)
{
	
	var objCount = document.getElementById(ObjName).options.length;
	var indexValue = "";
	
	for(i=0;i<=objCount-1;i++)
	{
		if(document.getElementById(ObjName)[i].value == NValue)
		{
			//document.getElementById(ObjName).selectedIndex = i;
			indexValue = i;
			break;
		}
	}
	
	return indexValue;
}

function dateFromPopupCalendarToSlash(date)
{
	var slashDate = "";
	if(trim(date)!="")
	{
		arr = date.split(" ")
		
		switch(arr[1])
		{
			case "Jan": month ="01";break;
			case "Feb": month ="02";break;
			case "Mar": month ="03";break;
			case "Apr": month ="04";break;
			case "May": month ="05";break;
			case "Jun": month ="06";break;
			case "Jul": month ="07";break;
			case "Aug": month ="08";break;
			case "Sep": month ="09";break;
			case "Oct": month ="10";break;
			case "Nov": month ="11";break;
			case "Dec": month ="12";break;
		}
		
		slashDate = arr[0]+"/"+month+"/"+arr[2];
		
	}
	else
	{
	  slashDate = "";
	}
	
	return slashDate;
}

function decodeURIToHTML(text)
{	
	text = decodeURIComponent(text);
	text = text.replace(/\n/g,'<br>');
	text = text.replace(/ /g,'&nbsp;');
	return text;
}

function checkFileType_Image(filename)
{
	var fileType=new Array();
			fileType[0]=".jpg";
			fileType[1]=".gif";
			fileType[2]=".jpeg";
			fileType[3]=".png";
			chk=false;
			
		newb=filename.lastIndexOf(".");
		tempb=filename.substr(newb,filename.length);
		tempb = tempb.toLowerCase();	
		for(x=0;x<=fileType.length-1;x++)
		{
			if(tempb==fileType[x])
			{
				chk=true;break;
			}
		}	
			
			return chk;
			
}

function checkFileType_Jpeg(filename)
{
	var fileType=new Array();
			fileType[0]=".jpg";
			fileType[1]=".jpeg";
			chk=false;
			
		newb=filename.lastIndexOf(".");
		tempb=filename.substr(newb,filename.length);
		tempb = tempb.toLowerCase();	
		for(x=0;x<=fileType.length-1;x++)
		{
			if(tempb==fileType[x])
			{
				chk=true;break;
			}
		}	
			
			return chk;
			
}

function checkFileNameForPhpThumb(filename)
{
			
			
		newx = filename.lastIndexOf('\\');
		
		tempb = filename.substr(newx+1,filename.length);
		newb = tempb.lastIndexOf(".");
		tempB = tempb.substr(0,newb);
		tempB = tempB.toLowerCase();//alert(tempB)	
		
		digit = tempB
		var chk = true;
		for (var i=0;i<digit.length;i++)
		{
			if ((!(digit.charAt(i)>="0" &&digit.charAt(i)<="9")) && (!(digit.charAt(i)>="a" &&digit.charAt(i)<="z")) && (!(digit.charAt(i)==" ")) && (!(digit.charAt(i)=="_"))  && (!(digit.charAt(i)=="(")) && (!(digit.charAt(i)==")")) && (!(digit.charAt(i)=="-")) && (!(digit.charAt(i)=="[")) && (!(digit.charAt(i)=="]")) )
			
			{ 
				chk = false;
			}
		}
		
		return chk;
		
			
}

function checkFileType_Pdf(filename)
{
	var fileType=new Array();
			fileType[0]=".pdf";
			chk=false;
			
		newb=filename.lastIndexOf(".");
		tempb=filename.substr(newb,filename.length);
		tempb = tempb.toLowerCase();	
		for(x=0;x<=fileType.length-1;x++)
		{
			if(tempb==fileType[x])
			{
				chk=true;break;
			}
		}	
			
			return chk;
			
}

function addOneDigit(num)
{
	num = num.toString();
	
	if(num.length<2)
	{
		num = ("0"+num); ;
	}
	
	return num;
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function getRadioCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function checkControl_id(checkBoxID,ControlName)
{
	reg3 = new RegExp(ControlName);
	r = checkBoxID.search(reg3);
	if(r!=-1)
	{
		return true;
	}
	else
	{
		return false;
	}

}



function ucwords( str ) 
{   
   return (str+'').replace(/^(.)|\s(.)/g, function ( $1 ) { return $1.toUpperCase ( ); } );   
}  

function trim(str)
{
 return str.replace(/^\s+|\s+$/g, ''); 
}

function stripslash(value)
{
	
	re = /\\'/;
  	r = value.replace(re, "'");
	return r;
}
function pageRefresh()
{
	window.location.reload(true) ;
}
function findPosX(objX)
  {
    var curleft = 0;
    if(objX.offsetParent)
        while(1) 
        {
          curleft += objX.offsetLeft;
          if(!objX.offsetParent)
            break;
          objX = objX.offsetParent;
        }
    else if(objX.x)
        curleft += objX.x;
    return curleft;
  }

  function findPosY(objY)
  {
    var curtop = 0;
    if(objY.offsetParent)
        while(1)
        {
          curtop += objY.offsetTop;
          if(!objY.offsetParent)
            break;
          objY = objY.offsetParent;
        }
    else if(objY.y)
        curtop += objY.y;
    return curtop;
  }
  
function pageRefresh()
{
	window.location.reload(true) ;
}


//--------------------- Popup High Authenticate -------------------//

function checkEnterPopupHighAuthenticate(e)
{
    e = e || window.event;
    var code = e.keyCode || e.which;
	
    if(code == 13)
      {
	  	checkPopupHighAuthenticate();
		return false;
	  }
}

function checkPopupHighAuthenticate()
{
	if(trim(document.getElementById("PopupHighAuthenticate_email").value)=="" || trim(document.getElementById("PopupHighAuthenticate_user_password").value)=="" || trim(document.getElementById("PopupHighAuthenticate_admin_password").value)=="")
	{
		PopupHighAuthenticate_ShowError();
		document.getElementById("PopupHighAuthenticate_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
		
	}
	else
	{	
			
			if(checkEmailSyntax(trim(document.getElementById("PopupHighAuthenticate_email").value))==false)
			{
				PopupHighAuthenticate_ShowError();
				document.getElementById("PopupHighAuthenticate_ErrorText").innerHTML = "Please enter a valid email address.";	
			}
			else
			{
				if(trim(document.getElementById("PopupHighAuthenticate_email").value)!=document.getElementById("PopupHighAuthenticate_owner_email").value)
				{
					PopupHighAuthenticate_ShowError();
					document.getElementById("PopupHighAuthenticate_ErrorText").innerHTML = "Please check your email.";
				}
				else
				{
					document.getElementById("PopupHighAuthenticate_ErrorText").innerHTML = "Please wait...";
					PopupHighAuthenticate_ShowSuccess();
					//document.getElementById("PopupHighAuthenticate_btnSave").disabled = true;
					//document.getElementById("PopupHighAuthenticate_btnCancel").disabled = true;
					checkHighAuthenticate();
				}
			}
			
	}
	
	
	if(trim(document.getElementById("PopupHighAuthenticate_email").value)=="" || checkEmailSyntax(document.getElementById("PopupHighAuthenticate_email").value)==false)
	{
		document.getElementById("PopupHighAuthenticate_email").className="txtbox_error250";
	}
	else
	{
		document.getElementById("PopupHighAuthenticate_email").className="txtbox250";
	}
	
	if(trim(document.getElementById("PopupHighAuthenticate_user_password").value)=="" )
	{
		document.getElementById("PopupHighAuthenticate_user_password").className="txtbox_error250";
	}
	else
	{
		document.getElementById("PopupHighAuthenticate_user_password").className="txtbox250";
	}
	
	if(trim(document.getElementById("PopupHighAuthenticate_admin_password").value)=="")
	{
		document.getElementById("PopupHighAuthenticate_admin_password").className="txtbox_error250";
	}
	else
	{
		document.getElementById("PopupHighAuthenticate_admin_password").className="txtbox250";
	}
	
	
	
	
}

function checkHighAuthenticate()
{
			//alert('s')	
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_check_high_authenticate.php?user_email="+trim(document.getElementById("PopupHighAuthenticate_email").value)+"&user_password="+trim(document.getElementById("PopupHighAuthenticate_user_password").value)+"&admin_password="+document.getElementById("PopupHighAuthenticate_admin_password").value+"&user_id="+document.getElementById("agent_id").value+"&goType="+document.getElementById("PopupHighAuthenticate_goType").value;  
	  
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						 if(CList!="No")
						 {
							 goType = document.getElementById("PopupHighAuthenticate_goType").value;
							if(goType=="editPrivileges")
							{
								window.location = "user_privileges_edit.php?user_id="+document.getElementById("agent_id").value+"&viewType="+document.getElementById("viewType").value+"&secure_code="+CList;
							}
							else if(goType=="changeEmail")
							{
								window.location = "user_email_edit.php?user_id="+document.getElementById("agent_id").value+"&viewType="+document.getElementById("viewType").value+"&secure_code="+CList;
							}
							else if(goType=="changePassword")
							{
								window.location = "user_password_edit.php?user_id="+document.getElementById("agent_id").value+"&viewType="+document.getElementById("viewType").value+"&secure_code="+CList;
							}
							else if(goType=="actionAccount")
							{
								window.location = "user_status_edit.php?user_id="+document.getElementById("agent_id").value+"&viewType="+document.getElementById("viewType").value+"&secure_code="+CList;
							}
							
						 }
						 else
						 {
						 	PopupHighAuthenticate_ShowError();
							document.getElementById("PopupHighAuthenticate_ErrorText").innerHTML = "Please check email or password.";	
							document.getElementById("PopupHighAuthenticate_btnSave").disabled = false;
							document.getElementById("PopupHighAuthenticate_btnCancel").disabled = false;
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}


function showPopupHighAuthenticate(goType)
{
	if(document.getElementById("PopupHighAuthenticate"))
	{
		document.getElementById("PopupHighAuthenticate").style.display="";
		//document.getElementById("PopupHighAuthenticate").style.top=((screen.height-200)*0.35)+"px";
		//document.getElementById("PopupHighAuthenticate").style.left=((screen.width+200)*0.25)+"px";
		document.getElementById("PopupHighAuthenticate").style.top=( ( (screen.height/2)+getScrollY() - 300 ))+"px";
		document.getElementById("PopupHighAuthenticate").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupHighAuthenticate").style.zIndex=130;
		
		
		document.getElementById("PopupHighAuthenticate_btnSave").disabled = false;
		document.getElementById("PopupHighAuthenticate_btnCancel").disabled = false;
		
		//document.getElementById("PopupHighAuthenticate_btnSave").onclick = null ;
		//document.getElementById("PopupHighAuthenticate_btnSave").onclick = function(){checkPopupHighAuthenticate();}
		document.getElementById("PopupHighAuthenticate_goType").value = goType;
					
	}
}

function hidePopupHighAuthenticate()
{
	if(document.getElementById("PopupHighAuthenticate"))
	{
		document.getElementById("PopupHighAuthenticate_email").value ="";
		document.getElementById("PopupHighAuthenticate_email").className="txtbox250";
		
		document.getElementById("PopupHighAuthenticate_user_password").value ="";
		document.getElementById("PopupHighAuthenticate_user_password").className="txtbox250";
		
		document.getElementById("PopupHighAuthenticate_admin_password").value ="";
		document.getElementById("PopupHighAuthenticate_admin_password").className="txtbox250";
		
		document.getElementById("PopupHighAuthenticate_ShowError1").style.display="none";
		document.getElementById("PopupHighAuthenticate").style.display="none";
	}
	
}

function PopupHighAuthenticate_ShowError()
{
	document.getElementById("PopupHighAuthenticate_ShowError1").style.display="";
	document.getElementById("PopupHighAuthenticate_ShowErrorBox").className = "mode_error";
	
}

function PopupHighAuthenticate_ShowSuccess()
{
	document.getElementById("PopupHighAuthenticate_ShowError1").style.display="";
	document.getElementById("PopupHighAuthenticate_ShowErrorBox").className = "mode_success";
	
}

function PopupHighAuthenticate_CloseError()
{
	document.getElementById("PopupHighAuthenticate_ShowError1").style.display="none";
	
	
}	

//----------------------------------------------------------------//



function checkPopupUserPostNotice()
{
	if(trim(document.getElementById("notice_text").value)=="" || trim(document.getElementById("notice_text").value)=="Write something on the wall...")
	{
		
		ShowError();
		document.getElementById("ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
	}
	else
	{
			
			
				ShowSuccess();
				document.getElementById("ErrorText").innerHTML = "Please wait...";
				document.getElementById("btnSave").disabled = true;
				postUserNotice();
			
	}
	
	
	if(trim(document.getElementById("notice_text").value)=="" || trim(document.getElementById("notice_text").value)=="Write something on the wall...")
	{
		document.getElementById("notice_text").className="table_error";
	}
	else
	{
		document.getElementById("notice_text").className="fake";
	}
	
	
	
	
}

function postUserNotice()
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_user_post_notice.php?user_id="+document.getElementById("user_id").value+"&notice_text="+trim(encodeURIComponent(document.getElementById("notice_text").value)); 
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						if(CList!="No")
						 {
							window.location = "start.php";
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}



function showPopupUserPostNotice()
{
	if(document.getElementById("PopupUserPostNotice"))
	{
		
		//document.getElementById("PopupUserPostNotice").style.display="";
		$("#PopupUserPostNotice").show("slow");
		document.getElementById("PopupUserPostNotice").style.top=((screen.height-200)*0.20)+"px";
		document.getElementById("PopupUserPostNotice").style.left=((screen.width+200)*0.25)+"px";
		document.getElementById("PopupUserPostNotice").style.zIndex=140;
		
		document.getElementById("PopupUserPostNotice_btnSave").disabled = false;
		document.getElementById("PopupUserPostNotice_btnCancel").disabled = false;
		
	}
}



function hidePopupUserPostNotice()
{
	if(document.getElementById("PopupUserPostNotice"))
	{
		
		document.getElementById("notice_text").value ="";
		document.getElementById("notice_text").className="fake";
		
		document.getElementById("PopupUserPostNotice_ShowError1").style.display="none";
		document.getElementById("PopupUserPostNotice_ShowError2").style.display="none";
		
		$("#PopupUserPostNotice").hide("slow");
		//document.getElementById("PopupUserPostNotice").style.display="none";
		
		//showPopupAddCompanyChangeShipMethod();
	}
	
}

function PopupUserPostNotice_ShowError()
{
	document.getElementById("PopupUserPostNotice_ShowError1").style.display="";
	document.getElementById("PopupUserPostNotice_ShowError2").style.display="";
	document.getElementById("PopupUserPostNotice_ShowErrorBox").className = "mode_error";
	
}

function PopupUserPostNotice_ShowSuccess()
{
	document.getElementById("PopupUserPostNotice_ShowError1").style.display="";
	document.getElementById("PopupUserPostNotice_ShowError2").style.display="";
	document.getElementById("PopupUserPostNotice_ShowErrorBox").className = "mode_success";
	
}

function PopupUserPostNotice_CloseError()
{
	document.getElementById("PopupUserPostNotice_ShowError1").style.display="none";
	document.getElementById("PopupUserPostNotice_ShowError2").style.display="none";
	
	
}	

//--------------------------------------------------------//



function checkPostcomment()
{
	if(trim(document.getElementById("comment_text").value)!="")
	{
		return true;
	}
	else
	{
		return false;
	}
}

function ShowError()
{
	document.getElementById("ShowError1").style.display="";
	document.getElementById("ShowError2").style.display="";
	document.getElementById("ShowErrorBox").className = "mode_error";
	
}

function ShowSuccess()
{
	document.getElementById("ShowError1").style.display="";
	document.getElementById("ShowError2").style.display="";
	document.getElementById("ShowErrorBox").className = "mode_success";
	
}
function CloseError()
{
	document.getElementById("ShowError1").style.display="none";
	document.getElementById("ShowError2").style.display="none";
}


function createAutoElement(CList)
{
	document.getElementById("auto_com").style.display ="";
	ClearChildNodes("auto_com");
	var ul = document.createElement("ul");
	var lix = document.createElement("li");
		lix.className = "li_normal2";
		lix.onmouseover = null;
		lix.onmouseover = function(){this.className="li_over2";};
		lix.onmouseout = null;
		lix.onmouseout = function(){this.className="li_normal2";};
		lix.onclick = null;
		lix.onclick = function(){showPopupAddCompany();removeAuto();};
		lix.innerHTML = "Add New Company";
	ul.appendChild(lix); 
	
	var allResult=CList.split("!#!#!");
	for (var i = 0; i < allResult.length-1; i++)
	{
		var result=allResult[i].split("!*!");    
		var CName = result[0];
		var CId = result[1];
		
		//class='li_normal'  onmouseover='this.className=\"li_over\"' onmouseout='this.className=\"li_normal\"' onclick='selectName(\"".$val["companyname"].$cus_id."\",\"".$val["cid"]."\");'
		
		var li = document.createElement("li");
		li.setAttribute("id",CId);
		li.className = "li_normal";
		li.onmouseover = null;
		li.onmouseover = function(){this.className="li_over";};
		li.onmouseout = null;
		li.onmouseout = function(){this.className="li_normal";};
		li.onclick = null;
		li.onclick = function(){selectName(this.innerHTML,this.id)};
		
		li.innerHTML = CName;
		ul.appendChild(li); 
	}
	
	document.getElementById("auto_com").appendChild(ul);
	
}

function createAutoElementForSalePack(CList)
{
	document.getElementById("auto_com").style.display ="";
	ClearChildNodes("auto_com");
	var ul = document.createElement("ul");
	var lix = document.createElement("li");
		lix.className = "li_normal2";
		lix.onmouseover = null;
		lix.onmouseover = function(){this.className="li_over2";};
		lix.onmouseout = null;
		lix.onmouseout = function(){this.className="li_normal2";};
		lix.onclick = null;
		lix.onclick = function(){showPopupAddCompany();removeAuto();};
		lix.innerHTML = "Add New Company";
	ul.appendChild(lix); 
	
	var allResult=CList.split("!#!#!");
	for (var i = 0; i < allResult.length-1; i++)
	{
		var result=allResult[i].split("!*!");    
		var CName = result[0];
		var CId = result[1];
		var company_name = result[2];
		
		
		
		var li = document.createElement("li");
		li.setAttribute("id",CId);
		li.x = company_name.toUpperCase();
		li.className = "li_normal";
		li.onmouseover = null;
		li.onmouseover = function(){this.className="li_over";};
		li.onmouseout = null;
		li.onmouseout = function(){this.className="li_normal";};
		li.onclick = null;
		li.onclick = function(){selectNameForSalePack(this.innerHTML,this.id,this.x)};
		
		li.innerHTML = CName;
		ul.appendChild(li); 
	}
	
	document.getElementById("auto_com").appendChild(ul);
	
}



function setCompanyAddFrom()
{
	if(document.getElementById("PopupAddCompany_add_from"))
	{
		document.getElementById("PopupAddCompany_add_from").value="quote";
	}
}

function createAutoElementForQuote(CList)
{
	document.getElementById("auto_com").style.display ="";
	ClearChildNodes("auto_com");
	var ul = document.createElement("ul");
	var lix = document.createElement("li");
		lix.className = "li_normal2";
		lix.onmouseover = null;
		lix.onmouseover = function(){this.className="li_over2";};
		lix.onmouseout = null;
		lix.onmouseout = function(){this.className="li_normal2";};
		lix.onclick = null;
		lix.onclick = function(){showPopupAddCompany();removeAuto();setCompanyAddFrom();};
		lix.innerHTML = "Add New Company";
	ul.appendChild(lix); 
	
	var allResult=CList.split("!#!#!");
	for (var i = 0; i < allResult.length-1; i++)
	{
		var result=allResult[i].split("!*!");    
		var CName = result[0];
		var CId = result[1];
		var discount_level = result[2];
		
		//class='li_normal'  onmouseover='this.className=\"li_over\"' onmouseout='this.className=\"li_normal\"' onclick='selectName(\"".$val["companyname"].$cus_id."\",\"".$val["cid"]."\");'
		
		var li = document.createElement("li");
		li.setAttribute("id",CId);
		li.x = discount_level;
		li.className = "li_normal";
		li.onmouseover = null;
		li.onmouseover = function(){this.className="li_over";};
		li.onmouseout = null;
		li.onmouseout = function(){this.className="li_normal";};
		li.onclick = null;
		li.onclick = function(){selectNameForQuote(this.innerHTML,this.id,this.x)};
		
		li.innerHTML = CName;
		ul.appendChild(li); 
	}
	
	document.getElementById("auto_com").appendChild(ul);
	
}
//----------------------Cancel Order--------------------------//

function cancelOrder()
{
				PopupCancelOrder_ShowSuccess();
				document.getElementById("PopupCancelOrder_ErrorText").innerHTML = "Please wait...";
				document.getElementById("PopupCancelOrder_btnSave").disabled =true;
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_cancel_order.php?order_id="+document.getElementById("order_id").value+"&order_no="+trim(document.getElementById("PopupCancelOrder_order_no").value)+"&user_id="+document.getElementById("user_id").value+"&company_name="+document.getElementById("company_name2").value+"&agent_id="+document.getElementById("agent_id").value;  
	  
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//document.getElementById("PopupCancelOrder_ErrorText").innerHTML = CList;//alert(CList)				 
						 if(CList!="No")
						 {
							hidePopupCancelOrder();
							pageRefresh();
							
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}

function showPopupCancelOrder()
{
	if(document.getElementById("PopupCancelOrder"))
	{
		document.getElementById("PopupCancelOrder_btnSave").disabled =false;
		
		document.getElementById("PopupCancelOrder").style.display="";
		document.getElementById("PopupCancelOrder").style.top=((screen.height-200)*0.25)+"px";
		document.getElementById("PopupCancelOrder").style.left=((screen.width+200)*0.23)+"px";
		document.getElementById("PopupCancelOrder").style.zIndex=160;
	}
}

function hidePopupCancelOrder()
{
	if(document.getElementById("PopupCancelOrder"))
	{
		
		document.getElementById("PopupCancelOrder").style.display="none";
	}
	
}

function PopupCancelOrder_ShowError()
{
	document.getElementById("PopupCancelOrder_ShowError1").style.display="";
	document.getElementById("PopupCancelOrder_ShowError2").style.display="";
	document.getElementById("PopupCancelOrder_ShowErrorBox").className = "mode_error";
	
}

function PopupCancelOrder_ShowSuccess()
{
	document.getElementById("PopupCancelOrder_ShowError1").style.display="";
	document.getElementById("PopupCancelOrder_ShowError2").style.display="";
	document.getElementById("PopupCancelOrder_ShowErrorBox").className = "mode_success";
	
}



function PopupCancelOrder_CloseError()
{
	document.getElementById("PopupCancelOrder_ShowError1").style.display="none";
	document.getElementById("PopupCancelOrder_ShowError2").style.display="none";
	//document.getElementById("PopupApproveAmendOrder_ShowErrorBox").className = "txt_mode_error";
	
}	


//------------------------------------------------------------//

//-------------------- Popup Edit Contact ----------------//

function checkPopupEditContact()
{
	if(trim(document.getElementById("PopupEditContact_fullname").value)=="" || trim(document.getElementById("PopupEditContact_salutation").value)=="" || trim(document.getElementById("PopupEditContact_email").value)=="")
	{
		PopupEditContact_ShowError();
		document.getElementById("PopupEditContact_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
		
	}
	else
	{
			
			if(document.getElementById("PopupEditContact_email").value.indexOf ('@',0) == -1 || document.getElementById("PopupEditContact_email").value.indexOf ('.',0) == -1)
			{
				PopupEditContact_ShowError();
				document.getElementById("PopupEditContact_ErrorText").innerHTML = "Please enter a valid email address.";
				
				
			}
			else
			{
				PopupEditContact_CloseError();
				if( trim(document.getElementById("PopupEditContact_email").value)!= document.getElementById("old_email").value)
				{
					
					var email ="";
					
					
					
					if(trim(document.getElementById("PopupEditContact_email").value)!= document.getElementById("old_email").value)
					{
						email = trim(document.getElementById("PopupEditContact_email").value)
					}
					
					checkFullName(email);
				}
				else
				{
					PopupEditContact_ShowSuccess();
					document.getElementById("PopupEditContact_ErrorText").innerHTML = "Please wait...";
					document.getElementById("PopupEditContact_btnSave").disabled =true;
					editCompanyContact();
				}
			}
	}
	
	
	if(trim(document.getElementById("PopupEditContact_fullname").value)=="")
	{
		document.getElementById("PopupEditContact_fullname").className="txtbox_error180";
	}
	else
	{
		document.getElementById("PopupEditContact_fullname").className="txtbox180";
	}
	
	if(trim(document.getElementById("PopupEditContact_salutation").value)=="")
	{
		document.getElementById("PopupEditContact_salutation").className="txtbox_error180";
	}
	else
	{
		document.getElementById("PopupEditContact_salutation").className="txtbox180";
	}
	
	if(trim(document.getElementById("PopupEditContact_email").value)=="" || document.getElementById("PopupEditContact_email").value.indexOf ('@',0) == -1 || document.getElementById("PopupEditContact_email").value.indexOf ('.',0) == -1)
	{
		document.getElementById("PopupEditContact_email").className="txtbox_error180";
	}
	else
	{
		document.getElementById("PopupEditContact_email").className="txtbox180";
	}
	
	
}

function checkFullName(email)
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_check_contact_fullname.php?email="+email;  
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						 if(CList=="Yes")
						 {
							
								PopupEditContact_ShowError();
								document.getElementById("PopupEditContact_ErrorText").innerHTML = "Email Exist.";
								document.getElementById("PopupEditContact_email").className="txtbox_error180";
								
							
						 }
						 else
						 {
						 	PopupEditContact_ShowSuccess();
							document.getElementById("PopupEditContact_ErrorText").innerHTML = "Please wait...";
							document.getElementById("PopupEditContact_btnSave").disabled =true;
							editCompanyContact();
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}

function editCompanyContact()
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_edit_company_contact.php?cname="+trim(encodeURIComponent(document.getElementById("PopupEditContact_fullname").value))+"&salutation="+trim(encodeURIComponent(document.getElementById("PopupEditContact_salutation").value))+"&telephone="+trim(encodeURIComponent(document.getElementById("PopupEditContact_telephone").value))+"&fax="+trim(encodeURIComponent(document.getElementById("PopupEditContact_fax").value))+"&email="+trim(document.getElementById("PopupEditContact_email").value)+"&ccid="+document.getElementById("contact_id").value+"&uid="+document.getElementById("user_id").value;  
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						 if(CList!="No")
						 {
							hidePopupEditContact();
							pageRefresh();
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}

function showPopupEditContact()
{
	if(document.getElementById("PopupEditContact"))
	{
		
		document.getElementById("PopupEditContact_fullname").value = document.getElementById("contact_name").value;
		document.getElementById("PopupEditContact_salutation").value = document.getElementById("contact_salutation").value;
		document.getElementById("PopupEditContact_telephone").value = document.getElementById("contact_telephone").value;
		document.getElementById("PopupEditContact_fax").value = document.getElementById("contact_fax").value;
		document.getElementById("PopupEditContact_email").value = document.getElementById("contact_email").value;
		
		
		document.getElementById("old_email").value = document.getElementById("contact_email").value;
		
		document.getElementById("PopupEditContact").style.display="";
		document.getElementById("PopupEditContact").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupEditContact").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupEditContact").style.zIndex=120;
	}
}

function hidePopupEditContact()
{
	if(document.getElementById("PopupEditContact"))
	{
		document.getElementById("PopupEditContact_fullname").value ="";
		document.getElementById("PopupEditContact_salutation").value ="";
		document.getElementById("PopupEditContact_telephone").value ="";
		document.getElementById("PopupEditContact_fax").value ="";
		document.getElementById("PopupEditContact_email").value ="";
		
		document.getElementById("PopupEditContact_fullname").className="txtbox180";
		document.getElementById("PopupEditContact_salutation").className="txtbox180";
		document.getElementById("PopupEditContact_email").className="txtbox180";
		
		document.getElementById("PopupEditContact_ShowError1").style.display="none";
		document.getElementById("PopupEditContact_ShowError2").style.display="none";
		document.getElementById("PopupEditContact").style.display="none";
	}
	
}

function PopupEditContact_ShowError()
{
	document.getElementById("PopupEditContact_ShowError1").style.display="";
	document.getElementById("PopupEditContact_ShowError2").style.display="";
	document.getElementById("PopupEditContact_ShowErrorBox").className = "mode_error";
	
}

function PopupEditContact_ShowSuccess()
{
	document.getElementById("PopupEditContact_ShowError1").style.display="";
	document.getElementById("PopupEditContact_ShowError2").style.display="";
	document.getElementById("PopupEditContact_ShowErrorBox").className = "mode_success";
	
}

function PopupEditContact_CloseError()
{
	document.getElementById("PopupEditContact_ShowError1").style.display="none";
	document.getElementById("PopupEditContact_ShowError2").style.display="none";
	//document.getElementById("PopupEditContact_ShowErrorBox").className = "txt_mode_error";
	
}	

//-------------------------------------------------------------//

//--------------------------- Popup Edit Company ---------------//

function checkPopupEditCompany()
{
	if(trim(document.getElementById("PopupEditCompany_company_name").value)=="" )
	{
		PopupEditCompany_ShowError();
		document.getElementById("PopupEditCompany_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
		
	}
	else
	{
			
			
				PopupEditCompany_ShowSuccess();
				document.getElementById("PopupEditCompany_ErrorText").innerHTML = "Please wait...";
				document.getElementById("PopupEditCompany_btnSave").disabled =true;
				editCompany();
			
	}
	
	
	if(trim(document.getElementById("PopupEditCompany_company_name").value)=="")
	{
		document.getElementById("PopupEditCompany_company_name").className="txtbox_error250";
	}
	else
	{
		document.getElementById("PopupEditCompany_company_name").className="txtbox250";
	}
	
	
	
	
}

function editCompany()
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_edit_company.php?companyname="+trim(encodeURIComponent(document.getElementById("PopupEditCompany_company_name").value))+"&customerid="+trim(encodeURIComponent(document.getElementById("PopupEditCompany_customer_id").value))+"&accountid="+trim(document.getElementById("PopupEditCompany_agent_id").value)+"&company_id="+document.getElementById("company_id").value+"&address="+trim(encodeURIComponent(document.getElementById("PopupEditCompany_address").value))+"&country="+trim(document.getElementById("PopupEditCompany_country").value)+"&telephone="+trim(encodeURIComponent(document.getElementById("PopupEditCompany_telephone").value))+"&fax="+trim(encodeURIComponent(document.getElementById("PopupEditCompany_fax").value));
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						if(CList!="No")
						 {
							hidePopupEditCompany();
							pageRefresh();
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}

function showPopupEditCompany()
{
	if(document.getElementById("PopupEditCompany"))
	{
		
		document.getElementById("PopupEditCompany_company_name").value = document.getElementById("company_name").value;
		document.getElementById("PopupEditCompany_customer_id").value = document.getElementById("company_customer_id").value;
		document.getElementById("PopupEditCompany_agent_id").value = document.getElementById("account_manager_id").value;
		document.getElementById("PopupEditCompany_address").value = trim(document.getElementById("company_address").value);
		//document.getElementById("PopupEditCompany_city").value = document.getElementById("company_city").value;
		//document.getElementById("PopupEditCompany_region").value = document.getElementById("company_region").value;
		//document.getElementById("PopupEditCompany_postcode").value = document.getElementById("company_postcode").value;
		document.getElementById("PopupEditCompany_telephone").value = document.getElementById("company_telephone").value;
		document.getElementById("PopupEditCompany_fax").value = document.getElementById("company_fax").value;
		
		SelectOption('PopupEditCompany_country',document.getElementById("company_country").value);
		//alert(document.getElementById("company_country").value);
		
		document.getElementById("PopupEditCompany").style.display="";
		document.getElementById("PopupEditCompany").style.top=((screen.height-500)*0.35)+"px";
		document.getElementById("PopupEditCompany").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupEditCompany").style.zIndex=140;
	}
}

function hidePopupEditCompany()
{
	if(document.getElementById("PopupEditCompany"))
	{
		document.getElementById("PopupEditCompany_company_name").value ="";
		document.getElementById("PopupEditCompany_agent_id").selectedIndex = 0;
		
		document.getElementById("PopupEditCompany_company_name").className="txtbox250";
		
		document.getElementById("PopupEditCompany_ShowError1").style.display="none";
		document.getElementById("PopupEditCompany_ShowError2").style.display="none";
		document.getElementById("PopupEditCompany").style.display="none";
	}
	
}

function PopupEditCompany_ShowError()
{
	document.getElementById("PopupEditCompany_ShowError1").style.display="";
	document.getElementById("PopupEditCompany_ShowError2").style.display="";
	document.getElementById("PopupEditCompany_ShowErrorBox").className = "mode_error";
	
}

function PopupEditCompany_ShowSuccess()
{
	document.getElementById("PopupEditCompany_ShowError1").style.display="";
	document.getElementById("PopupEditCompany_ShowError2").style.display="";
	document.getElementById("PopupEditCompany_ShowErrorBox").className = "mode_success";
	
}

function PopupEditCompany_CloseError()
{
	document.getElementById("PopupEditCompany_ShowError1").style.display="none";
	document.getElementById("PopupEditCompany_ShowError2").style.display="none";
	//document.getElementById("PopupAddContact_ShowErrorBox").className = "txt_mode_error";
	
}	

//-------------------------------------------------------------//

//----------------------- Popup Add Contact  ------------------------//

function checkPopupAddContact()
{
	if(trim(document.getElementById("PopupAddContact_fullname").value)=="" || trim(document.getElementById("PopupAddContact_salutation").value)=="" || trim(document.getElementById("PopupAddContact_email").value)=="")
	{
		PopupAddContact_ShowError();
		document.getElementById("PopupAddContact_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
		
	}
	else if(checkTelephoneAndFaxSyntax(document.getElementById("PopupAddContact_telephone"))==false || checkTelephoneAndFaxSyntax(document.getElementById("PopupAddContact_telephone"))==false )
	{
		PopupAddContact_ShowError();
		document.getElementById("PopupAddContact_ErrorText").innerHTML = "For Telephone and Fax use 0-9 +-/* only.";
	}
	else
	{
			
			if(document.getElementById("PopupAddContact_email").value.indexOf ('@',0) == -1 || document.getElementById("PopupAddContact_email").value.indexOf ('.',0) == -1)
			{
				PopupAddContact_ShowError();
				document.getElementById("PopupAddContact_ErrorText").innerHTML = "Please enter a valid email address.";
				
				
			}
			else
			{
				
				PopupAddContact_ShowSuccess();
				document.getElementById("PopupAddContact_ErrorText").innerHTML = "Please wait...";
				document.getElementById("PopupAddContact_btnSave").disabled =true;
				checkFullName1(trim(document.getElementById("PopupAddContact_email").value));
			}
	}
	
	
	if(trim(document.getElementById("PopupAddContact_fullname").value)=="")
	{
		document.getElementById("PopupAddContact_fullname").className="txtbox_error180";
	}
	else
	{
		document.getElementById("PopupAddContact_fullname").className="txtbox180";
	}
	
	if(trim(document.getElementById("PopupAddContact_salutation").value)=="")
	{
		document.getElementById("PopupAddContact_salutation").className="txtbox_error180";
	}
	else
	{
		document.getElementById("PopupAddContact_salutation").className="txtbox180";
	}
	
	if(trim(document.getElementById("PopupAddContact_email").value)=="" || document.getElementById("PopupAddContact_email").value.indexOf ('@',0) == -1 || document.getElementById("PopupAddContact_email").value.indexOf ('.',0) == -1)
	{
		document.getElementById("PopupAddContact_email").className="txtbox_error180";
	}
	else
	{
		document.getElementById("PopupAddContact_email").className="txtbox180";
	}
	
	
}

function checkFullName1(email)
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_check_contact_fullname.php?email="+email;  
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						 
						 if(CList=="Yes")
						 {
							
								PopupAddContact_ShowError();
								document.getElementById("PopupAddContact_btnSave").disabled =false;
								document.getElementById("PopupAddContact_ErrorText").innerHTML = "Email Exist.";
								document.getElementById("PopupAddContact_email").className="txtbox_error180";
							
							
						 }
						 else
						 {
						 	addNewCompanyContact();
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}

function addNewCompanyContact()
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_add_company_contact.php?cname="+trim(encodeURIComponent(document.getElementById("PopupAddContact_fullname").value))+"&salutation="+trim(encodeURIComponent(document.getElementById("PopupAddContact_salutation").value))+"&telephone="+trim(encodeURIComponent(document.getElementById("PopupAddContact_telephone").value))+"&fax="+trim(encodeURIComponent(document.getElementById("PopupAddContact_fax").value))+"&email="+trim(document.getElementById("PopupAddContact_email").value)+"&cid="+document.getElementById("company_id").value+"&uid="+document.getElementById("user_id").value;  
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						 if(CList!="No")
						 {
							getCompanyContact(document.getElementById("company_id").value,CList);
							hidePopupAddContact();
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}

function showPopupAddContact()
{
	if(document.getElementById("PopupAddContact"))
	{
		document.getElementById("PopupAddContact_btnSave").disabled =false;
		document.getElementById("PopupAddContact").style.display="";
		document.getElementById("PopupAddContact").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupAddContact").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupAddContact").style.zIndex=120;
	}
}

function hidePopupAddContact()
{
	if(document.getElementById("PopupAddContact"))
	{
		document.getElementById("PopupAddContact_fullname").value ="";
		document.getElementById("PopupAddContact_salutation").value ="";
		document.getElementById("PopupAddContact_telephone").value ="";
		document.getElementById("PopupAddContact_fax").value ="";
		document.getElementById("PopupAddContact_email").value ="";
		
		document.getElementById("PopupAddContact_fullname").className="txtbox180";
		document.getElementById("PopupAddContact_salutation").className="txtbox180";
		document.getElementById("PopupAddContact_email").className="txtbox180";
		
		document.getElementById("PopupAddContact_ShowError1").style.display="none";
		document.getElementById("PopupAddContact_ShowError2").style.display="none";
		document.getElementById("PopupAddContact").style.display="none";
	}
	
}

function PopupAddContact_ShowError()
{
	document.getElementById("PopupAddContact_ShowError1").style.display="";
	document.getElementById("PopupAddContact_ShowError2").style.display="";
	document.getElementById("PopupAddContact_ShowErrorBox").className = "mode_error";
	
}

function PopupAddContact_ShowSuccess()
{
	document.getElementById("PopupAddContact_ShowError1").style.display="";
	document.getElementById("PopupAddContact_ShowError2").style.display="";
	document.getElementById("PopupAddContact_ShowErrorBox").className = "mode_success";
	
}

function PopupAddContact_CloseError()
{
	document.getElementById("PopupAddContact_ShowError1").style.display="none";
	document.getElementById("PopupAddContact_ShowError2").style.display="none";
	//document.getElementById("PopupAddContact_ShowErrorBox").className = "txt_mode_error";
	
}

//-------------------------------------------------------------------------//	

//--------------------------- Popup Add Company -------------//
function checkPopupAddCompany()
{
	if(trim(document.getElementById("PopupAddCompany_company_name").value)=="" )
	{
		PopupAddCompany_ShowError();
		document.getElementById("PopupAddCompany_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
		
	}
	else
	{
			
			
				PopupAddCompany_ShowSuccess();
				document.getElementById("PopupAddCompany_ErrorText").innerHTML = "Please wait...";
				document.getElementById("PopupAddCompany_btnSave").disabled =true;
				addNewCompany();
			
	}
	
	
	if(trim(document.getElementById("PopupAddCompany_company_name").value)=="")
	{
		document.getElementById("PopupAddCompany_company_name").className="txtbox_error250";
	}
	else
	{
		document.getElementById("PopupAddCompany_company_name").className="txtbox250";
	}
	
	
	
	
}

function addNewCompany()
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_add_company.php?companyname="+trim(encodeURIComponent(document.getElementById("PopupAddCompany_company_name").value))+"&customerid="+trim(encodeURIComponent(document.getElementById("PopupAddCompany_customer_id").value))+"&accountid="+trim(document.getElementById("PopupAddCompany_agent_id").value)+"&uid="+document.getElementById("user_id").value; 
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						if(CList!="No")
						 {
							//getCompanyContact(document.getElementById("company_id").value,CList);
							value = trim(document.getElementById("PopupAddCompany_company_name").value);
							if(trim(document.getElementById("PopupAddCompany_customer_id").value)!="")
							{
								value = value + " (" + trim(document.getElementById("PopupAddCompany_customer_id").value) +")";
							}
							if(document.getElementById("PopupAddCompany_add_from").value=="")
							{
								selectName(value,CList);
							}
							else if(document.getElementById("PopupAddCompany_add_from").value=="quote")
							{
								selectNameForQuote(value,CList,0);
							}
							
							hidePopupAddCompany();
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}

function showPopupAddCompany()
{
	if(document.getElementById("PopupAddCompany"))
	{
		document.getElementById("PopupAddCompany_btnSave").disabled =false;
		document.getElementById("company_name").value="";
		document.getElementById("PopupAddCompany").style.display="";
		document.getElementById("PopupAddCompany").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupAddCompany").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupAddCompany").style.zIndex=130;
	}
}

function hidePopupAddCompany()
{
	if(document.getElementById("PopupAddCompany"))
	{
		document.getElementById("PopupAddCompany_company_name").value ="";
		document.getElementById("PopupAddCompany_agent_id").selectedIndex = 0;
		
		document.getElementById("PopupAddCompany_company_name").className="txtbox250";
		
		document.getElementById("PopupAddCompany_ShowError1").style.display="none";
		document.getElementById("PopupAddCompany_ShowError2").style.display="none";
		document.getElementById("PopupAddCompany").style.display="none";
	}
	
}

function PopupAddCompany_ShowError()
{
	document.getElementById("PopupAddCompany_ShowError1").style.display="";
	document.getElementById("PopupAddCompany_ShowError2").style.display="";
	document.getElementById("PopupAddCompany_ShowErrorBox").className ="mode_error";
	
	
}

function PopupAddCompany_ShowSuccess()
{
	document.getElementById("PopupAddCompany_ShowError1").style.display="";
	document.getElementById("PopupAddCompany_ShowError2").style.display="";
	
	document.getElementById("PopupAddCompany_ShowErrorBox").className ="mode_success";
	
	
}

function PopupAddCompany_CloseError()
{
	document.getElementById("PopupAddCompany_ShowError1").style.display="none";
	document.getElementById("PopupAddCompany_ShowError2").style.display="none";
	;
	
}	



// ----------------------------------------------------------//

//--------------------- Add New company Delivery ------------//

function checkPopupAddCompanyDelivery()
{
	if(trim(document.getElementById("PopupAddCompanyDelivery_location").value)=="" )
	{
		PopupAddCompanyDelivery_ShowError();
		document.getElementById("PopupAddCompanyDelivery_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
		
	}
	else
	{
			
			
				PopupAddCompanyDelivery_ShowSuccess();
				document.getElementById("PopupAddCompanyDelivery_ErrorText").innerHTML = "Please wait...";
				document.getElementById("PopupAddCompanyDelivery_btnSave").disabled =true;
				addCompanyDelivery();
			
	}
	
	
	if(trim(document.getElementById("PopupAddCompanyDelivery_location").value)=="")
	{
		document.getElementById("PopupAddCompanyDelivery_location").className="txtbox_error250";
	}
	else
	{
		document.getElementById("PopupAddCompanyDelivery_location").className="txtbox250";
	}
	
	
	
	
}

function addCompanyDelivery()
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			//var url = "arena_lib/ajax/ajax_add_company_delivery.php?location="+trim(document.getElementById("PopupAddCompanyDelivery_location").value)+"&cid="+document.getElementById("company_id").value+"&address="+trim(encodeURIComponent(document.getElementById("PopupAddCompanyDelivery_address").value))+"&city="+trim(document.getElementById("PopupAddCompanyDelivery_city").value)+"&region="+trim(document.getElementById("PopupAddCompanyDelivery_region").value)+"&postcode="+trim(document.getElementById("PopupAddCompanyDelivery_postcode").value)+"&country="+trim(document.getElementById("PopupAddCompanyDelivery_country").value)+"&uid="+document.getElementById("user_id").value; 
			var url = "arena_lib/ajax/ajax_add_company_delivery.php?location="+trim(document.getElementById("PopupAddCompanyDelivery_location").value)+"&cid="+document.getElementById("company_id").value+"&address="+trim(encodeURIComponent(document.getElementById("PopupAddCompanyDelivery_address").value))+"&country="+trim(document.getElementById("PopupAddCompanyDelivery_country").value)+"&uid="+document.getElementById("user_id").value; 
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						if(CList!="No")
						 {
							getCompanyDelivery(document.getElementById("company_id").value,CList);
							hidePopupAddCompanyDelivery();
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}




function showPopupAddCompanyDelivery()
{
	if(document.getElementById("PopupAddCompanyDelivery"))
	{
		document.getElementById("PopupAddCompanyDelivery_btnSave").disabled =false;
		document.getElementById("PopupAddCompanyDelivery").style.display="";
		document.getElementById("PopupAddCompanyDelivery").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupAddCompanyDelivery").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupAddCompanyDelivery").style.zIndex=140;
	}
}

function hidePopupAddCompanyDelivery()
{
	if(document.getElementById("PopupAddCompanyDelivery"))
	{
		document.getElementById("PopupAddCompanyDelivery_location").value ="";
		document.getElementById("PopupAddCompanyDelivery_country").selectedIndex = 0;
		
		document.getElementById("PopupAddCompanyDelivery_location").className="txtbox250";
		
		document.getElementById("PopupAddCompanyDelivery_ShowError1").style.display="none";
		document.getElementById("PopupAddCompanyDelivery_ShowError2").style.display="none";
		document.getElementById("PopupAddCompanyDelivery").style.display="none";
	}
	
}

function PopupAddCompanyDelivery_ShowError()
{
	document.getElementById("PopupAddCompanyDelivery_ShowError1").style.display="";
	document.getElementById("PopupAddCompanyDelivery_ShowError2").style.display="";
	document.getElementById("PopupAddCompanyDelivery_ShowErrorBox").className ="mode_error";
	
	
}

function PopupAddCompanyDelivery_ShowSuccess()
{
	document.getElementById("PopupAddCompanyDelivery_ShowError1").style.display="";
	document.getElementById("PopupAddCompanyDelivery_ShowError2").style.display="";
	document.getElementById("PopupAddCompanyDelivery_ShowErrorBox").className ="mode_success";
	
	
}

function PopupAddCompanyDelivery_CloseError()
{
	document.getElementById("PopupAddCompanyDelivery_ShowError1").style.display="none";
	document.getElementById("PopupAddCompanyDelivery_ShowError2").style.display="none";
	
	
}	



/*
function showPopup(event)
{
	if(document.getElementById("PopUpRecipient"))
	{
		
		document.getElementById("PopUpRecipient").style.display="";
		document.getElementById("PopUpRecipient").style.top=(event.clientY )+"px";
		document.getElementById("PopUpRecipient").style.left=(event.clientX )+"px";
		document.getElementById("PopUpRecipient").style.zIndex=130;
		
	}
}

function hidePopup()
{
	if(document.getElementById("PopUpRecipient"))
	{
		
		document.getElementById("PopUpRecipient").style.display="none";
	}
	
}
*/



//<img  id='preload' src='images/loading1.gif' style=' z-index:1000;POSITION: absolute ;left:120;top:150'>
function addLoading()
{
	if(document.getElementById("preload")==null)
	{
		var img =document.createElement("img");
			img.setAttribute("id", "preload");
			img.src = "images/loading.gif";
			img.style.top="20%";
			img.style.left="50%";
			img.style.zIndex=1000;
			img.style.position = "absolute"; 
			document.body.appendChild(img);
			
	}
}



function removeLoading()
{
	if(document.getElementById("preload")!=null)
	{
		//document.getElementById("preload")=null;
		document.body.removeChild(document.getElementById("preload"));
	}
}

//-------------------- header ----------------------//
function checkKeyWordHeader()
{
	if((trim(document.getElementById("search_keyword").value)!=""))
	{
		document.formHeader.submit();	
	}
	
	
	
}

function checkSampleKeyWordHeader()
{
	if((trim(document.getElementById("search_keyword").value)!=""))
	{
		document.formHeader.submit();	
	}
	
	
	
}

function checkCompanyKeyWordHeader()
{
	if((trim(document.getElementById("search_keyword").value)!=""))
	{
		document.formHeader.submit();	
	}
	
	
	
}

function checkProductKeyWordHeader()
{
	if((trim(document.getElementById("search_keyword").value)!=""))
	{
		
		
			var k =trim(document.getElementById("search_keyword").value);
			if(k.length>=2)
			{
				document.formProductHeader.submit();
			}
	}
	
	
	
}

function checkUserKeyWordHeader()
{
	if((trim(document.getElementById("search_keyword").value)!=""))
	{
		document.formUserHeader.submit();
	}
	
	
	
}

function checkArtworkKeyWordHeader()
{
	if((trim(document.getElementById("search_keyword").value)!=""))
	{
		document.formArtworkHeader.submit();
	}
	
		
}

function checkEnterForSaleHead(e)
{
    e = e || window.event;
    var code = e.keyCode || e.which;
    if(code == 13)
      {
	  	checkSaleKeyWordHeader();
		return false;
	  }
}

function checkSaleKeyWordHeader()
{
	if((trim(document.getElementById("search_keyword").value)!=""))
	{
		
		
			var search_type =trim(document.getElementById("search_type").value);
			if(search_type=="quote")
			{
				document.formSaletHeader.action = "sale_quote_main.php";;
				document.formSaletHeader.submit();
			}
			else if(search_type=="pack")
			{
				document.formSaletHeader.action = "sale_pack_main.php";;
				document.formSaletHeader.submit();
			}
			else if(search_type=="calc")
			{
				document.formSaletHeader.action = "sale_calc_main.php";;
				document.formSaletHeader.submit();
			}
			else if(search_type=="info")
			{
				document.formSaletHeader.action = "sale_sheet_main.php";;
				document.formSaletHeader.submit();
			}
			
	}
	
	
	
}

function checkCustomerResourceKeyWordHeader()
{
	if((trim(document.getElementById("search_keyword").value)!=""))
	{
		
		
			var search_type =trim(document.getElementById("search_type").value);
			if(search_type=="asset")
			{
				document.formCustomerResourceHeader.action = "customer_asset_main.php";;
				document.formCustomerResourceHeader.submit();
			}
			else if(search_type=="sheet")
			{
				document.formCustomerResourceHeader.action = "customer_sheet_main.php";;
				document.formCustomerResourceHeader.submit();
			}
			else if(search_type=="colour")
			{
				document.formCustomerResourceHeader.action = "customer_colour_chart_main.php";;
				document.formCustomerResourceHeader.submit();
			}
			
			
	}
	
	
	
}

function checkKeyWordAllCustomerHeader()
{
	if((trim(document.getElementById("search_keyword").value)!=""))
	{
		document.formHeader.submit();	
	}
	
	
	
}


//-----------------------------------------------//

// --------------------- Sample Ship Method -------------------------//
function getCompanyShipMethod(cid,method_id,objMethod)
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_get_company_ship_method.php?cid="+trim(cid);  
	
			createXMLHttpRequest3();
				xmlHttp3.onreadystatechange = function () {
						if(xmlHttp3.readyState == 4) {
						if(xmlHttp3.status == 200) {
												
						CList = xmlHttp3.responseText;  
								//alert(CList)				 
						if(CList!="" && CList!="No" )
						{
							CreateCompanyShipMethod(CList,cid,method_id,objMethod);  
							
						 }
						 else if(CList =="No" )
						 {
						 	CreateCompanyShipMethod("",cid,method_id,objMethod);  
						 }
						 else
						 {
						 	removeCompanyShipMethod();
							
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp3.open("POST", url, true);
									 xmlHttp3.send(pBody); 
}

function CreateCompanyShipMethod(CList,cid,method_id2,objMethod)
{
	ClearChildNodes(objMethod);
	var allResult=CList.split("!#!#!");
	for (var i = 0; i < allResult.length-1; i++)
	{
		var result=allResult[i].split("!*!");    
		var method_id = result[0];
		var method_name = result[1];
		
		option=document.createElement("option");
		
		if(method_name.length>40)
		{
			method_name = method_name.substr(0, 40)+"...";	
		}
		
		
		option.appendChild(document.createTextNode(method_name)); 
		option.value=method_id;
		
		if(method_id2==method_id)
		{
			option.selected=true;
		}
		
		document.getElementById(objMethod).appendChild(option);
	} 
	
	 option=document.createElement("option");
	 option.appendChild(document.createTextNode("Speedy from Shenzhen (for our account) *")); 
	 option.value="-1";
	  if(method_id2=="-1")
	 {
	 	option.selected=true;
	 }
	 document.getElementById(objMethod).appendChild(option);
	 
	 option=document.createElement("option");
	 option.appendChild(document.createTextNode("TNT from Shenzhen (for our account) *")); 
	 option.value="-2";
	  if(method_id2=="-2")
	 {
	 	option.selected=true;
	 }
	 document.getElementById(objMethod).appendChild(option);
	 
	 option=document.createElement("option");
	 option.appendChild(document.createTextNode("Will be collected from factory *")); 
	 option.value="-3";
	  if(method_id2=="-3")
	 {
	 	option.selected=true;
	 }
	 document.getElementById(objMethod).appendChild(option);
	 
	 option=document.createElement("option");
	 option.appendChild(document.createTextNode("OCS from London *")); 
	 option.value="-4";
	  if(method_id2=="-4")
	 {
	 	option.selected=true;
	 }
	 document.getElementById(objMethod).appendChild(option);
	 
	 option=document.createElement("option");
	 option.appendChild(document.createTextNode("To be announced *")); 
	 option.value="0";
	  if(method_id2=="-0")
	 {
	 	option.selected=true;
	 }
	 document.getElementById(objMethod).appendChild(option);
	 
	 if(objMethod=="method_id")
	 {
	 	enableShipMethodArea(cid);
	 }
	
	
	
	
}

function enableShipMethodArea(cid)
{
	document.getElementById("method_id").disabled = false;
	document.getElementById("ShipMethodText").className = "txt_11_999_b";
	document.getElementById("addNewShipMethod").className = "txt_add_new_contact";
	document.getElementById("addNewShipMethod").onclick = null;
	document.getElementById("addNewShipMethod").onclick = function () {showPopupAddCompanyShipMethod();};
	
}

function removeCompanyShipMethod()
{
	ClearChildNodes("method_id");
	document.getElementById("method_id").disabled = true;
	document.getElementById("ShipMethodText").className = "txt_11_ccc";
	document.getElementById("addNewShipMethod").className = "";
	document.getElementById("addNewShipMethod").onclick = null;
	
	
}


function checkPopupAddCompanyShipMethod()
{
	if((document.getElementById("PopupAddCompanyShipMethod_courier").value=="0" ||trim(document.getElementById("PopupAddCompanyShipMethod_from").value)=="" ||trim(document.getElementById("PopupAddCompanyShipMethod_account").value)=="") && document.getElementById("PopupAddCompanyShipMethod_type").value=="1" )
	{
		PopupAddCompanyShipMethod_ShowError();
		document.getElementById("PopupAddCompanyShipMethod_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
		
	}
	else if(trim(document.getElementById("PopupAddCompanyShipMethod_detail").value)=="" && document.getElementById("PopupAddCompanyShipMethod_type").value=="2" )
	{
		PopupAddCompanyShipMethod_ShowError();
		document.getElementById("PopupAddCompanyShipMethod_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
	}
	else
	{
			
			
				
				PopupAddCompanyShipMethod_ShowSuccess();
				document.getElementById("PopupAddCompanyShipMethod_ErrorText").innerHTML = "Please wait...";
				document.getElementById("PopupAddCompanyShipMethod_btnSave").disabled =true;
				addCompanyShipMethod();
			
	}
	
	
	
	if(document.getElementById("PopupAddCompanyShipMethod_type").value=="1")
	{
		if(trim(document.getElementById("PopupAddCompanyShipMethod_courier").value)=="0")
		{
			document.getElementById("PopupAddCompanyShipMethod_tblCourier").className="table_error";
		}
		else
		{
			document.getElementById("PopupAddCompanyShipMethod_tblCourier").className="";
		}
		
		if(trim(document.getElementById("PopupAddCompanyShipMethod_from").value)=="")
		{
			document.getElementById("PopupAddCompanyShipMethod_from").className="txtbox_error250";
		}
		else
		{
			document.getElementById("PopupAddCompanyShipMethod_from").className="txtbox250";
		}
		
		if(trim(document.getElementById("PopupAddCompanyShipMethod_account").value)=="")
		{
			document.getElementById("PopupAddCompanyShipMethod_account").className="txtbox_error250";
		}
		else
		{
			document.getElementById("PopupAddCompanyShipMethod_account").className="txtbox250";
		}
	}
	else
	{
		if(trim(document.getElementById("PopupAddCompanyShipMethod_detail").value)=="")
		{
			document.getElementById("PopupAddCompanyShipMethod_detail").className="txtbox_error250";
		}
		else
		{
			document.getElementById("PopupAddCompanyShipMethod_detail").className="txtbox250";
		}
	}
	
	
	
	
}

function addCompanyShipMethod()
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_add_company_ship_method.php?company_id="+document.getElementById("company_id").value+"&ship_type="+document.getElementById("PopupAddCompanyShipMethod_type").value+"&ship_courier="+document.getElementById("PopupAddCompanyShipMethod_courier").value+"&ship_from="+trim(document.getElementById("PopupAddCompanyShipMethod_from").value)+"&ship_account="+trim(document.getElementById("PopupAddCompanyShipMethod_account").value)+"&ship_detail="+trim(encodeURIComponent(document.getElementById("PopupAddCompanyShipMethod_detail").value))+"&create_by="+document.getElementById("user_id").value; 
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						if(CList!="No")
						 {
							getCompanyShipMethod(document.getElementById("company_id").value,CList,"method_id");
							hidePopupAddCompanyShipMethod();
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}


function ShipMethod_showAddDetail()
{
	document.getElementById("PopupAddCompanyShipMethod_row1").style.display="none";
	document.getElementById("PopupAddCompanyShipMethod_row2").style.display="none";
	document.getElementById("PopupAddCompanyShipMethod_row3").style.display="none";
	document.getElementById("PopupAddCompanyShipMethod_row4").style.display="";
	document.getElementById("PopupAddCompanyShipMethod_row5").style.display="none";
	
	document.getElementById("PopupAddCompanyShipMethod_rowHead1").style.display="";
	document.getElementById("PopupAddCompanyShipMethod_rowHead2").style.display="none";
	
	document.getElementById("PopupAddCompanyShipMethod_btnSave").onclick = null;
    document.getElementById("PopupAddCompanyShipMethod_btnSave").onclick = function(){checkPopupAddCompanyShipMethod();}
	document.getElementById("PopupAddCompanyShipMethod_btnSave").value ="Save";
	
	document.getElementById("PopupAddCompanyShipMethod_showAddDetail").innerHTML ="Add New Courier Account";
	document.getElementById("PopupAddCompanyShipMethod_showAddDetail").onclick = null;
	document.getElementById("PopupAddCompanyShipMethod_showAddDetail").onclick = function(){ShipMethod_showAddCourier();};
	document.getElementById("PopupAddCompanyShipMethod_MiddleWord").innerHTML ="If these goods are sent via courier";
	document.getElementById("PopupAddCompanyShipMethod_headText").innerHTML ="Is this a customer-specific special shipping method?";
	document.getElementById("PopupAddCompanyShipMethod_title").innerHTML ="Add New Special Shipping Method";
	document.getElementById("PopupAddCompanyShipMethod_type").value = "2";
	
	PopupAddCompanyShipMethod_CloseError();
	document.getElementById("PopupAddCompanyShipMethod_tblCourier").className="";
	document.getElementById("PopupAddCompanyShipMethod_from").className="txtbox250";
	document.getElementById("PopupAddCompanyShipMethod_account").className="txtbox250";
	document.getElementById("PopupAddCompanyShipMethod_detail").className="txtbox250";
	
}

function ShipMethod_showAddCourier()
{
	document.getElementById("PopupAddCompanyShipMethod_row1").style.display="";
	document.getElementById("PopupAddCompanyShipMethod_row2").style.display="";
	document.getElementById("PopupAddCompanyShipMethod_row3").style.display="";
	document.getElementById("PopupAddCompanyShipMethod_row4").style.display="none";
	document.getElementById("PopupAddCompanyShipMethod_row5").style.display="none";
	
	document.getElementById("PopupAddCompanyShipMethod_rowHead1").style.display="";
	document.getElementById("PopupAddCompanyShipMethod_rowHead2").style.display="none";
	
	document.getElementById("PopupAddCompanyShipMethod_btnSave").onclick = null;
    document.getElementById("PopupAddCompanyShipMethod_btnSave").onclick = function(){checkPopupAddCompanyShipMethod();}
	document.getElementById("PopupAddCompanyShipMethod_btnSave").value ="Save";
	
	
	document.getElementById("PopupAddCompanyShipMethod_showAddDetail").innerHTML ="Add New Special Shipping Method";
	document.getElementById("PopupAddCompanyShipMethod_showAddDetail").onclick = null;
	document.getElementById("PopupAddCompanyShipMethod_showAddDetail").onclick = function(){ShipMethod_showAddDetail();};
	document.getElementById("PopupAddCompanyShipMethod_MiddleWord").innerHTML = "If these goods won&acute;t be sent by courier";
	document.getElementById("PopupAddCompanyShipMethod_headText").innerHTML = "Is this a customer-specific courier account?";
	document.getElementById("PopupAddCompanyShipMethod_title").innerHTML = "Add New Courier Account";
	document.getElementById("PopupAddCompanyShipMethod_type").value = "1";
	
	PopupAddCompanyShipMethod_CloseError();
	document.getElementById("PopupAddCompanyShipMethod_tblCourier").className="";
	document.getElementById("PopupAddCompanyShipMethod_from").className="txtbox250";
	document.getElementById("PopupAddCompanyShipMethod_account").className="txtbox250";
	document.getElementById("PopupAddCompanyShipMethod_detail").className="txtbox250";
}


function showPopupAddCompanyShipMethod()
{
	if(document.getElementById("PopupAddCompanyShipMethod"))
	{
		ShipMethod_showAddCourier();
		document.getElementById("PopupAddCompanyShipMethod_btnSave").disabled =false;
		document.getElementById("PopupAddCompanyShipMethod").style.display="";
		document.getElementById("PopupAddCompanyShipMethod").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupAddCompanyShipMethod").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupAddCompanyShipMethod").style.zIndex=140;
		
		if(document.getElementById("sample_id") && document.getElementById("ship_method_id"))
		{
			document.getElementById("PopupAddCompanyShipMethod_showChangeMethod").className ="txt_13_f60_b";
			document.getElementById("PopupAddCompanyShipMethod_showChangeMethod").style.cursor = "pointer";
			document.getElementById("PopupAddCompanyShipMethod_showChangeMethod").onclick = null;
			document.getElementById("PopupAddCompanyShipMethod_showChangeMethod").onclick = function(){showPopupAddCompanyChangeShipMethod()};
			
		}
		
	}
}

function showPopupAddCompanyChangeShipMethod()
{
	if(document.getElementById("PopupAddCompanyShipMethod"))
	{
		
		document.getElementById("PopupAddCompanyShipMethod_btnSave").disabled =false;
		document.getElementById("PopupAddCompanyShipMethod_row1").style.display="none";
		document.getElementById("PopupAddCompanyShipMethod_row2").style.display="none";
		document.getElementById("PopupAddCompanyShipMethod_row3").style.display="none";
		document.getElementById("PopupAddCompanyShipMethod_row4").style.display="none";
		document.getElementById("PopupAddCompanyShipMethod_row5").style.display="";
		
		document.getElementById("PopupAddCompanyShipMethod_rowHead1").style.display="none";
		document.getElementById("PopupAddCompanyShipMethod_rowHead2").style.display="";
		
		document.getElementById("PopupAddCompanyShipMethod_headText").innerHTML ="Select a different shipping method";
		document.getElementById("PopupAddCompanyShipMethod_title").innerHTML ="Change Shipping Method";
		
		document.getElementById("PopupAddCompanyShipMethod_btnSave").onclick = null;
		document.getElementById("PopupAddCompanyShipMethod_btnSave").onclick = function(){changeSampleChangeShipMethod();}
		document.getElementById("PopupAddCompanyShipMethod_btnSave").value = "  Ok  ";
		
		document.getElementById("PopupAddCompanyShipMethod").style.display="";
		document.getElementById("PopupAddCompanyShipMethod").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupAddCompanyShipMethod").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupAddCompanyShipMethod").style.zIndex=140;
		
		if(document.getElementById("company_id"))
		{
			getCompanyShipMethod(document.getElementById("company_id").value,"","PopupAddCompanyShipMethod_ship_id");
		}
		
		if(document.getElementById("sample_id"))
		{
			if(document.getElementById("sample_id").value!="")
			{
				
			}
		}
		
	}
}

function changeSampleChangeShipMethod()
{
	alert("ch");
}

function hidePopupAddCompanyShipMethod()
{
	if(document.getElementById("PopupAddCompanyShipMethod"))
	{
		
		document.getElementById("PopupAddCompanyShipMethod_courier").selectedIndex = 0;
		document.getElementById("PopupAddCompanyShipMethod_from").value ="";
		document.getElementById("PopupAddCompanyShipMethod_account").value ="";
		document.getElementById("PopupAddCompanyShipMethod_detail").value ="";
		
		document.getElementById("PopupAddCompanyShipMethod_from").className = "txtbox250";
		document.getElementById("PopupAddCompanyShipMethod_account").className = "txtbox250";
		document.getElementById("PopupAddCompanyShipMethod_detail").className = "txtbox250";
		document.getElementById("PopupAddCompanyShipMethod_tblCourier").className = "";
		
		document.getElementById("PopupAddCompanyShipMethod_ShowError1").style.display="none";
		document.getElementById("PopupAddCompanyShipMethod_ShowError2").style.display="none";
		document.getElementById("PopupAddCompanyShipMethod").style.display="none";
		
		//showPopupAddCompanyChangeShipMethod();
	}
	
}

function PopupAddCompanyShipMethod_ShowError()
{
	document.getElementById("PopupAddCompanyShipMethod_ShowError1").style.display="";
	document.getElementById("PopupAddCompanyShipMethod_ShowError2").style.display="";
	document.getElementById("PopupAddCompanyShipMethod_ShowErrorBox").className ="mode_error";
	
}

function PopupAddCompanyShipMethod_ShowSuccess()
{
	document.getElementById("PopupAddCompanyShipMethod_ShowError1").style.display="";
	document.getElementById("PopupAddCompanyShipMethod_ShowError2").style.display="";
	document.getElementById("PopupAddCompanyShipMethod_ShowErrorBox").className ="mode_success";
	
}

function PopupAddCompanyShipMethod_CloseError()
{
	document.getElementById("PopupAddCompanyShipMethod_ShowError1").style.display="none";
	document.getElementById("PopupAddCompanyShipMethod_ShowError2").style.display="none";
	
	
}	
//-------------------------------------------------------//

//--------------------- Sample Place Order ---------------------//

function samplePlaceOrder()
{
				PopupSamplePlaceOrder_ShowSuccess();
				document.getElementById("PopupSamplePlaceOrder_ErrorText").innerHTML = "Please wait...";
				document.getElementById("PopupSamplePlaceOrder_btnSave").disabled =true;
				document.getElementById("PopupSamplePlaceOrder_btnCancel").disabled =true;
				
			
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			
			
			
			var url = "basket/sample_email_pdf.php?sample_id="+document.getElementById("sample_id").value+"&update_by="+trim(document.getElementById("user_id").value)+"&place_text="+trim(encodeURIComponent(document.getElementById("PopupSamplePlaceOrder_text").value))+"&company_name="+document.getElementById("company_name").value+"&sample_type="+document.getElementById("sample_type").value+"&agent_id="+document.getElementById("agent_id").value+"&agent_email="+document.getElementById("agent_email").value+"&action=placeOrder"; 
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						if(CList!="No")
						 {
							
							hidePopupSamplePlaceOrder();
							pageRefresh();
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}



function showPopupSamplePlaceOrder()
{
	if(document.getElementById("PopupSamplePlaceOrder"))
	{
		
		document.getElementById("PopupSamplePlaceOrder").style.display="";
		document.getElementById("PopupSamplePlaceOrder").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupSamplePlaceOrder").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupSamplePlaceOrder").style.zIndex=140;
		
		
		
	}
}



function hidePopupSamplePlaceOrder()
{
	if(document.getElementById("PopupSamplePlaceOrder"))
	{
		
		document.getElementById("PopupSamplePlaceOrder_text").value ="";
		document.getElementById("PopupSamplePlaceOrder_text").className="txtbox250";
		
		document.getElementById("PopupSamplePlaceOrder_ShowError1").style.display="none";
		document.getElementById("PopupSamplePlaceOrder_ShowError2").style.display="none";
		document.getElementById("PopupSamplePlaceOrder").style.display="none";
		
		//showPopupAddCompanyChangeShipMethod();
	}
	
}

function PopupSamplePlaceOrder_ShowError()
{
	document.getElementById("PopupSamplePlaceOrder_ShowError1").style.display="";
	document.getElementById("PopupSamplePlaceOrder_ShowError2").style.display="";
	document.getElementById("PopupSamplePlaceOrder_ShowErrorBox").className ="mode_error";
	
}

function PopupSamplePlaceOrder_ShowSuccess()
{
	document.getElementById("PopupSamplePlaceOrder_ShowError1").style.display="";
	document.getElementById("PopupSamplePlaceOrder_ShowError2").style.display="";
	document.getElementById("PopupSamplePlaceOrder_ShowErrorBox").className ="mode_success";
	
}

function PopupSamplePlaceOrder_CloseError()
{
	document.getElementById("PopupSamplePlaceOrder_ShowError1").style.display="none";
	document.getElementById("PopupSamplePlaceOrder_ShowError2").style.display="none";
	
	
}	


//---------------------------------------------------------------//

//-------------------- Sample Approve Order ---------------------//
function checkPopupSampleApproveOrder()
{
	if(trim(document.getElementById("PopupSampleApproveOrder_control_no").value)=="")
	{
		PopupSampleApproveOrder_ShowError();
		document.getElementById("PopupSampleApproveOrder_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
		
	}
	else
	{
			
			
				PopupSampleApproveOrder_ShowSuccess();
				document.getElementById("PopupSampleApproveOrder_ErrorText").innerHTML = "Please wait...";
				document.getElementById("PopupSampleApproveOrder_btnSave").disabled =true;
				sampleApproveOrder();
			
	}
	
	
	if(trim(document.getElementById("PopupSampleApproveOrder_control_no").value)=="")
	{
		document.getElementById("PopupSampleApproveOrder_control_no").className="txtbox_error150";
	}
	else
	{
		document.getElementById("PopupSampleApproveOrder_control_no").className="txtbox150";
	}
	
	
	
	
}

function sampleApproveOrder()
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_sample_approve_order.php?sample_id="+document.getElementById("sample_id").value+"&update_by="+document.getElementById("user_id").value+"&control_no="+trim(document.getElementById("PopupSampleApproveOrder_control_no").value)+"&company_name="+document.getElementById("company_name").value+"&order_date="+document.getElementById("order_date").value+"&invoice_no="+document.getElementById("invoice_no").value+"&agent_id="+document.getElementById("agent_id").value+"&agent_email="+document.getElementById("agent_email").value+"&user_name="+document.getElementById("user_name").value+"&user_email="+document.getElementById("user_email").value; 
			
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						if(CList!="No")
						 {
							pageRefresh();
							hidePopupSampleApproveOrder();
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}



function showPopupSampleApproveOrder()
{
	if(document.getElementById("PopupSampleApproveOrder"))
	{
		
		document.getElementById("PopupSampleApproveOrder").style.display="";
		document.getElementById("PopupSampleApproveOrder").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupSampleApproveOrder").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupSampleApproveOrder").style.zIndex=140;
		
		
		
	}
}



function hidePopupSampleApproveOrder()
{
	if(document.getElementById("PopupSampleApproveOrder"))
	{
		
		document.getElementById("PopupSampleApproveOrder_control_no").value ="";
		document.getElementById("PopupSampleApproveOrder_control_no").className="txtbox150";
		
		document.getElementById("PopupSampleApproveOrder_ShowError1").style.display="none";
		document.getElementById("PopupSampleApproveOrder_ShowError2").style.display="none";
		document.getElementById("PopupSampleApproveOrder").style.display="none";
		
		//showPopupAddCompanyChangeShipMethod();
	}
	
}

function PopupSampleApproveOrder_ShowError()
{
	document.getElementById("PopupSampleApproveOrder_ShowError1").style.display="";
	document.getElementById("PopupSampleApproveOrder_ShowError2").style.display="";
	document.getElementById("PopupSampleApproveOrder_ShowErrorBox").className ="mode_error";
	
}

function PopupSampleApproveOrder_ShowSuccess()
{
	document.getElementById("PopupSampleApproveOrder_ShowError1").style.display="";
	document.getElementById("PopupSampleApproveOrder_ShowError2").style.display="";
	document.getElementById("PopupSampleApproveOrder_ShowErrorBox").className ="mode_success";
	
}

function PopupSampleApproveOrder_CloseError()
{
	document.getElementById("PopupSampleApproveOrder_ShowError1").style.display="none";
	document.getElementById("PopupSampleApproveOrder_ShowError2").style.display="none";
	
	
}	

//----------------------------------------------------------------//

//------------------------- Sample Ship Order ----------------------------//

function checkPopupSampleShipOrder()
{
	if(trim(document.getElementById("PopupSampleShipOrder_ship_date").value)==""  )
	{
		PopupSampleShipOrder_ShowError();
		document.getElementById("PopupSampleShipOrder_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
		
	}
	else
	{
			
				PopupSampleShipOrder_ShowSuccess();
				document.getElementById("PopupSampleShipOrder_ErrorText").innerHTML = "Please wait...";
				document.getElementById("PopupSampleShipOrder_btnSave").disabled =true;
				shipSampleOrder();
			
	}
	
	
	if(trim(document.getElementById("PopupSampleShipOrder_ship_date").value)=="")
	{
		document.getElementById("PopupSampleShipOrder_ship_date").className="txtbox_error145";
	}
	else
	{
		document.getElementById("PopupSampleShipOrder_ship_date").className="txtbox145";
	}
	
	
	
	
	
	
}

function shipSampleOrder()
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			 
			
			
			var url = "basket/sample_email_pdf.php?sample_id="+document.getElementById("sample_id").value+"&ship_date="+trim(document.getElementById("PopupSampleShipOrder_ship_date").value)+"&invoice_track="+trim(document.getElementById("PopupSampleShipOrder_invoice_track").value)+"&update_by="+document.getElementById("user_id").value+"&cartons="+trim(encodeURIComponent(document.getElementById("PopupSampleShipOrder_cartons").value))+"&weight="+trim(encodeURIComponent(document.getElementById("PopupSampleShipOrder_weight").value))+"&volume="+trim(encodeURIComponent(document.getElementById("PopupSampleShipOrder_volume").value))+"&order_date="+document.getElementById("order_date").value+"&invoice_no="+document.getElementById("invoice_no").value+"&contact_id="+document.getElementById("contact_id").value+"&delivery_id="+document.getElementById("delivery_id").value+"&method_name="+trim(encodeURIComponent(document.getElementById("method_name").value))+"&company_id="+document.getElementById("company_id").value+"&method_id="+document.getElementById("method_id").value+"&agent_id="+document.getElementById("agent_id").value+"&agent_email="+document.getElementById("agent_email").value+"&user_name="+document.getElementById("user_name").value+"&user_email="+document.getElementById("user_email").value+"&courier="+trim(encodeURIComponent(document.getElementById("PopupSampleShipOrder_courier").value))+"&real_invoice_no="+trim(encodeURIComponent(document.getElementById("PopupSampleShipOrder_real_invoice_no").value))+"&total_amount="+trim(encodeURIComponent(document.getElementById("PopupSampleShipOrder_total_amount").value))+"&freight_amount="+trim(encodeURIComponent(document.getElementById("PopupSampleShipOrder_freight_amount").value))+"&action=shipOrder";
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//document.getElementById("PopupSampleShipOrder_ErrorText").innerHTML = CList;//alert(CList)				 
						 if(CList!="No")
						 {
							hidePopupSampleShipOrder();
							pageRefresh();
							
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}

function showPopupSampleShipOrder()
{
	if(document.getElementById("PopupSampleShipOrder"))
	{
		
		
		document.getElementById("PopupSampleShipOrder").style.display="";
		document.getElementById("PopupSampleShipOrder").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupSampleShipOrder").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupSampleShipOrder").style.zIndex=1;
	}
}

function hidePopupSampleShipOrder()
{
	if(document.getElementById("PopupSampleShipOrder"))
	{
		document.getElementById("PopupSampleShipOrder_ship_date").value = document.getElementById("PopupSampleShipOrder_Today").value;
		document.getElementById("PopupSampleShipOrder_invoice_track").value = "";
		
		document.getElementById("PopupSampleShipOrder_ship_date").className="txtbox145";
		
		document.getElementById("PopupSampleShipOrder_ShowError1").style.display="none";
		document.getElementById("PopupSampleShipOrder_ShowError2").style.display="none";
		document.getElementById("PopupSampleShipOrder").style.display="none";
	}
	
}


function PopupSampleShipOrder_ShowError()
{
	document.getElementById("PopupSampleShipOrder_ShowError1").style.display="";
	document.getElementById("PopupSampleShipOrder_ShowError2").style.display="";
	document.getElementById("PopupSampleShipOrder_ShowErrorBox").className = "mode_error";
	
}
function PopupSampleShipOrder_ShowSuccess()
{
	document.getElementById("PopupSampleShipOrder_ShowError1").style.display="";
	document.getElementById("PopupSampleShipOrder_ShowError2").style.display="";
	document.getElementById("PopupSampleShipOrder_ShowErrorBox").className ="mode_success";
	
}


function PopupSampleShipOrder_CloseError()
{
	document.getElementById("PopupSampleShipOrder_ShowError1").style.display="none";
	document.getElementById("PopupSampleShipOrder_ShowError2").style.display="none";
	
	
}	


//-----------------------------------------------------------------------//

//---------------------- Sample Factory Edit Order ---------------------//

function checkPopupSampleFacEditOrder()
{
	if(trim(document.getElementById("PopupSampleFacEditOrder_control_no").value)=="" && trim(document.getElementById("PopupSampleFacEditOrder_ship_date").value)!=""  )
	{
		document.getElementById("PopupSampleFacEditOrder_control_no").className="txtbox_error145";
		PopupSampleFacEditOrder_ShowError();
		document.getElementById("PopupSampleFacEditOrder_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
		
	}
	else
	{	
		document.getElementById("PopupSampleFacEditOrder_control_no").className="txtbox145";
		
				if((trim(document.getElementById("PopupSampleFacEditOrder_ship_date").value)=="" && trim(document.getElementById("PopupSampleFacEditOrder_ship_date_old").value)=="") && (document.getElementById("PopupSampleFacEditOrder_control_no_old").value=="") && trim(document.getElementById("PopupSampleFacEditOrder_control_no").value)!="" )
				{
					document.getElementById("PopupSampleFacEditOrder_newStatus").value ="ApproveNewOrder";
				}
				else if((trim(document.getElementById("PopupSampleFacEditOrder_ship_date").value)!="" && trim(document.getElementById("PopupSampleFacEditOrder_ship_date_old").value)=="")  && trim(document.getElementById("PopupSampleFacEditOrder_control_no").value)!="" )
				{
					document.getElementById("PopupSampleFacEditOrder_newStatus").value ="ShipNewOrder";
					
					//sendMailShipSampleOrder();
					
				}
				else if((trim(document.getElementById("PopupSampleFacEditOrder_ship_date").value)=="" && trim(document.getElementById("PopupSampleFacEditOrder_ship_date_old").value)=="") && (document.getElementById("PopupSampleFacEditOrder_control_no_old").value!="") && trim(document.getElementById("PopupSampleFacEditOrder_control_no").value)=="" )
				{
					document.getElementById("PopupSampleFacEditOrder_newStatus").value ="BackToNewOrder";
				}
				else if(trim(document.getElementById("PopupSampleFacEditOrder_ship_date").value)!="" && (document.getElementById("PopupSampleFacEditOrder_control_no_old").value!="") && trim(document.getElementById("PopupSampleFacEditOrder_control_no").value)=="" )
				{
					document.getElementById("PopupSampleFacEditOrder_newStatus").value ="BackToNewOrder";
				}
				else if(trim(document.getElementById("PopupSampleFacEditOrder_ship_date").value)=="" && trim(document.getElementById("PopupSampleFacEditOrder_ship_date_old").value)!="" && (document.getElementById("PopupSampleFacEditOrder_control_no_old").value!="") && trim(document.getElementById("PopupSampleFacEditOrder_control_no").value)=="" )
				{
					document.getElementById("PopupSampleFacEditOrder_newStatus").value ="BackToNewOrder";
				}
				else if((trim(document.getElementById("PopupSampleFacEditOrder_ship_date").value)=="" && trim(document.getElementById("PopupSampleFacEditOrder_ship_date_old").value)!="") && (document.getElementById("PopupSampleFacEditOrder_control_no_old").value!="") && trim(document.getElementById("PopupSampleFacEditOrder_control_no").value)!="" )
				{
					document.getElementById("PopupSampleFacEditOrder_newStatus").value ="BackToUnship";
				}
				else if(trim(document.getElementById("PopupSampleFacEditOrder_ship_date").value)!="" && trim(document.getElementById("PopupSampleFacEditOrder_ship_date_old").value)==""   && trim(document.getElementById("PopupSampleFacEditOrder_control_no").value)=="" && document.getElementById("PopupSampleFacEditOrder_control_no_old").value=="" )
				{
					document.getElementById("PopupSampleFacEditOrder_ship_date").value = "";
					document.getElementById("PopupSampleFacEditOrder_newStatus").value ="Normal";
				}
				else if((trim(document.getElementById("PopupSampleFacEditOrder_ship_date").value)=="" && trim(document.getElementById("PopupSampleFacEditOrder_ship_date_old").value)=="") && document.getElementById("PopupSampleFacEditOrder_control_no_old").value=="" && trim(document.getElementById("PopupSampleFacEditOrder_control_no").value)=="" )
				{
					document.getElementById("PopupSampleFacEditOrder_newStatus").value ="Normal";
				}
				//else{ alert('555')}
				
			//alert(document.getElementById("PopupSampleFacEditOrder_newStatus").value)
				PopupSampleFacEditOrder_ShowSuccess();
				document.getElementById("PopupSampleFacEditOrder_ErrorText").innerHTML = "Please wait...";
				document.getElementById("PopupSampleFacEditOrder_btnSave").disabled = true;
				facEditSampleOrder();
			
	}
	
	
	//if(trim(document.getElementById("PopupSampleFacEditOrder_ship_date").value)=="")
	//{
	//	document.getElementById("PopupSampleFacEditOrder_ship_date").className="txtbox_error145";
	//}
	//else
	//{
	//	document.getElementById("PopupSampleFacEditOrder_ship_date").className="txtbox145";
	//}
	
	
	
	
	
	
}

function sendMailShipSampleOrder()
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			
			
			
			var url = "basket/sample_email_pdf.php?sample_id="+document.getElementById("sample_id").value+"&ship_date="+trim(document.getElementById("PopupSampleFacEditOrder_ship_date").value)+"&invoice_track="+trim(document.getElementById("PopupSampleFacEditOrder_invoice_track").value)+"&cartons="+trim(encodeURIComponent(document.getElementById("PopupSampleFacEditOrder_cartons").value))+"&weight="+trim(encodeURIComponent(document.getElementById("PopupSampleFacEditOrder_weight").value))+"&volume="+trim(encodeURIComponent(document.getElementById("PopupSampleFacEditOrder_volume").value))+"&agent_id="+document.getElementById("agent_id").value+"&agent_email="+document.getElementById("agent_email").value+"&user_name="+document.getElementById("user_name").value+"&user_email="+document.getElementById("user_email").value+"&action=emailShipOrder";
	//document.getElementById("PopupSampleFacEditOrder_ErrorText").innerHTML =url;
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
									//document.getElementById("PopupSampleFacEditOrder_ErrorText").innerHTML = CList;//			 
						 if(CList!="No")
						 {
							//hidePopupSampleShipOrder();
							//pageRefresh();
							hidePopupSampleFacEditOrder();
							pageRefresh();
							
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}


function facEditSampleOrder()
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_sample_fac_edit_order.php?sample_id="+document.getElementById("sample_id").value+"&ship_date="+trim(document.getElementById("PopupSampleFacEditOrder_ship_date").value)+"&invoice_track="+trim(document.getElementById("PopupSampleFacEditOrder_invoice_track").value)+"&update_by="+document.getElementById("user_id").value+"&cartons="+trim(encodeURIComponent(document.getElementById("PopupSampleFacEditOrder_cartons").value))+"&weight="+trim(encodeURIComponent(document.getElementById("PopupSampleFacEditOrder_weight").value))+"&volume="+trim(encodeURIComponent(document.getElementById("PopupSampleFacEditOrder_volume").value))+"&order_date="+document.getElementById("order_date").value+"&invoice_no="+document.getElementById("invoice_no").value+"&control_no="+trim(document.getElementById("PopupSampleFacEditOrder_control_no").value)+"&newStatus="+document.getElementById("PopupSampleFacEditOrder_newStatus").value+"&contact_id="+document.getElementById("contact_id").value+"&delivery_id="+document.getElementById("delivery_id").value+"&method_name="+trim(encodeURIComponent(document.getElementById("method_name").value))+"&company_id="+document.getElementById("company_id").value+"&method_id="+document.getElementById("method_id").value+"&courier="+trim(encodeURIComponent(document.getElementById("PopupSampleFacEditOrder_courier").value))+"&real_invoice_no="+trim(encodeURIComponent(document.getElementById("PopupSampleFacEditOrder_real_invoice_no").value))+"&total_amount="+trim(encodeURIComponent(document.getElementById("PopupSampleFacEditOrder_total_amount").value))+"&freight_amount="+trim(encodeURIComponent(document.getElementById("PopupSampleFacEditOrder_freight_amount").value));  
	
			createXMLHttpRequest2();
				xmlHttp2.onreadystatechange = function () {
						if(xmlHttp2.readyState == 4) {
						if(xmlHttp2.status == 200) {
												
						CList = xmlHttp2.responseText;  
											 
						 if(CList!="No")
						 {
							
							if(document.getElementById("PopupSampleFacEditOrder_newStatus").value =="ShipNewOrder")
							{
								sendMailShipSampleOrder();	
							}
							else
							{
									hidePopupSampleFacEditOrder();
									pageRefresh();
							}
							
							
							
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp2.open("POST", url, true);
									 xmlHttp2.send(pBody); 
}

function showPopupSampleFacEditOrder()
{
	if(document.getElementById("PopupSampleFacEditOrder"))
	{
		
		document.getElementById("PopupSampleFacEditOrder_control_no").className="txtbox145";
		document.getElementById("PopupSampleFacEditOrder").style.display="";
		document.getElementById("PopupSampleFacEditOrder").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupSampleFacEditOrder").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupSampleFacEditOrder").style.zIndex=1;
	}
}

function hidePopupSampleFacEditOrder()
{
	if(document.getElementById("PopupSampleFacEditOrder"))
	{
		document.getElementById("PopupSampleFacEditOrder_control_no").value = document.getElementById("PopupSampleFacEditOrder_control_no_old").value;
		document.getElementById("PopupSampleFacEditOrder_ship_date").value = document.getElementById("PopupSampleFacEditOrder_ship_date_old").value;
		document.getElementById("PopupSampleFacEditOrder_invoice_track").value = document.getElementById("PopupSampleFacEditOrder_invoice_track_old").value;
		document.getElementById("PopupSampleFacEditOrder_courier").value = document.getElementById("PopupSampleFacEditOrder_courier_old").value;
		document.getElementById("PopupSampleFacEditOrder_real_invoice_no").value = document.getElementById("PopupSampleFacEditOrder_real_invoice_no_old").value;
		document.getElementById("PopupSampleFacEditOrder_total_amount").value = document.getElementById("PopupSampleFacEditOrder_total_amount_old").value;
		document.getElementById("PopupSampleFacEditOrder_freight_amount").value = document.getElementById("PopupSampleFacEditOrder_freight_amount_old").value;
		document.getElementById("PopupSampleFacEditOrder_cartons").value = document.getElementById("PopupSampleFacEditOrder_cartons_old").value;
		document.getElementById("PopupSampleFacEditOrder_weight").value = document.getElementById("PopupSampleFacEditOrder_weight_old").value;
		document.getElementById("PopupSampleFacEditOrder_volume").value = document.getElementById("PopupSampleFacEditOrder_volume_old").value;
		
		//document.getElementById("PopupSampleFacEditOrder_ship_date").className="txtbox145";
		
		document.getElementById("PopupSampleFacEditOrder_ShowError1").style.display="none";
		document.getElementById("PopupSampleFacEditOrder_ShowError2").style.display="none";
		document.getElementById("PopupSampleFacEditOrder").style.display="none";
	}
	
}


function PopupSampleFacEditOrder_ShowError()
{
	document.getElementById("PopupSampleFacEditOrder_ShowError1").style.display="";
	document.getElementById("PopupSampleFacEditOrder_ShowError2").style.display="";
	document.getElementById("PopupSampleFacEditOrder_ShowErrorBox").className = "mode_error";
	
}
function PopupSampleFacEditOrder_ShowSuccess()
{
	document.getElementById("PopupSampleFacEditOrder_ShowError1").style.display="";
	document.getElementById("PopupSampleFacEditOrder_ShowError2").style.display="";
	document.getElementById("PopupSampleFacEditOrder_ShowErrorBox").className ="mode_success";
	
}


function PopupSampleFacEditOrder_CloseError()
{
	document.getElementById("PopupSampleFacEditOrder_ShowError1").style.display="none";
	document.getElementById("PopupSampleFacEditOrder_ShowError2").style.display="none";
	
	
}	

//----------------------------------------------------------------------//

//----------------------- Product change visibile ----------------------//

function checkPopupProductChangeVisible()
{
	
	PopupProductChangeVisible_ShowSuccess();
	document.getElementById("PopupProductChangeVisible_ErrorText").innerHTML = "Please wait...";
	document.getElementById("PopupProductChangeVisible_btnSave").disabled =true;
	document.getElementById("PopupProductChangeVisible_btnCancle").disabled =true;
	
	changeProductVisibile();
	
}

function changeProductVisibile()
{
	
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_product_change_visible.php?product_id="+document.getElementById("product_id").value+"&user_id="+document.getElementById("user_id").value+"&show_public="+getRadioCheckedValue(document.formPopupProductChangeVisible.PopupProductChangeVisible_show_public)+"&brand_type="+document.getElementById("brand_type").value;  
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						 if(CList!="No")
						 {
							
							pageRefresh();
							
						 }
						 
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}





function showPopupProductChangeVisible()
{
	if(document.getElementById("PopupProductChangeVisible"))
	{
		
		document.getElementById("PopupProductChangeVisible").style.display="";
		document.getElementById("PopupProductChangeVisible").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupProductChangeVisible").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupProductChangeVisible").style.zIndex=140;
	}
}

function hidePopupProductChangeVisible()
{
	if(document.getElementById("PopupProductChangeVisible"))
	{
		
		document.getElementById("PopupProductChangeVisible_ShowError1").style.display="none";
		document.getElementById("PopupProductChangeVisible_ShowError2").style.display="none";
		document.getElementById("PopupProductChangeVisible").style.display="none";
	}
	
}



function PopupProductChangeVisible_ShowError()
{
	document.getElementById("PopupProductChangeVisible_ShowError1").style.display="";
	document.getElementById("PopupProductChangeVisible_ShowError2").style.display="";
	document.getElementById("PopupProductChangeVisible_ShowErrorBox").className = "mode_error";
	
}

function PopupProductChangeVisible_ShowSuccess()
{
	document.getElementById("PopupProductChangeVisible_ShowError1").style.display="";
	document.getElementById("PopupProductChangeVisible_ShowError2").style.display="";
	document.getElementById("PopupProductChangeVisible_ShowErrorBox").className ="mode_success";
	
}

function PopupProductChangeVisible_CloseError()
{
	document.getElementById("PopupProductChangeVisible_ShowError1").style.display="none";
	document.getElementById("PopupProductChangeVisible_ShowError2").style.display="none";
	
	
}


//---------------------------------------------------------------------//

//---------------- Popup Delete Catalogue ----------------//

function checkPopupSaleDeleteCatalogue()
{
	
	PopupSaleDeleteCatalogue_ShowSuccess();
	document.getElementById("PopupSaleDeleteCatalogue_ErrorText").innerHTML = "Please wait...";
	document.getElementById("PopupSaleDeleteCatalogue_btnSave").disabled =true;
	document.getElementById("PopupSaleDeleteCatalogue_btnCancle").disabled =true;
	
	window.location = document.getElementById("PopupSaleDeleteCatalogue_linkValue").value;
	
}

function showPopupSaleDeleteCatalogue(linkValue)
{
	if(document.getElementById("PopupSaleDeleteCatalogue"))
	{
		
		document.getElementById("PopupSaleDeleteCatalogue_linkValue").value = linkValue;
		document.getElementById("PopupSaleDeleteCatalogue").style.display="";
		document.getElementById("PopupSaleDeleteCatalogue").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupSaleDeleteCatalogue").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupSaleDeleteCatalogue").style.zIndex=140;
	}
}

function hidePopupSaleDeleteCatalogue()
{
	if(document.getElementById("PopupSaleDeleteCatalogue"))
	{
		
		document.getElementById("PopupSaleDeleteCatalogue_linkValue").value ="";
		document.getElementById("PopupSaleDeleteCatalogue_ShowError1").style.display="none";
		document.getElementById("PopupSaleDeleteCatalogue_ShowError2").style.display="none";
		document.getElementById("PopupSaleDeleteCatalogue").style.display="none";
	}
	
}



function PopupSaleDeleteCatalogue_ShowError()
{
	document.getElementById("PopupSaleDeleteCatalogue_ShowError1").style.display="";
	document.getElementById("PopupSaleDeleteCatalogue_ShowError2").style.display="";
	document.getElementById("PopupSaleDeleteCatalogue_ShowErrorBox").className = "mode_error";
	
}

function PopupSaleDeleteCatalogue_ShowSuccess()
{
	document.getElementById("PopupSaleDeleteCatalogue_ShowError1").style.display="";
	document.getElementById("PopupSaleDeleteCatalogue_ShowError2").style.display="";
	document.getElementById("PopupSaleDeleteCatalogue_ShowErrorBox").className ="mode_success";
	
}

function PopupSaleDeleteCatalogue_CloseError()
{
	document.getElementById("PopupSaleDeleteCatalogue_ShowError1").style.display="none";
	document.getElementById("PopupSaleDeleteCatalogue_ShowError2").style.display="none";
	
	
}

//-----------------------------------------------------------//

//---------------- Popup Delete Catalogue Page ----------------//

function checkPopupSaleDeleteCataloguePage()
{
	
	PopupSaleDeleteCataloguePage_ShowSuccess();
	document.getElementById("PopupSaleDeleteCataloguePage_ErrorText").innerHTML = "Please wait...";
	document.getElementById("PopupSaleDeleteCataloguePage_btnSave").disabled =true;
	document.getElementById("PopupSaleDeleteCataloguePage_btnCancle").disabled =true;
	
	window.location = document.getElementById("PopupSaleDeleteCataloguePage_linkValue").value;
	
}

function showPopupSaleDeleteCataloguePage(linkValue)
{
	if(document.getElementById("PopupSaleDeleteCataloguePage"))
	{
		
		document.getElementById("PopupSaleDeleteCataloguePage_linkValue").value = linkValue;
		document.getElementById("PopupSaleDeleteCataloguePage").style.display="";
		document.getElementById("PopupSaleDeleteCataloguePage").style.top=( ( (screen.height/2)+getScrollY() - 200 ))+"px";
		document.getElementById("PopupSaleDeleteCataloguePage").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupSaleDeleteCataloguePage").style.zIndex=140;
	}
}

function hidePopupSaleDeleteCataloguePage()
{
	if(document.getElementById("PopupSaleDeleteCataloguePage"))
	{
		
		document.getElementById("PopupSaleDeleteCataloguePage_linkValue").value ="";
		document.getElementById("PopupSaleDeleteCataloguePage_ShowError1").style.display="none";
		document.getElementById("PopupSaleDeleteCataloguePage_ShowError2").style.display="none";
		document.getElementById("PopupSaleDeleteCataloguePage").style.display="none";
	}
	
}



function PopupSaleDeleteCataloguePage_ShowError()
{
	document.getElementById("PopupSaleDeleteCataloguePage_ShowError1").style.display="";
	document.getElementById("PopupSaleDeleteCataloguePage_ShowError2").style.display="";
	document.getElementById("PopupSaleDeleteCataloguePage_ShowErrorBox").className = "mode_error";
	
}

function PopupSaleDeleteCataloguePage_ShowSuccess()
{
	document.getElementById("PopupSaleDeleteCataloguePage_ShowError1").style.display="";
	document.getElementById("PopupSaleDeleteCataloguePage_ShowError2").style.display="";
	document.getElementById("PopupSaleDeleteCataloguePage_ShowErrorBox").className ="mode_success";
	
}

function PopupSaleDeleteCataloguePage_CloseError()
{
	document.getElementById("PopupSaleDeleteCataloguePage_ShowError1").style.display="none";
	document.getElementById("PopupSaleDeleteCataloguePage_ShowError2").style.display="none";
	
	
}

//-----------------------------------------------------------//

//---------------- Popup Delete Test Report ----------------//

function checkPopupSaleDeleteReport()
{
	
	PopupSaleDeleteReport_ShowSuccess();
	document.getElementById("PopupSaleDeleteReport_ErrorText").innerHTML = "Please wait...";
	document.getElementById("PopupSaleDeleteReport_btnSave").disabled =true;
	document.getElementById("PopupSaleDeleteReport_btnCancle").disabled =true;
	
	window.location = document.getElementById("PopupSaleDeleteReport_linkValue").value;
	
}

function showPopupSaleDeleteReport(linkValue)
{
	if(document.getElementById("PopupSaleDeleteReport"))
	{
		
		document.getElementById("PopupSaleDeleteReport_linkValue").value = linkValue;
		document.getElementById("PopupSaleDeleteReport").style.display="";
		document.getElementById("PopupSaleDeleteReport").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupSaleDeleteReport").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupSaleDeleteReport").style.zIndex=140;
	}
}

function hidePopupSaleDeleteReport()
{
	if(document.getElementById("PopupSaleDeleteReport"))
	{
		
		document.getElementById("PopupSaleDeleteReport_linkValue").value ="";
		document.getElementById("PopupSaleDeleteReport_ShowError1").style.display="none";
		document.getElementById("PopupSaleDeleteReport_ShowError2").style.display="none";
		document.getElementById("PopupSaleDeleteReport").style.display="none";
	}
	
}



function PopupSaleDeleteReport_ShowError()
{
	document.getElementById("PopupSaleDeleteReport_ShowError1").style.display="";
	document.getElementById("PopupSaleDeleteReport_ShowError2").style.display="";
	document.getElementById("PopupSaleDeleteReport_ShowErrorBox").className = "mode_error";
	
}

function PopupSaleDeleteReport_ShowSuccess()
{
	document.getElementById("PopupSaleDeleteReport_ShowError1").style.display="";
	document.getElementById("PopupSaleDeleteReport_ShowError2").style.display="";
	document.getElementById("PopupSaleDeleteReport_ShowErrorBox").className ="mode_success";
	
}

function PopupSaleDeleteReport_CloseError()
{
	document.getElementById("PopupSaleDeleteReport_ShowError1").style.display="none";
	document.getElementById("PopupSaleDeleteReport_ShowError2").style.display="none";
	
	
}

//-----------------------------------------------------------//

//--------------------------- Popup Sample Edit Company ---------------//

function checkPopupSampleEditCompany()
{
	if(trim(document.getElementById("PopupSampleEditCompany_company_name").value)=="" )
	{
		PopupSampleEditCompany_ShowError();
		document.getElementById("PopupSampleEditCompany_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
		
	}
	else
	{
			
			
				PopupSampleEditCompany_ShowSuccess();
				document.getElementById("PopupSampleEditCompany_ErrorText").innerHTML = "Please wait...";
				document.getElementById("PopupSampleEditCompany_btnSave").disabled =true;
				document.getElementById("PopupSampleEditCompany_btnCancel").disabled =true;
				sampleEditCompany();
			
	}
	
	
	if(trim(document.getElementById("PopupSampleEditCompany_company_name").value)=="")
	{
		document.getElementById("PopupSampleEditCompany_company_name").className="txtbox_error250";
	}
	else
	{
		document.getElementById("PopupSampleEditCompany_company_name").className="txtbox250";
	}
	
	
	
	
}

function sampleEditCompany()
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_edit_company.php?companyname="+trim(encodeURIComponent(document.getElementById("PopupSampleEditCompany_company_name").value))+"&customerid="+trim(encodeURIComponent(document.getElementById("PopupSampleEditCompany_customer_id").value))+"&accountid="+trim(document.getElementById("PopupSampleEditCompany_agent_id").value)+"&company_id="+document.getElementById("company_id").value+"&address="+trim(encodeURIComponent(document.getElementById("PopupSampleEditCompany_address").value))+"&country="+trim(document.getElementById("PopupSampleEditCompany_country").value)+"&telephone="+trim(encodeURIComponent(document.getElementById("PopupSampleEditCompany_telephone").value))+"&fax="+trim(encodeURIComponent(document.getElementById("PopupSampleEditCompany_fax").value)); 
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						if(CList!="No")
						 {
							
							//pageRefresh();
							
							 document.getElementById("company_name").value = document.getElementById("PopupSampleEditCompany_company_name").value;
							document.getElementById("company_customer_id").value = document.getElementById("PopupSampleEditCompany_customer_id").value;
							//document.getElementById("account_manager_id").value = document.getElementById("PopupSampleEditCompany_agent_id").value;
							document.getElementById("agent_id").value = document.getElementById("PopupSampleEditCompany_agent_id").value;
							document.getElementById("company_address").value = document.getElementById("PopupSampleEditCompany_address").value;
							//document.getElementById("company_city").value = document.getElementById("PopupSampleEditCompany_city").value;
							//document.getElementById("company_region").value = document.getElementById("PopupSampleEditCompany_region").value;
							//document.getElementById("company_postcode").value = document.getElementById("PopupSampleEditCompany_postcode").value;
							document.getElementById("company_telephone").value = document.getElementById("PopupSampleEditCompany_telephone").value;
							document.getElementById("company_fax").value = document.getElementById("PopupSampleEditCompany_fax").value;
							document.getElementById("company_country").value = document.getElementById("PopupSampleEditCompany_country").value;
							
							
							customerText = "";
							customerText = document.getElementById("company_name").value;
							if(trim(document.getElementById("company_customer_id").value)!="")
							{
								customerText = customerText + " ("+trim(document.getElementById("company_customer_id").value)+")"
							}
							
							document.getElementById("lbnCompanyName").innerHTML = customerText;
							document.getElementById("lbnCompanyName2").innerHTML = customerText;
							
							
							hidePopupSampleEditCompany();
							
							
						 }
						 else
						 {
						 	
						 }
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}

function SelectOption(ObjName,NValue)
{
	
	var objCount = document.getElementById(ObjName).options.length;
	
	for(i=0;i<=objCount-1;i++)
	{
		if(document.getElementById(ObjName)[i].text == NValue)
		{
			document.getElementById(ObjName).selectedIndex = i;
			break;
		}
	}
	
}


function showPopupSampleEditCompany()
{
	if(document.getElementById("PopupSampleEditCompany"))
	{
		
		document.getElementById("PopupSampleEditCompany_company_name").value = document.getElementById("company_name").value;
		document.getElementById("PopupSampleEditCompany_customer_id").value = document.getElementById("company_customer_id").value;
		document.getElementById("PopupSampleEditCompany_agent_id").value = document.getElementById("agent_id").value;
		document.getElementById("PopupSampleEditCompany_address").value = trim(document.getElementById("company_address").value);
		//document.getElementById("PopupSampleEditCompany_city").value = document.getElementById("company_city").value;
		//document.getElementById("PopupSampleEditCompany_region").value = document.getElementById("company_region").value;
		//document.getElementById("PopupSampleEditCompany_postcode").value = document.getElementById("company_postcode").value;
		document.getElementById("PopupSampleEditCompany_telephone").value = document.getElementById("company_telephone").value;
		document.getElementById("PopupSampleEditCompany_fax").value = document.getElementById("company_fax").value;
		
		SelectOption('PopupSampleEditCompany_country',document.getElementById("company_country").value);
		//alert(document.getElementById("company_country").value);
		document.getElementById("PopupSampleEditCompany_btnSave").disabled = false;
		document.getElementById("PopupSampleEditCompany_btnCancel").disabled = false;
		
		document.getElementById("PopupSampleEditCompany").style.display="";
		document.getElementById("PopupSampleEditCompany").style.top=((screen.height-500)*0.35)+"px";
		document.getElementById("PopupSampleEditCompany").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupSampleEditCompany").style.zIndex=140;
	}
}

function hidePopupSampleEditCompany()
{
	if(document.getElementById("PopupSampleEditCompany"))
	{
		//document.getElementById("PopupSampleEditCompany_company_name").value ="";
		//document.getElementById("PopupSampleEditCompany_agent_id").selectedIndex = 0;
		
		document.getElementById("PopupSampleEditCompany_company_name").className="txtbox250";
		
		document.getElementById("PopupSampleEditCompany_ShowError1").style.display="none";
		document.getElementById("PopupSampleEditCompany_ShowError2").style.display="none";
		document.getElementById("PopupSampleEditCompany").style.display="none";
	}
	
}

function PopupSampleEditCompany_ShowError()
{
	document.getElementById("PopupSampleEditCompany_ShowError1").style.display="";
	document.getElementById("PopupSampleEditCompany_ShowError2").style.display="";
	document.getElementById("PopupSampleEditCompany_ShowErrorBox").className = "mode_error";
	
}

function PopupSampleEditCompany_ShowSuccess()
{
	document.getElementById("PopupSampleEditCompany_ShowError1").style.display="";
	document.getElementById("PopupSampleEditCompany_ShowError2").style.display="";
	document.getElementById("PopupSampleEditCompany_ShowErrorBox").className = "mode_success";
	
}

function PopupSampleEditCompany_CloseError()
{
	document.getElementById("PopupSampleEditCompany_ShowError1").style.display="none";
	document.getElementById("PopupSampleEditCompany_ShowError2").style.display="none";
	//document.getElementById("PopupAddContact_ShowErrorBox").className = "txt_mode_error";
	
}	

//-------------------------------------------------------------//

//---------------- Popup Company Contact Edit Privacy ------//

function saveCompanyContactEditPrivacy()//***
{
	contact_id = document.getElementById("contact_id").value;
	
	if(document.formPopupCompanyContactEditPrivacy.PopupCompanyContactEditPrivacy_mail_rec[0].checked==true)
	{
		mail_rec = "Yes";
	}
	else
	{
		mail_rec = "No";
	}
	
	if(document.formPopupCompanyContactEditPrivacy.PopupCompanyContactEditPrivacy_news_rec[0].checked==true)
	{
		news_rec = "Yes";
	}
	else
	{
		news_rec = "No";
	}
	
	if(document.formPopupCompanyContactEditPrivacy.PopupCompanyContactEditPrivacy_status_login[0].checked==true)
	{
		status_login = "Active";
	}
	else
	{
		status_login = "Inactive";
	}
	
	
		
	
	PopupCompanyContactEditPrivacy_ShowSuccess();
	document.getElementById("PopupCompanyContactEditPrivacy_ErrorText").innerHTML = "Please wait...";
	
	document.getElementById("PopupCompanyContactEditPrivacy_btnSave").disabled = true;
	document.getElementById("PopupCompanyContactEditPrivacy_btnCancel").disabled = true;
	
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_edit_company_contact_privacy.php?contact_id="+contact_id+"&mail_rec="+mail_rec+"&news_rec="+news_rec+"&status_login="+status_login;
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						if(CList=="Ok")
						 {
							
							if(document.formPopupCompanyContactEditPrivacy.PopupCompanyContactEditPrivacy_mail_rec[0].checked==true)
							{
								document.getElementById("mail_rec"+contact_id).src = "images/icn_contact_yes.jpg";
							}
							else
							{
								document.getElementById("mail_rec"+contact_id).src = "images/icn_contact_no.jpg";
							}
							
							if(document.formPopupCompanyContactEditPrivacy.PopupCompanyContactEditPrivacy_news_rec[0].checked==true)
							{
								document.getElementById("news_rec"+contact_id).src = "images/icn_contact_yes.jpg";
							}
							else
							{
								document.getElementById("news_rec"+contact_id).src = "images/icn_contact_no.jpg";
							}
							
							if(document.formPopupCompanyContactEditPrivacy.PopupCompanyContactEditPrivacy_status_login[0].checked==true)
							{
								document.getElementById("status_login"+contact_id).src = "images/icn_contact_yes.jpg";
							}
							else
							{
								document.getElementById("status_login"+contact_id).src = "images/icn_contact_no.jpg";
							}
							
							
							
							document.getElementById("PopupCompanyContactEditPrivacy_ErrorText").innerHTML = "<font color='green'> Your changes have been saved.</font>";
							setTimeout("hidePopupCompanyContactEditPrivacy();",500);
							document.getElementById("PopupCompanyContactEditPrivacy_btnSave").disabled = false;
							document.getElementById("PopupCompanyContactEditPrivacy_btnCancel").disabled = false;
							
						 }
						 
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
										document.getElementById("PopupCompanyContactEditPrivacy_btnSave").disabled = false;
										document.getElementById("PopupCompanyContactEditPrivacy_btnCancel").disabled = false;
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
	
	
	
	
}

function getCompanyContactPrivacy(contact_id,obj)
{
	var returnTop;
	var returnLeft;
	returnTop = findPosY(obj)-50;
	returnLeft = findPosX(obj);
	addChangeLoading(returnTop,returnLeft);
	
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_get_company_contact_privacy.php?contact_id="+trim(contact_id);  
	
			createXMLHttpRequest3();
				xmlHttp3.onreadystatechange = function () {
						if(xmlHttp3.readyState == 4) {
						if(xmlHttp3.status == 200) {
												
						CList = xmlHttp3.responseText;  
								//alert(CList)				 
						
							showPopupCompanyContactEditPrivacy(CList,contact_id);  
							
						 
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp3.open("POST", url, true);
									 xmlHttp3.send(pBody); 
}

function showPopupCompanyContactEditPrivacy(CList,contact_id)//***
{
	if(document.getElementById("PopupCompanyContactEditPrivacy"))
	{
		arr = CList.split("!*!");
		var contact_name = arr[0];
		var news_rec = arr[1];
		var mail_rec = arr[2];
		var status_login = arr[3];
		
		//alert(agent_group_id)
		
		document.getElementById("contact_id").value = contact_id;
		
		document.getElementById("PopupCompanyContactEditPrivacy_name").innerHTML = contact_name;
		
		if(news_rec=="Yes")
		{
			document.formPopupCompanyContactEditPrivacy.PopupCompanyContactEditPrivacy_news_rec[0].checked = true;		
		}
		else
		{
			document.formPopupCompanyContactEditPrivacy.PopupCompanyContactEditPrivacy_news_rec[1].checked = true;			
		}
		
		if(mail_rec=="Yes")
		{
			document.formPopupCompanyContactEditPrivacy.PopupCompanyContactEditPrivacy_mail_rec[0].checked = true;		
		}
		else
		{
			document.formPopupCompanyContactEditPrivacy.PopupCompanyContactEditPrivacy_mail_rec[1].checked = true;			
		}
		
		if(status_login=="Active")
		{
			document.formPopupCompanyContactEditPrivacy.PopupCompanyContactEditPrivacy_status_login[0].checked = true;		
		}
		else
		{
			document.formPopupCompanyContactEditPrivacy.PopupCompanyContactEditPrivacy_status_login[1].checked = true;			
		}
		
		/*var allAgentCount = parseInt(document.getElementById("PopupCompanyContactEditPrivacy_AllAgentCount").value);
		var arrAgentId = agent_group_id.split(",");
		
		for(i=1;i<=allAgentCount;i++)
		{
			if(document.getElementById("PopupCompanyContactEditPrivacy_agent"+i))
			{
				document.getElementById("PopupCompanyContactEditPrivacy_agent"+i).checked = false;
				if(checkValueInArray(document.getElementById("PopupCompanyContactEditPrivacy_agent"+i).value,arrAgentId)==true)
				{
					
					document.getElementById("PopupCompanyContactEditPrivacy_agent"+i).checked = true;
					
				}
				
				
			}
		}*/
		
		
		
		removeChangeLoading();
		document.getElementById("PopupCompanyContactEditPrivacy_btnSave").disabled = false;
		document.getElementById("PopupCompanyContactEditPrivacy_btnCancel").disabled = false;
		document.getElementById("PopupCompanyContactEditPrivacy").style.display="";
		document.getElementById("PopupCompanyContactEditPrivacy").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupCompanyContactEditPrivacy").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupCompanyContactEditPrivacy").style.zIndex=120;
	}
}

function checkValueInArray(value,array)
{
	var countArray = array.length-1;
	var chk = false;
	for(x=0;x<=countArray;x++)
	{
		if(array[x]==value)
		{
			chk = true;
			break;
		}
	}
	
	return chk
	
}

function hidePopupCompanyContactEditPrivacy()
{
	if(document.getElementById("PopupCompanyContactEditPrivacy"))
	{
		
		document.getElementById("PopupCompanyContactEditPrivacy_ShowError1").style.display="none";
		document.getElementById("PopupCompanyContactEditPrivacy_ShowError2").style.display="none";
		document.getElementById("PopupCompanyContactEditPrivacy").style.display="none";
	}
	
}

function PopupCompanyContactEditPrivacy_ShowError()
{
	document.getElementById("PopupCompanyContactEditPrivacy_ShowError1").style.display="";
	document.getElementById("PopupCompanyContactEditPrivacy_ShowError2").style.display="";
	document.getElementById("PopupCompanyContactEditPrivacy_ShowErrorBox").className = "mode_error";
	
}

function PopupCompanyContactEditPrivacy_ShowSuccess()
{
	document.getElementById("PopupCompanyContactEditPrivacy_ShowError1").style.display="";
	document.getElementById("PopupCompanyContactEditPrivacy_ShowError2").style.display="";
	document.getElementById("PopupCompanyContactEditPrivacy_ShowErrorBox").className = "mode_success";
	
}

function PopupCompanyContactEditPrivacy_CloseError()
{
	document.getElementById("PopupCompanyContactEditPrivacy_ShowError1").style.display="none";
	document.getElementById("PopupCompanyContactEditPrivacy_ShowError2").style.display="none";
	//document.getElementById("PopupAddContact_ShowErrorBox").className = "txt_mode_error";
	
}

//--------------------------------------------------------//

//--------------------------- Asset ---------------------------------//
function clickNavToggle(spnSubName,subItem,subNavSign,clickDefault)
{
	
	if($(jq(subItem)).is(':visible') )
	{
        if(document.getElementById(subNavSign))
		{
			document.getElementById(subNavSign).className='Toggle';
		}
		
		if(document.getElementById(clickDefault!="Yes"))
		{
			document.getElementById(spnSubName).className='leftNav';
		}
		
		if(spnSubName=="spnSubNameMore")
		{
			document.getElementById("lbSubNameMore").innerHTML = "More";
			document.getElementById("imgSubNameMore").src = "images/img_down1.gif";
			
		}
		
     }
	 else
	 {
	 	 if(document.getElementById(subNavSign))
		 {
		 	document.getElementById(subNavSign).className='ToggleClick';
		 }
		 
		if(document.getElementById(clickDefault!="Yes"))
		{
			document.getElementById(spnSubName).className='leftNav';
		}
		
		if(spnSubName=="spnSubNameMore")
		{
			document.getElementById("lbSubNameMore").innerHTML = "Less";
			document.getElementById("imgSubNameMore").src = "images/img_up1.gif";
		}
		 
	 }
	   
	$(jq(subItem)).slideToggle('medium');
	
   
}
//----------------------------------------------------------//
//--------------------- Popup Artwork Info ------------------//
function showPopupAssetInfo(obj,file_id)
{
	if(document.getElementById("PopupAssetInfo"))
	{
		 var objTop = getCurrentPageY()+getScrollHeight();
		 var objLeft = getCurrentPageX();
		 var objWidth = 420;
		 var objHeight = 350;
		 
		 var returnTop;
		 var returnLeft;
		 returnTop = findPosY(obj)-50;
		 returnLeft = findPosX(obj)-50;
		 //alert(objLeft+"--"+(returnLeft+320))
		 
		 if((returnLeft+320)>objLeft)
		 {
			 returnLeft = (objLeft-330);
		 }
		 //addChangeLoading(returnTop,returnLeft);
		 
		// var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15;
		 //var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight);
		 document.getElementById("currentAssetId").value = document.getElementById("hid_asset_id"+file_id).value;
		 
		 if(document.getElementById("hid_asset_name"+file_id).value!="")
		 {
		 	document.getElementById("PopupAssetInfo_asset_name").innerHTML = document.getElementById("hid_asset_name"+file_id).value;
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_asset_name").innerHTML = "&nbsp;&nbsp;";
		 }
		 
		 if(document.getElementById("hid_ref_product"+file_id).value!="")
		 {
		 	document.getElementById("PopupAssetInfo_ref_product").innerHTML = document.getElementById("hid_ref_product"+file_id).value;
			document.getElementById("PopupAssetInfo_ref_product_lb").className = "txt11_333";
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_ref_product").innerHTML = "&nbsp;&nbsp;";
			document.getElementById("PopupAssetInfo_ref_product_lb").className = "txt11_999";
		 }
		 
		 if(document.getElementById("hid_ref_orders"+file_id).value!="")
		 {
		 	document.getElementById("PopupAssetInfo_ref_orders").innerHTML = document.getElementById("hid_ref_orders"+file_id).value;
			document.getElementById("PopupAssetInfo_ref_orders_lb").className = "txt11_333";
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_ref_orders").innerHTML = "&nbsp;&nbsp;";
			document.getElementById("PopupAssetInfo_ref_orders_lb").className = "txt11_999";
		 }
		 
		 if(document.getElementById("hid_ref_sample"+file_id).value!="")
		 {
		 	document.getElementById("PopupAssetInfo_ref_sample").innerHTML = document.getElementById("hid_ref_sample"+file_id).value;
			document.getElementById("PopupAssetInfo_ref_sample_lb").className = "txt11_333";
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_ref_sample").innerHTML = "&nbsp;&nbsp;";
			document.getElementById("PopupAssetInfo_ref_sample_lb").className = "txt11_999";
		 }
		 
		 if(document.getElementById("hid_asset_keyword"+file_id).value!="")
		 {
			 document.getElementById("PopupAssetInfo_asset_keyword").innerHTML = document.getElementById("hid_asset_keyword"+file_id).value;
			 document.getElementById("PopupAssetInfo_asset_keyword_lb").className = "txt11_333";
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_asset_keyword").innerHTML = "&nbsp;";
			document.getElementById("PopupAssetInfo_asset_keyword_lb").className = "txt11_999";
		 }
		 
		 if(document.getElementById("hid_asset_desc"+file_id).value!="")
		 {
			 document.getElementById("PopupAssetInfo_asset_desc").innerHTML = document.getElementById("hid_asset_desc"+file_id).value;
			 document.getElementById("PopupAssetInfo_asset_desc_lb").className = "txt11_333";
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_asset_desc").innerHTML = "&nbsp;";
			document.getElementById("PopupAssetInfo_asset_desc_lb").className = "txt11_999";
		 }
		 
		 if(document.getElementById("hid_type_size"+file_id).value!="")
		 {
		 	document.getElementById("PopupAssetInfo_type_size").innerHTML = document.getElementById("hid_type_size"+file_id).value;
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_type_size").innerHTML = "&nbsp;&nbsp;";
		 }
		 
		 if(document.getElementById("hid_upload_up_by"+file_id))
		 {
			if(document.getElementById("hid_upload_up_by"+file_id).value!="")
			{
				document.getElementById("PopupAssetInfo_upload_by_lb").innerHTML = "Last Updater";	
				document.getElementById("PopupAssetInfo_upload_by").innerHTML = document.getElementById("hid_upload_up_by"+file_id).value;
				document.getElementById("PopupAssetInfo_upload_date_lb").innerHTML = "Last Updated";
				document.getElementById("PopupAssetInfo_upload_date").innerHTML = document.getElementById("hid_upload_up_date"+file_id).value;
			}
			else
			{
				document.getElementById("PopupAssetInfo_upload_by_lb").innerHTML = "Uploader";
				document.getElementById("PopupAssetInfo_upload_date_lb").innerHTML = "Uploaded";
				if(document.getElementById("hid_upload_by"+file_id).value!="")
				 {
					document.getElementById("PopupAssetInfo_upload_by").innerHTML = document.getElementById("hid_upload_by"+file_id).value;
					document.getElementById("PopupAssetInfo_upload_date").innerHTML = document.getElementById("hid_upload_date"+file_id).value;
				 }
				 else
				 {
					document.getElementById("PopupAssetInfo_upload_by").innerHTML = "&nbsp;&nbsp;";
					document.getElementById("PopupAssetInfo_upload_date").innerHTML = "&nbsp;&nbsp;";
				 }	
			}
		 }
		 else
		 {
			   document.getElementById("PopupAssetInfo_upload_by_lb").innerHTML = "Uploader";
				document.getElementById("PopupAssetInfo_upload_date_lb").innerHTML = "Uploaded";
				if(document.getElementById("hid_upload_by"+file_id).value!="")
				 {
					document.getElementById("PopupAssetInfo_upload_by").innerHTML = document.getElementById("hid_upload_by"+file_id).value;
					document.getElementById("PopupAssetInfo_upload_date").innerHTML = document.getElementById("hid_upload_date"+file_id).value;
				 }
				 else
				 {
					document.getElementById("PopupAssetInfo_upload_by").innerHTML = "&nbsp;&nbsp;";
					document.getElementById("PopupAssetInfo_upload_date").innerHTML = "&nbsp;&nbsp;";
				 }	
		 }
		 
		 
		 
		 
		 
		 if(document.getElementById("hid_asset_file"+file_id).value!="")
		 {
		 	document.getElementById("PopupAssetInfo_asset_file").innerHTML = document.getElementById("hid_asset_file"+file_id).value;
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_asset_file").innerHTML = "&nbsp;&nbsp;";
		 }
		 
		 if(document.getElementById("hid_asset_image"+file_id).value!="")
		 {
			 document.getElementById("PopupAssetInfo_asset_image").innerHTML = document.getElementById("hid_asset_image"+file_id).value;
			 document.getElementById("PopupAssetInfo_asset_image_lb").className = "txt11_333";
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_asset_image").innerHTML = "&nbsp;";
			document.getElementById("PopupAssetInfo_asset_image_lb").className = "txt11_999";
		 }
		 
		 document.getElementById("PopupAssetInfo_cat_sub").innerHTML = document.getElementById("hid_cat_name"+file_id).value;
		 
		 if(document.getElementById("hid_sub_name"+file_id).value!="")
		 {
		 	document.getElementById("PopupAssetInfo_cat_sub").innerHTML += "/"+document.getElementById("hid_sub_name"+file_id).value;
		 }
		
		
		 if(document.getElementById("hid_submit_no"+file_id).value!="")
		 {
			 document.getElementById("PopupAssetInfo_submit_no").innerHTML = document.getElementById("hid_submit_no"+file_id).value;
			 document.getElementById("PopupAssetInfo_submit_no_lb").className = "txt11_333";
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_submit_no").innerHTML = "&nbsp;";
			document.getElementById("PopupAssetInfo_submit_no_lb").className = "txt11_999";
		 }
		 
		 if(document.getElementById("hid_submit_by"+file_id).value!="")
		 {
			 document.getElementById("PopupAssetInfo_submit_by").innerHTML = document.getElementById("hid_submit_by"+file_id).value;
			 document.getElementById("PopupAssetInfo_submit_by_lb").className = "txt11_333";
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_submit_by").innerHTML = "&nbsp;";
			document.getElementById("PopupAssetInfo_submit_by_lb").className = "txt11_999";
		 }
		 
		 if(document.getElementById("hid_approve_status"+file_id).value!="")
		 {
			 //document.getElementById("PopupAssetInfo_approve_status").innerHTML = document.getElementById("hid_approve_status"+file_id).value;
			 
			 if(document.getElementById("hid_approve_status"+file_id).value=="Yes")
			 {
				 document.getElementById("PopupAssetInfo_approve_status").className = "txt11_green";
				 document.getElementById("PopupAssetInfo_approve_status").style.fontWeight = "bold";
				 
				 document.getElementById("PopupAssetInfo_approve_icon").style.display = "";
				 document.getElementById("PopupAssetInfo_approve_icon").src = "images/icn_asset_app_yes.png";
				 document.getElementById("PopupAssetInfo_approve_status").innerHTML = "Approved"; 
			 }
			 else if(document.getElementById("hid_approve_status"+file_id).value=="No")
			 {
				 document.getElementById("PopupAssetInfo_approve_status").className = "txt11_red2";
				 document.getElementById("PopupAssetInfo_approve_status").style.fontWeight = "bold";
				 
				 document.getElementById("PopupAssetInfo_approve_icon").style.display = "";
				 document.getElementById("PopupAssetInfo_approve_icon").src = "images/icn_asset_app_no.png";
				 document.getElementById("PopupAssetInfo_approve_status").innerHTML = "Not Approved"; 
			 }
			 else if(document.getElementById("hid_approve_status"+file_id).value=="Pending")
			 {
				 document.getElementById("PopupAssetInfo_approve_status").className = "txt11_yellow2";
				 document.getElementById("PopupAssetInfo_approve_status").style.fontWeight = "bold"; 
				 
				 document.getElementById("PopupAssetInfo_approve_icon").style.display = "";
				 document.getElementById("PopupAssetInfo_approve_icon").src = "images/icn_asset_app_pending.png";
				 document.getElementById("PopupAssetInfo_approve_status").innerHTML = "Pending"; 
			 }
			 else
			 {
				 document.getElementById("PopupAssetInfo_approve_status").className = "txt11_333";
				 document.getElementById("PopupAssetInfo_approve_status").style.fontWeight = "normal";
				 document.getElementById("PopupAssetInfo_approve_icon").style.display = "none";
				 document.getElementById("PopupAssetInfo_approve_icon").src = "images/icn_asset_app_yes.png";
				 document.getElementById("PopupAssetInfo_approve_status").innerHTML = document.getElementById("hid_approve_status"+file_id).value; 
			 }
			 
			 
			 document.getElementById("PopupAssetInfo_approve_status_lb").className = "txt11_333";
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_approve_status").innerHTML = "&nbsp;";
			document.getElementById("PopupAssetInfo_approve_status_lb").className = "txt11_999";
		 }
		 
		 if(document.getElementById("hid_approve_date"+file_id).value!="")
		 {
			 document.getElementById("PopupAssetInfo_approve_date").innerHTML = " on "+document.getElementById("hid_approve_date"+file_id).value;
			 //document.getElementById("PopupAssetInfo_approve_date_lb").className = "txt11_333";
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_approve_date").innerHTML = "&nbsp;";
			//document.getElementById("PopupAssetInfo_approve_date_lb").className = "txt11_999";
		 }
		 
		  if(document.getElementById("hid_approve_note"+file_id).value!="")
		 {
			 document.getElementById("PopupAssetInfo_approve_note").innerHTML = document.getElementById("hid_approve_note"+file_id).value;
			 document.getElementById("PopupAssetInfo_approve_note_lb").className = "txt11_333";
		 }
		 else
		 {
		 	document.getElementById("PopupAssetInfo_approve_note").innerHTML = "&nbsp;";
			document.getElementById("PopupAssetInfo_approve_note_lb").className = "txt11_999";
		 }
		
		if(document.getElementById("hid_can_delete"+file_id).value=="Yes")
		{
			document.getElementById("PopupAssetInfo_row_delete").style.display = "";
		}
		else
		{
			document.getElementById("PopupAssetInfo_row_delete").style.display = "none";
		}  
		
		 
		 
		document.getElementById("PopupAssetInfo").style.display="";
		document.getElementById("PopupAssetInfo").style.top= (returnTop)+"px";
		document.getElementById("PopupAssetInfo").style.left= (returnLeft)+"px";
		document.getElementById("PopupAssetInfo").style.zIndex=140;
		
	}
	
	
}



function hidePopupAssetInfo()
{
	if(document.getElementById("PopupAssetInfo"))
	{
			
		document.getElementById("PopupAssetInfo_ShowError1").style.display="none";
		document.getElementById("PopupAssetInfo_ShowError2").style.display="none";
		document.getElementById("PopupAssetInfo").style.display="none";
	
	}
}

function PopupAssetInfo_ShowError()
{
	document.getElementById("PopupAssetInfo_ShowError1").style.display="";
	document.getElementById("PopupAssetInfo_ShowError2").style.display="";
	document.getElementById("PopupAssetInfo_ShowErrorBox").className = "mode_error";
	
}

function PopupAssetInfo_ShowSuccess()
{
	document.getElementById("PopupAssetInfo_ShowError1").style.display="";
	document.getElementById("PopupAssetInfo_ShowError2").style.display="";
	document.getElementById("PopupAssetInfo_ShowErrorBox").className = "mode_success3";
	
}

function PopupAssetInfo_CloseError()
{
	document.getElementById("PopupAssetInfo_ShowError1").style.display="none";
	document.getElementById("PopupAssetInfo_ShowError2").style.display="none";
	
	
}
//-----------------------------------------------------------------------//
//-------------------------- Delete Asset ------------------//
function deleteAsset(value)
{
	if(value==true)
	{
			var user_id = trim(document.getElementById("user_id").value);
			var asset_id = document.getElementById("currentAssetId").value;
			
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_asset_delete_asset.php?asset_id="+asset_id+"&user_id="+user_id;  
	 		
			document.getElementById("PopupConfirmBox_btnConfirm").disabled = true;
			document.getElementById("PopupConfirmBox_btnCancel").disabled = true;
			
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						 if(CList!="No")
						 {
							
							pageRefresh();
							//window.location = "asset_manage_cat_sub.php";
						 }
						 
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
	
	}
	else
	{
		hidePopupConfirmBox();
	}
}

function deleteRealAsset(value)
{
	if(value==true)
	{
			var user_id = trim(document.getElementById("user_id").value);
			var asset_id = document.getElementById("currentAssetId").value;
			
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_asset_delete_real_asset.php?asset_id="+asset_id+"&user_id="+user_id;  
	 		
			document.getElementById("PopupConfirmBox_btnConfirm").disabled = true;
			document.getElementById("PopupConfirmBox_btnCancel").disabled = true;
			
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						 if(CList!="No")
						 {
							
							pageRefresh();
							//window.location = "asset_manage_cat_sub.php";
						 }
						 
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
	
	}
	else
	{
		hidePopupConfirmBox();
	}
}
//----------------------------------------------------------//

//-------------------- Add Asset  ------------------------//
function checkGetSubFromCat()
{
	var cat_id = parseInt(document.getElementById("new_cat_id").value);
	if(cat_id!=0)
	{
		getSubFromCat(cat_id);
	}
	else
	{
		ClearChildNodes("ssub_id");
		option=document.createElement("option");
		option.appendChild(document.createTextNode("Select Sub Folder")); 
		option.value="0";
		document.getElementById("ssub_id").appendChild(option);
		document.getElementById("ssub_id").disabled = true;
	}
}

function getSubFromCat(cat_id)
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_asset_get_sub.php?cat_id="+cat_id+"&user_id="+document.getElementById("user_id").value;  
			//removeCompanyContact();
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						if( CList!="No")
						{
							createSubIdList(CList);
						}
						else
						{
							ClearChildNodes("ssub_id");
							option=document.createElement("option");
							option.appendChild(document.createTextNode("Select Sub Folder")); 
							option.value="0";
							document.getElementById("ssub_id").appendChild(option);
							document.getElementById("ssub_id").disabled = true;
						}
						
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}

function createSubIdList(CList)
{
	ClearChildNodes("ssub_id");
	
	option=document.createElement("option");
	option.appendChild(document.createTextNode("Select Sub Folder")); 
	option.value="0";
	document.getElementById("ssub_id").appendChild(option);
	
	var allResult=CList.split("!#!#!");
	for (var i = 0; i < allResult.length-1; i++)
	{
		var result=allResult[i].split("!*!");    
		var sub_id = result[0];
		var sub_name = result[1];
		
		option=document.createElement("option");
		option.appendChild(document.createTextNode(sub_name)); 
		option.value=sub_id;
		
		
		document.getElementById("ssub_id").appendChild(option);
	} 
	
	document.getElementById("ssub_id").disabled = false;
	 
	
	
}
//---------------------------------------------------------------//

//---------------------- Popup Add Asset ------------------------//
function checkPopupAssetAddNew()
{
		var ref_orders = trim(document.getElementById("PopupAssetAddNew_ref_orders").value);
		var ref_sample = trim(document.getElementById("PopupAssetAddNew_ref_sample").value);
		
		if(trim(document.getElementById("PopupAssetAddNew_asset_file").value)=="" || trim(document.getElementById("PopupAssetAddNew_asset_name").value)=="" || document.getElementById("new_cat_id").value=="0")
		{
			document.getElementById("PopupAssetAddNew_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
			PopupAssetAddNew_ShowError();
		}
		else if(trim(document.getElementById("PopupAssetAddNew_asset_image").value)!="" && checkFileType_Jpeg(trim(document.getElementById("PopupAssetAddNew_asset_image").value))==false)
		{
			document.getElementById("PopupAssetAddNew_ErrorText").innerHTML = "Please check Thumbnail/Preview File you are trying to upload. JPG formats Only.";
			PopupAssetAddNew_ShowError();
		}
		else if(trim(document.getElementById("PopupAssetAddNew_asset_image").value)!="" && checkFileType_Jpeg(trim(document.getElementById("PopupAssetAddNew_asset_image").value))==true && checkFileNameForPhpThumb(trim(document.getElementById("PopupAssetAddNew_asset_image").value))==false)
		{
			document.getElementById("PopupAssetAddNew_ErrorText").innerHTML = "Only use these characters in the file name A to Z 0 to 9  _ ( ) - [ ]";
			PopupAssetAddNew_ShowError();
		}
		else if(ref_orders!="" && checkAssetRefOrders(ref_orders)==false)
		{
			document.getElementById("PopupAssetAddNew_ErrorText").innerHTML = "Please check CBD No.";
			PopupAssetAddNew_ShowError();
		}
		else if(ref_sample!="" && checkAssetRefSample(ref_sample)==false)
		{
			document.getElementById("PopupAssetAddNew_ErrorText").innerHTML = "Please check TT No.";
			PopupAssetAddNew_ShowError();
		}
		else
		{
			document.getElementById("PopupAssetAddNew_ErrorText").innerHTML = "Please wait...";
			PopupAssetAddNew_ShowSuccess();
			document.getElementById("XSave").value = "Save";
			
			
			
			document.getElementById("saveCommand").value = "SaveOnly";
			
			
			document.getElementById("PopupAssetAddNew_btnSaveOnly").disabled = true; 
			
			document.formPopupAssetAddNew.submit();
			
		}
		
		
		
		
		if(trim(document.getElementById("PopupAssetAddNew_asset_name").value)=="")
		{
			document.getElementById("PopupAssetAddNew_asset_name").className = "txtbox_error300";
		}
		else
		{
			document.getElementById("PopupAssetAddNew_asset_name").className = "txtbox300";
		}
		
		
		if(trim(document.getElementById("PopupAssetAddNew_asset_file").value)=="" )
		{
			document.getElementById("PopupAssetAddNew_asset_file").className = "table_error";
		}
		else
		{
			document.getElementById("PopupAssetAddNew_asset_file").className = "fake";
		}
		
		
		if(trim(document.getElementById("PopupAssetAddNew_asset_image").value)!="" && checkFileType_Jpeg(trim(document.getElementById("PopupAssetAddNew_asset_image").value))==false )
		{
			document.getElementById("PopupAssetAddNew_asset_image").className = "table_error";
		}
		else
		{
			document.getElementById("PopupAssetAddNew_asset_image").className = "fake";
		}
		
		if(trim(document.getElementById("PopupAssetAddNew_asset_image").value)!="" && checkFileType_Jpeg(trim(document.getElementById("PopupAssetAddNew_asset_image").value))==true  && checkFileNameForPhpThumb(trim(document.getElementById("PopupAssetAddNew_asset_image").value))==false)
		{
			document.getElementById("PopupAssetAddNew_asset_image").className = "table_error";
		}
		else
		{
			document.getElementById("PopupAssetAddNew_asset_image").className = "fake";
		}
		
		if(trim(document.getElementById("new_cat_id").value)=="0")
		{
			document.getElementById("tblCat").className = "table_error";
		}
		else
		{
			document.getElementById("tblCat").className = "";
		}
		
		if(ref_orders!="" && checkAssetRefOrders(ref_orders)==false)
		{
			document.getElementById("PopupAssetAddNew_ref_orders").className = "txtbox_error80";
		}
		else
		{
			document.getElementById("PopupAssetAddNew_ref_orders").className = "txtbox80";
		}
		
		if(ref_sample!="" && checkAssetRefSample(ref_sample)==false)
		{
			document.getElementById("PopupAssetAddNew_ref_sample").className = "txtbox_error80";
		}
		else
		{
			document.getElementById("PopupAssetAddNew_ref_sample").className = "txtbox80";
		}
		
}

function showPopupAssetAddNew()
{
	if(document.getElementById("PopupAssetAddNew"))
	{
		
		document.getElementById("PopupAssetAddNew_asset_file").className = "fake";
		document.getElementById("PopupAssetAddNew_asset_image").className = "fake";
		document.getElementById("PopupAssetAddNew_asset_name").className = "txtbox300";
		document.getElementById("tblCat").className = "";
		
		document.getElementById("PopupAssetAddNew_btnSaveOnly").disabled = false;
		//document.getElementById("PopupAssetAddNew_btnCancle").disabled = false;
		 
		document.getElementById("PopupAssetAddNew").style.display="";
		document.getElementById("PopupAssetAddNew").style.top="100px";
		document.getElementById("PopupAssetAddNew").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupAssetAddNew").style.zIndex=100;
		
	}
	
	
}

function hidePopupAssetAddNew()
{
	if(document.getElementById("PopupAssetAddNew"))
	{
			
		document.getElementById("PopupAssetAddNew_ShowError1").style.display="none";
		document.getElementById("PopupAssetAddNew_ShowError2").style.display="none";
		document.getElementById("PopupAssetAddNew").style.display="none";
	
	}
}

function PopupAssetAddNew_ShowError()
{
	
	
	document.getElementById("PopupAssetAddNew_ShowError1").style.display="";
	document.getElementById("PopupAssetAddNew_ShowError2").style.display="";
	document.getElementById("PopupAssetAddNew_ShowErrorBox").className = "mode_error";
	
}

function PopupAssetAddNew_ShowSuccess()
{
	document.getElementById("PopupAssetAddNew_ShowError1").style.display="";
	document.getElementById("PopupAssetAddNew_ShowError2").style.display="";
	document.getElementById("PopupAssetAddNew_ShowErrorBox").className = "mode_success";
	
}

function PopupAssetAddNew_CloseError()
{
	document.getElementById("PopupAssetAddNew_ShowError1").style.display="none";
	document.getElementById("PopupAssetAddNew_ShowError2").style.display="none";
	
	
}
//---------------------------------------------------------------//

//---------------------- Popup Edit Asset ------------------------//
function checkGetSubFromCat_edit()
{
	var cat_id = parseInt(document.getElementById("cat_id2").value);
	
	if(cat_id!=0)
	{
		getSubFromCat_edit(cat_id);
	}
	else
	{
		ClearChildNodes("sub_id2");
		option=document.createElement("option");
		option.appendChild(document.createTextNode("Select Sub Folder")); 
		option.value="0";
		document.getElementById("sub_id2").appendChild(option);
		document.getElementById("sub_id2").disabled = true;
	}
}

function getSubFromCat_edit(cat_id)
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_asset_get_sub.php?cat_id="+cat_id+"&user_id="+document.getElementById("user_id").value;  
			//removeCompanyContact();
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						if( CList!="No")
						{
							createSubIdList_edit(CList);
						}
						else
						{
							ClearChildNodes("sub_id2");
							option=document.createElement("option");
							option.appendChild(document.createTextNode("Select Sub Folder")); 
							option.value="0";
							document.getElementById("sub_id2").appendChild(option);
							document.getElementById("sub_id2").disabled = true;
						}
						
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}

function createSubIdList_edit(CList)
{
	ClearChildNodes("sub_id2");
	
	option=document.createElement("option");
	option.appendChild(document.createTextNode("Select Sub Folder")); 
	option.value="0";
	document.getElementById("sub_id2").appendChild(option);
	
	var allResult=CList.split("!#!#!");
	for (var i = 0; i < allResult.length-1; i++)
	{
		var result=allResult[i].split("!*!");    
		var sub_id = result[0];
		var sub_name = result[1];
		
		option=document.createElement("option");
		option.appendChild(document.createTextNode(sub_name)); 
		option.value=sub_id;
		
		
		
		document.getElementById("sub_id2").appendChild(option);
	} 
	
	document.getElementById("sub_id2").disabled = false;
	 
	
	
}

function getSubFromCat_edit_start(cat_id,id)
{
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_asset_get_sub.php?cat_id="+cat_id+"&user_id="+document.getElementById("user_id").value;  
			//removeCompanyContact();
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						if( CList!="No")
						{
							createSubIdList_edit_start(CList,id);
						}
						else
						{
							ClearChildNodes("sub_id2");
							option=document.createElement("option");
							option.appendChild(document.createTextNode("Select Sub Folder")); 
							option.value="0";
							document.getElementById("sub_id2").appendChild(option);
							document.getElementById("sub_id2").disabled = true;
						}
						
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
}

function createSubIdList_edit_start(CList,id)
{
	ClearChildNodes("sub_id2");
	
	temp_sub_id = document.getElementById("hid_sub_id"+id).value;
	
	option=document.createElement("option");
	option.appendChild(document.createTextNode("Select Sub Folder")); 
	option.value="0";
	document.getElementById("sub_id2").appendChild(option);
	
	var allResult=CList.split("!#!#!");
	for (var i = 0; i < allResult.length-1; i++)
	{
		var result=allResult[i].split("!*!");    
		var sub_id = result[0];
		var sub_name = result[1];
		
		option=document.createElement("option");
		option.appendChild(document.createTextNode(sub_name)); 
		option.value=sub_id;
		
		if(temp_sub_id==sub_id)
		{
			option.selected=true;
		}
		
		
		document.getElementById("sub_id2").appendChild(option);
	} 
	
	document.getElementById("sub_id2").disabled = false;
	 
	 
	
	
	
	
}

function checkPopupAssetEdit()
{
		if(trim(document.getElementById("PopupAssetEdit_asset_name").value)=="" || document.getElementById("cat_id2").value=="0")
		{
			document.getElementById("PopupAssetEdit_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
			PopupAssetEdit_ShowError();
		}
		else if(trim(document.getElementById("PopupAssetEdit_asset_image").value)!="" && checkFileType_Jpeg(trim(document.getElementById("PopupAssetEdit_asset_image").value))==false)
		{
			document.getElementById("PopupAssetEdit_ErrorText").innerHTML = "Please check Thumbnail/Preview File you are trying to upload. JPG formats Only.";
			PopupAssetEdit_ShowError();
		}
		else if(trim(document.getElementById("PopupAssetEdit_asset_image").value)!="" && checkFileType_Jpeg(trim(document.getElementById("PopupAssetEdit_asset_image").value))==true && checkFileNameForPhpThumb(trim(document.getElementById("PopupAssetEdit_asset_image").value))==false)
		{
			document.getElementById("PopupAssetEdit_ErrorText").innerHTML = "Only use these characters in the file name A to Z 0 to 9  _ ( ) - [ ]";
			PopupAssetEdit_ShowError();
		}
		else
		{
			document.getElementById("PopupAssetEdit_ErrorText").innerHTML = "Please wait...";
			PopupAssetEdit_ShowSuccess();
			document.getElementById("EXSave").value = "Edit";
			
			
			
			document.getElementById("saveCommand").value = "SaveOnly";
			
			
			document.getElementById("PopupAssetEdit_btnSaveOnly").disabled = true; 
			
			document.formPopupAssetEdit.submit();
			
		}
		
		
		
		
		if(trim(document.getElementById("PopupAssetEdit_asset_name").value)=="")
		{
			document.getElementById("PopupAssetEdit_asset_name").className = "txtbox_error300";
		}
		else
		{
			document.getElementById("PopupAssetEdit_asset_name").className = "txtbox300";
		}
		
				
		if(trim(document.getElementById("PopupAssetEdit_asset_image").value)!="" && checkFileType_Jpeg(trim(document.getElementById("PopupAssetEdit_asset_image").value))==false )
		{
			document.getElementById("PopupAssetEdit_asset_image").className = "table_error";
		}
		else
		{
			document.getElementById("PopupAssetEdit_asset_image").className = "fake";
		}
		
		if(trim(document.getElementById("PopupAssetEdit_asset_image").value)!="" && checkFileType_Jpeg(trim(document.getElementById("PopupAssetEdit_asset_image").value))==true  && checkFileNameForPhpThumb(trim(document.getElementById("PopupAssetEdit_asset_image").value))==false )
		{
			document.getElementById("PopupAssetEdit_asset_image").className = "table_error";
		}
		else
		{
			document.getElementById("PopupAssetEdit_asset_image").className = "fake";
		}
		
		if(trim(document.getElementById("cat_id2").value)=="0")
		{
			document.getElementById("tblCat").className = "table_error";
		}
		else
		{
			document.getElementById("tblCat").className = "";
		}
		
}

function showPopupAssetEdit(id)
{
	if(document.getElementById("PopupAssetEdit"))
	{
		document.getElementById("PopupAssetEdit_asset_id").value = document.getElementById("hid_asset_id"+id).value;
		
		document.getElementById("PopupAssetEdit_asset_file").className = "fake";
		document.getElementById("PopupAssetEdit_asset_image").className = "fake";
		document.getElementById("PopupAssetEdit_asset_name").className = "txtbox300";
		document.getElementById("tblCat").className = "";
		
		SelectOptionValue("cat_id2",document.getElementById("hid_cat_id"+id).value);
		
		getSubFromCat_edit_start(document.getElementById("hid_cat_id"+id).value,id);
		
		var fullURLAssetAddress = document.getElementById("fullURLAssetAddress").value;
		
		if(document.getElementById("hid_asset_file_old"+id).value!="")
		{
			document.getElementById("lbAssetFile").innerHTML =  fullURLAssetAddress+document.getElementById("hid_asset_file_old"+id).value+"<BR>";
			document.getElementById("PopupAssetEdit_old_asset_file").value = document.getElementById("hid_asset_file_old"+id).value;
			document.getElementById("PopupAssetEdit_old_asset_file_size").value = document.getElementById("hid_file_size_old"+id).value;
		}
		else
		{
			document.getElementById("lbAssetFile").innerHTML = "&nbsp;";
			document.getElementById("PopupAssetEdit_old_asset_file").value = "";
			document.getElementById("PopupAssetEdit_old_asset_file_size").value = "";
		}
		
		if(document.getElementById("hid_asset_image_old"+id).value!="")
		{
			document.getElementById("lbAssetImage").innerHTML =  fullURLAssetAddress+document.getElementById("hid_asset_image_old"+id).value+"<BR>";
			document.getElementById("PopupAssetEdit_old_asset_image").value = document.getElementById("hid_asset_image_old"+id).value;
		}
		else
		{
			document.getElementById("lbAssetImage").innerHTML = "&nbsp;";
			document.getElementById("PopupAssetEdit_old_asset_image").value = "";
		}
		
		document.getElementById("PopupAssetEdit_ref_product").value = document.getElementById("hid_ref_product"+id).value;
		document.getElementById("PopupAssetEdit_ref_orders").value = document.getElementById("hid_ref_orders"+id).value;
		document.getElementById("PopupAssetEdit_ref_sample").value = document.getElementById("hid_ref_sample"+id).value;
		document.getElementById("PopupAssetEdit_asset_name").value = document.getElementById("hid_asset_name"+id).value;
		document.getElementById("PopupAssetEdit_asset_keyword").value = document.getElementById("hid_asset_keyword_old"+id).value;
		document.getElementById("PopupAssetEdit_asset_desc").value = document.getElementById("hid_asset_desc_old"+id).value;
		document.getElementById("PopupAssetEdit_submit_no").value = document.getElementById("hid_submit_no"+id).value;
		document.getElementById("PopupAssetEdit_submit_by").value = document.getElementById("hid_submit_by"+id).value;
		if(document.getElementById("PopupAssetEdit_no_approve"))
		{
			document.getElementById("PopupAssetEdit_approve_status").value = document.getElementById("hid_approve_status_old"+id).value;
		}
		else
		{
			SelectOption("PopupAssetEdit_approve_status",document.getElementById("hid_approve_status"+id).value);
		}
		document.getElementById("PopupAssetEdit_approve_date").value = document.getElementById("hid_approve_date_old"+id).value;
		document.getElementById("PopupAssetEdit_approve_note").value = document.getElementById("hid_approve_note_old"+id).value;
		
		
		document.getElementById("PopupAssetEdit_btnSaveOnly").disabled = false;
		//document.getElementById("PopupAssetEdit_btnCancle").disabled = false;
		 
		document.getElementById("PopupAssetEdit").style.display="";
		document.getElementById("PopupAssetEdit").style.top=((getScrollY()+20))+"px";//document.getElementById("PopupAssetEdit").style.top=((100))+"px";
		document.getElementById("PopupAssetEdit").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupAssetEdit").style.zIndex=100;
		
	}
	
	
}

function hidePopupAssetEdit()
{
	if(document.getElementById("PopupAssetEdit"))
	{
			
		document.getElementById("PopupAssetEdit_ShowError1").style.display="none";
		document.getElementById("PopupAssetEdit_ShowError2").style.display="none";
		document.getElementById("PopupAssetEdit").style.display="none";
	
	}
}

function PopupAssetEdit_ShowError()
{
	
	
	document.getElementById("PopupAssetEdit_ShowError1").style.display="";
	document.getElementById("PopupAssetEdit_ShowError2").style.display="";
	document.getElementById("PopupAssetEdit_ShowErrorBox").className = "mode_error";
	
}

function PopupAssetEdit_ShowSuccess()
{
	document.getElementById("PopupAssetEdit_ShowError1").style.display="";
	document.getElementById("PopupAssetEdit_ShowError2").style.display="";
	document.getElementById("PopupAssetEdit_ShowErrorBox").className = "mode_success";
	
}

function PopupAssetEdit_CloseError()
{
	document.getElementById("PopupAssetEdit_ShowError1").style.display="none";
	document.getElementById("PopupAssetEdit_ShowError2").style.display="none";
	
	
}

function onFocusAssetOrders(obj)
{
	if(trim(obj.value)=="")
	{
		obj.value = "CBD";
	}
}

function onBlurAssetOrders(obj)
{
	if(trim(obj.value)=="CBD")
	{
		obj.value = "";
	}
}

function onFocusAssetSample(obj)
{
	if(trim(obj.value)=="")
	{
		obj.value = "TT";
	}
}

function onBlurAssetSample(obj)
{
	if(trim(obj.value)=="TT")
	{
		obj.value = "";
	}
}

function checkAssetRefOrders(ref)
{
	if(ref.length!=7)
	{
		return false;
	}
	else
	{
		return true;
	}
	
}

function checkAssetRefSample(ref)
{
	if(ref.length!=6)
	{
		return false;
	}
	else
	{
		return true;
	}
	
}
//---------------------------------------------------------------//

//------------------------- Pop Restore Asset -------------------//
function checkPopupAssetRestore()
{
	  if(document.getElementById("cat_id2").value=="0")
		{
			document.getElementById("PopupAssetRestore_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
			PopupAssetRestore_ShowError();
		}
		else
		{
			document.getElementById("PopupAssetRestore_ErrorText").innerHTML = "Please wait...";
			PopupAssetRestore_ShowSuccess();
			
			restoreAsset();
		}
		
		
		
		
				
		if(trim(document.getElementById("cat_id2").value)=="0")
		{
			document.getElementById("tblCat").className = "table_error";
		}
		else
		{
			document.getElementById("tblCat").className = "";
		}	
}

function restoreAsset()
{
	       var user_id = document.getElementById("user_id").value;
		   var asset_id = document.getElementById("currentAssetId").value;
		   var cat_id = document.getElementById("cat_id2").value;
		   var sub_id = document.getElementById("sub_id2").value;
		   
		   var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_asset_restore.php?asset_id="+asset_id+"&cat_id="+cat_id+"&sub_id="+sub_id+"&user_id="+user_id;  
	
			createXMLHttpRequest2();
			xmlHttp2.onreadystatechange = function () {
						if(xmlHttp2.readyState == 4) {
						if(xmlHttp2.status == 200) {
												
						CList = xmlHttp2.responseText;  
								//alert(CList)				 
						if(CList!=""  )
						{
							pageRefresh();
						 }
						 					
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp2.open("POST", url, true);
									 xmlHttp2.send(pBody);
}

function showPopupAssetRestore(obj,id)
{
	if(document.getElementById("PopupAssetRestore"))
	{
		document.getElementById("currentAssetId").value = document.getElementById("hid_asset_id"+id).value;
		
		
		SelectOptionValue("cat_id2",document.getElementById("hid_cat_id"+id).value);
		
		getSubFromCat_edit_start(document.getElementById("hid_cat_id"+id).value,id);
		
		
		document.getElementById("PopupAssetRestore_btnSaveOnly").disabled = false;
		//document.getElementById("PopupAssetRestore_btnCancle").disabled = false;
		
		var objTop = findPosY(obj);
		var objLeft = findPosX(obj);
		 
		document.getElementById("PopupAssetRestore").style.display="";
		document.getElementById("PopupAssetRestore").style.top=((getScrollY()+250))+"px";
		document.getElementById("PopupAssetRestore").style.left=((screen.width+300)*0.30)+"px";
		document.getElementById("PopupAssetRestore").style.zIndex=100;
		
	}
	
	
}

function hidePopupAssetRestore()
{
	if(document.getElementById("PopupAssetRestore"))
	{
			
		document.getElementById("PopupAssetRestore_ShowError1").style.display="none";
		document.getElementById("PopupAssetRestore_ShowError2").style.display="none";
		document.getElementById("PopupAssetRestore").style.display="none";
	
	}
}

function PopupAssetRestore_ShowError()
{
	
	
	document.getElementById("PopupAssetRestore_ShowError1").style.display="";
	document.getElementById("PopupAssetRestore_ShowError2").style.display="";
	document.getElementById("PopupAssetRestore_ShowErrorBox").className = "mode_error";
	
}

function PopupAssetRestore_ShowSuccess()
{
	document.getElementById("PopupAssetRestore_ShowError1").style.display="";
	document.getElementById("PopupAssetRestore_ShowError2").style.display="";
	document.getElementById("PopupAssetRestore_ShowErrorBox").className = "mode_success";
	
}

function PopupAssetRestore_CloseError()
{
	document.getElementById("PopupAssetRestore_ShowError1").style.display="none";
	document.getElementById("PopupAssetRestore_ShowError2").style.display="none";
	
	
}

//---------------------------------------------------------------//

//--------------- Popup User Meter Info -------------------------//
function showPopupUserMeterInfo(row_id,obj)
{
	if(document.getElementById("PopupUserMeterInfo"))
	{
		
		
		
		var arrName = (document.getElementById("UserOnLineRow_user_name"+row_id).value).split(" ");
		var userName =  arrName[0];
		var userOnlinePeriod =  document.getElementById("userOnlinePeriod").value;
		var ranking_group_day = document.getElementById("UserOnLineRow_ranking_group_day"+row_id).value ;
		var user_photo = document.getElementById("UserOnLineRow_user_photo"+row_id).value ;
		var user_online_status = document.getElementById("UserOnLineRow_status"+row_id).value ;
		var view_day0 = parseInt(document.getElementById("UserOnLineRow_view_0day"+row_id).value) ;
		var view_day1 = parseInt(document.getElementById("UserOnLineRow_view_1day"+row_id).value) ;
		var view_day2 = parseInt(document.getElementById("UserOnLineRow_view_2day"+row_id).value) ;
		var view_day3 = parseInt(document.getElementById("UserOnLineRow_view_3day"+row_id).value) ;
		var view_day4 = parseInt(document.getElementById("UserOnLineRow_view_4day"+row_id).value) ;
		var view_day5 = parseInt(document.getElementById("UserOnLineRow_view_5day"+row_id).value) ;
		var view_day6 = parseInt(document.getElementById("UserOnLineRow_view_6day"+row_id).value) ;
		var view_day7 = parseInt(document.getElementById("UserOnLineRow_view_7day"+row_id).value) ;
		
		var avgLast7DayCount = parseInt(document.getElementById("UserOnLineRow_avgLast7DayCount"+row_id).value) ;
		var avgLast30DayCount = parseInt(document.getElementById("UserOnLineRow_avgLast30DayCount"+row_id).value) ;
		var All3MonthCount = parseInt(document.getElementById("UserOnLineRow_All3MonthCount"+row_id).value) ;
		var All12MonthCount = parseInt(document.getElementById("UserOnLineRow_All12MonthCount"+row_id).value) ;
		
		var topModule1 = document.getElementById("UserOnLineRow_top_1module"+row_id).value ;
		var topModule2 = document.getElementById("UserOnLineRow_top_2module"+row_id).value ;
		var topModule3 = document.getElementById("UserOnLineRow_top_3module"+row_id).value ;
		var topModule4 = document.getElementById("UserOnLineRow_top_4module"+row_id).value ;
		
		var view_percent_day = parseInt(document.getElementById("UserOnLineRow_view_percent_day"+row_id).value) ;
		var view_week = parseInt(document.getElementById("UserOnLineRow_view_week"+row_id).value) ;
		var view_percent_week = parseInt(document.getElementById("UserOnLineRow_view_percent_week"+row_id).value) ;
		var user_id = parseInt(document.getElementById("UserOnLineRow_user_id"+row_id).value) ;
		
		
		var online_time = document.getElementById("UserOnLineRow_online_time"+row_id).value ;
		
		var userOnlineStatus_src = "images/icn_user_offline.png";
		if(user_online_status=="On")
		{
			userOnlineStatus_src = "images/icn_user_online.png";
		}
		
		/*var txtPageViewToday = "";
		if(view_day>1){txtPageViewToday += view_day+" pages visited today";}
		else{txtPageViewToday += view_day+" page visited today";}
		
		var txtPercentViewToday = view_percent_day+"% of everyone&rsquo;s";
		
		var txtPageViewWeek = "";
		if(view_week>1){txtPageViewWeek += view_week+" pages visited in last 14 days";}
		else{txtPageViewWeek += view_week+" page visited in last 14 days";}
		
		var txtPercentViewWeek = view_percent_week+"% of everyone&rsquo;s";
		*/
		
		document.getElementById("PopupUserMeterInfo_Name").innerHTML = document.getElementById("UserOnLineRow_user_name"+row_id).value;
		document.getElementById("PopupUserMeterInfo_HeadName").innerHTML = userName;
		//document.getElementById("PopupUserMeterInfo_meterOnline").innerHTML = getMeterOnline(ranking_group_day);
		document.getElementById("PopupUserMeterInfo_meterOnline").innerHTML = getMeterOnlineToday(online_time,view_day0);
		document.getElementById("PopupUserMeterInfo_user_photo").src = user_photo;
		document.getElementById("PopupUserMeterInfo_onlineStatus").src = userOnlineStatus_src;
		//document.getElementById("PopupUserMeterInfo_groupRankToday").innerHTML = getTextOnlineRankToday(ranking_group_day);
		
		if(view_day0!="0")
		{
			var txtClick0 = "clicks";
			if(view_day0=="1")
			{
				txtClick0 = "click";
			}
			document.getElementById("PopupUserMeterInfo_lbTodayView0").innerHTML  = view_day0+"&nbsp;"+txtClick0;
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_lbTodayView0").innerHTML  = "0 clicks";	
		}
		
		if(view_day1!="0")
		{
			var txtClick1 = "clicks";
			if(view_day1=="1")
			{
				txtClick1 = "click";
			}
			document.getElementById("PopupUserMeterInfo_lbTodayView1").innerHTML  = view_day1+"&nbsp;"+txtClick1;
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_lbTodayView1").innerHTML  = "0 clicks";	
		}
		
		if(view_day2!="0")
		{
			var txtClick2 = "clicks";
			if(view_day2=="1")
			{
				txtClick2 = "click";
			}
			document.getElementById("PopupUserMeterInfo_lbTodayView2").innerHTML  = view_day2+"&nbsp;"+txtClick2;
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_lbTodayView2").innerHTML  = "0 clicks";	
		}
		
		if(view_day3!="0")
		{
			var txtClick3 = "clicks";
			if(view_day3=="1")
			{
				txtClick3 = "click";
			}
			document.getElementById("PopupUserMeterInfo_lbTodayView3").innerHTML  = view_day3+"&nbsp;"+txtClick3;
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_lbTodayView3").innerHTML  = "0 clicks";	
		}
		
		if(view_day4!="0")
		{
			var txtClick4 = "clicks";
			if(view_day4=="1")
			{
				txtClick4 = "click";
			}
			document.getElementById("PopupUserMeterInfo_lbTodayView4").innerHTML  = view_day4+"&nbsp;"+txtClick4;
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_lbTodayView4").innerHTML  = "0 clicks";	
		}
		
		if(view_day5!="0")
		{
			var txtClick5 = "clicks";
			if(view_day5=="1")
			{
				txtClick5 = "click";
			}
			document.getElementById("PopupUserMeterInfo_lbTodayView5").innerHTML  = view_day5+"&nbsp;"+txtClick5;
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_lbTodayView5").innerHTML  = "0 clicks";	
		}
		
		if(view_day6!="0")
		{
			var txtClick6 = "clicks";
			if(view_day6=="1")
			{
				txtClick6 = "click";
			}
			document.getElementById("PopupUserMeterInfo_lbTodayView6").innerHTML  = view_day6+"&nbsp;"+txtClick6;
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_lbTodayView6").innerHTML  = "0 clicks";	
		}
		
		if(view_day7!="0")
		{
			var txtClick7 = "clicks";
			if(view_day7=="1")
			{
				txtClick7 = "click";
			}
			document.getElementById("PopupUserMeterInfo_lbTodayView7").innerHTML  = view_day7+"&nbsp;"+txtClick7;
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_lbTodayView7").innerHTML  = "0 clicks";	
		}
		
		if(avgLast7DayCount!="0")
		{
			var txtavgLast7DayCount = "clicks";
			if(avgLast7DayCount=="1")
			{
				txtavgLast7DayCount = "click";
			}
			document.getElementById("PopupUserMeterInfo_avgLast7DayCount").innerHTML  = avgLast7DayCount+"&nbsp;"+txtavgLast7DayCount;
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_avgLast7DayCount").innerHTML  = "0 clicks";	
		}
		
		if(avgLast30DayCount!="0")
		{
			var txtavgLast30DayCount = "clicks";
			if(avgLast30DayCount=="1")
			{
				txtavgLast30DayCount = "click";
			}
			document.getElementById("PopupUserMeterInfo_avgLast30DayCount").innerHTML  = avgLast30DayCount+"&nbsp;"+txtavgLast30DayCount;
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_avgLast30DayCount").innerHTML  = "0 clicks";	
		}
		
		if(All3MonthCount!="0")
		{
			var txtAll3MonthCount = "clicks";
			if(All3MonthCount=="1")
			{
				txtAll3MonthCount = "click";
			}
			document.getElementById("PopupUserMeterInfo_All3MonthCount").innerHTML  = All3MonthCount+"&nbsp;"+txtAll3MonthCount;
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_All3MonthCount").innerHTML  = "0 clicks";	
		}
		
		if(All12MonthCount!="0")
		{
			var txtAll12MonthCount = "clicks";
			if(All12MonthCount=="1")
			{
				txtAll12MonthCount = "click";
			}
			document.getElementById("PopupUserMeterInfo_All12MonthCount").innerHTML  = All12MonthCount+"&nbsp;"+txtAll12MonthCount;
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_All12MonthCount").innerHTML  = "0 clicks";	
		}
		
		
		
		
		if(topModule1!="")
		{
			document.getElementById("PopupUserMeterInfo_rowTopMain").style.display = "";
			document.getElementById("PopupUserMeterInfo_lbTopModule1").innerHTML  = topModule1;	
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_rowTopMain").style.display = "none";
		}
		
		if(topModule2!="")
		{
			document.getElementById("PopupUserMeterInfo_rowTop2").style.display = "";
			document.getElementById("PopupUserMeterInfo_lbTopModule2").innerHTML  = topModule2;	
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_rowTop2").style.display = "none";
		}
		
		if(topModule3!="")
		{
			document.getElementById("PopupUserMeterInfo_rowTop3").style.display = "";
			document.getElementById("PopupUserMeterInfo_lbTopModule3").innerHTML  = topModule3;	
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_rowTop3").style.display = "none";
		}
		
		if(topModule4!="")
		{
			document.getElementById("PopupUserMeterInfo_rowTop4").style.display = "";
			document.getElementById("PopupUserMeterInfo_lbTopModule4").innerHTML  = topModule4;	
		}
		else
		{
			document.getElementById("PopupUserMeterInfo_rowTop4").style.display = "none";
		}
		
		document.getElementById("PopupUserMeterInfo_online_time").innerHTML  = online_time;	
		
		
		//document.getElementById("PopupUserMeterInfo_percentViewToday").innerHTML  = txtPercentViewToday;
		//document.getElementById("PopupUserMeterInfo_pageViewWeek").innerHTML  = txtPageViewWeek;
		//document.getElementById("PopupUserMeterInfo_percentViewWeek").innerHTML  = txtPercentViewWeek;
		document.getElementById("PopupUserMeterInfo_linkSeeLog").innerHTML = "See "+userName+" &rsquo;s activities";
		document.getElementById("PopupUserMeterInfo_linkSeeLog").onclick = null;
		document.getElementById("PopupUserMeterInfo_linkSeeLog").onclick = function(){window.location="user_log_summary.php?user_id="+user_id;};
		
		
		var objTop = findPosY(obj);
		var objLeft = findPosX(obj);
		
		document.getElementById("PopupUserMeterInfo").style.display="";
		//document.getElementById("PopupUserMeterInfo").style.top=((screen.height-300)*0.35)+"px";
		//document.getElementById("PopupUserMeterInfo").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupUserMeterInfo").style.top=((objTop+20))+"px";
		document.getElementById("PopupUserMeterInfo").style.left=((objLeft-140))+"px";
		document.getElementById("PopupUserMeterInfo").style.zIndex=140;
		
		//hidePopupProductArtworkOption();
		
	}
	
	
}

function hidePopupUserMeterInfo()
{
	if(document.getElementById("PopupUserMeterInfo"))
	{
		document.getElementById("PopupUserMeterInfo").style.display="none";
	}
	
}

function getTextOnlineRankToday(groupRank)
{
	var txtRankToday = "&nbsp;";
	var userOnlinePeriod =  document.getElementById("userOnlinePeriod").value;
	
	switch(groupRank)
	{
		case "1": txtRankToday ="Top "+userOnlinePeriod+" most active user today";break;
		case "2": txtRankToday ="Active user today";break;
		case "3": txtRankToday ="Moderate user today";break;
		case "4": txtRankToday ="Light user today";break;
		case "5": txtRankToday ="Bottom "+userOnlinePeriod+" least active user today";break;
		default: txtRankToday = "&nbsp;";break;		
	}
		
		return txtRankToday;
	
}
function getMeterOnline(groupRank)
{
	var txtMeter = "&nbsp;";
	
	switch(groupRank)
	{
		case "1": txtMeter ="<img src='images/icn_online_meter5.gif'/> <img src='images/icn_online_meter4.gif'/> <img src='images/icn_online_meter3.gif'/> <img src='images/icn_online_meter2.gif'/> <img src='images/icn_online_meter1.gif'/>";break;
		case "2": txtMeter ="<img src='images/icn_online_meter5.gif'/> <img src='images/icn_online_meter4.gif'/> <img src='images/icn_online_meter3.gif'/> <img src='images/icn_online_meter2.gif'/>";break;
		case "3": txtMeter ="<img src='images/icn_online_meter5.gif'/> <img src='images/icn_online_meter4.gif'/> <img src='images/icn_online_meter3.gif'/>";break;
		case "4": txtMeter ="<img src='images/icn_online_meter5.gif'/> <img src='images/icn_online_meter4.gif'/>";break;
		case "5": txtMeter ="<img src='images/icn_online_meter5.gif'/>";break;
		default: txtMeter = "&nbsp;";break;		
	}
		
		return txtMeter;
}

function getMeterOnlineToday(onlineDate,todayClick)
{
	var today = document.getElementById("todayDate").value;
	var txtMeter = "&nbsp;";
	var txtClick = " clicks";
	
	if(todayClick=="1")
	{
		txtClick = " click";
	}
	
	if(onlineDate==today)
	{
		txtMeter ="<img src='images/icn_online_meter1.gif'/>&nbsp;&nbsp;<label class='txt11_333'>"+todayClick+txtClick+"</label>";
	}
	
	return txtMeter;
}

//---------------------------------------------------------------//

//---------------- Popup Info Order ---------------------------//

function showPopupOrderInfo(order_id,obj)
{
	if(document.getElementById("PopupOrderInfo"))
	{
		
	
		var order_no = document.getElementById("order_order_no"+order_id).value;
		var sop_no = document.getElementById("order_sop_no"+order_id).value;
		var customer_po_no = document.getElementById("order_customer_po_no"+order_id).value ;
		var shipment_no = document.getElementById("order_shipment_no"+order_id).value ;
		var release_status = document.getElementById("order_release_status"+order_id).value ;
		var ship_method = document.getElementById("order_ship_method"+order_id).value ;
		var cartons = document.getElementById("order_cartons"+order_id).value ;
		var weight = document.getElementById("order_weight"+order_id).value ;
		var volume = document.getElementById("order_volume"+order_id).value ;
		var contact_name = document.getElementById("order_contact_name"+order_id).value ;
		var contact_email = document.getElementById("order_contact_email"+order_id).value ;
		var contact_telephone = document.getElementById("order_contact_telephone"+order_id).value ;
		var contact_fax = document.getElementById("order_contact_fax"+order_id).value ;
		
		
		document.getElementById("PopupOrderInfo_HeadName").innerHTML = order_no; 		
		
		if(sop_no!="")
		{
			document.getElementById("PopupOrderInfo_lb_sop_no").className = "txt11_333_b";
			document.getElementById("PopupOrderInfo_sop_no").innerHTML = sop_no;
		}
		else
		{
			document.getElementById("PopupOrderInfo_lb_sop_no").className = "txt11_ccc_b";
			document.getElementById("PopupOrderInfo_sop_no").innerHTML = "&nbsp;";
		}
		
		if(customer_po_no!="")
		{
			document.getElementById("PopupOrderInfo_lb_customer_po_no").className = "txt11_333_b";
			document.getElementById("PopupOrderInfo_customer_po_no").innerHTML = customer_po_no;
		}
		else
		{
			document.getElementById("PopupOrderInfo_lb_customer_po_no").className = "txt11_ccc_b";
			document.getElementById("PopupOrderInfo_customer_po_no").innerHTML = "&nbsp;";
		}
		
		if(shipment_no!="")
		{
			document.getElementById("PopupOrderInfo_lb_shipment_no").className = "txt11_333_b";
			document.getElementById("PopupOrderInfo_shipment_no").innerHTML = shipment_no;
		}
		else
		{
			document.getElementById("PopupOrderInfo_lb_shipment_no").className = "txt11_ccc_b";
			document.getElementById("PopupOrderInfo_shipment_no").innerHTML = "&nbsp;";
		}
		
		if(release_status!="")
		{
			document.getElementById("PopupOrderInfo_lb_release_status").className = "txt11_333_b";
			document.getElementById("PopupOrderInfo_release_status").innerHTML = release_status;
		}
		else
		{
			document.getElementById("PopupOrderInfo_lb_release_status").className = "txt11_ccc_b";
			document.getElementById("PopupOrderInfo_release_status").innerHTML = "&nbsp;";
		}
		
		if(ship_method!="")
		{
			document.getElementById("PopupOrderInfo_lb_ship_method").className = "txt11_333_b";
			document.getElementById("PopupOrderInfo_ship_method").innerHTML = ship_method;
		}
		else
		{
			document.getElementById("PopupOrderInfo_lb_ship_method").className = "txt11_ccc_b";
			document.getElementById("PopupOrderInfo_ship_method").innerHTML = "&nbsp;";
		}
		
		if(cartons!="")
		{
			document.getElementById("PopupOrderInfo_lb_cartons").className = "txt11_333_b";
			document.getElementById("PopupOrderInfo_cartons").innerHTML = cartons;
		}
		else
		{
			document.getElementById("PopupOrderInfo_lb_cartons").className = "txt11_ccc_b";
			document.getElementById("PopupOrderInfo_cartons").innerHTML = "&nbsp;";
		}
		
		if(weight!="")
		{
			document.getElementById("PopupOrderInfo_lb_weight").className = "txt11_333_b";
			document.getElementById("PopupOrderInfo_weight").innerHTML = weight+" kg";
		}
		else
		{
			document.getElementById("PopupOrderInfo_lb_weight").className = "txt11_ccc_b";
			document.getElementById("PopupOrderInfo_weight").innerHTML = "&nbsp;";
		}
		
		if(volume!="")
		{
			document.getElementById("PopupOrderInfo_lb_volume").className = "txt11_333_b";
			document.getElementById("PopupOrderInfo_volume").innerHTML = volume+" CuM";
		}
		else
		{
			document.getElementById("PopupOrderInfo_lb_volume").className = "txt11_ccc_b";
			document.getElementById("PopupOrderInfo_volume").innerHTML = "&nbsp;";
		}
		
		if(contact_name!="")
		{
			document.getElementById("PopupOrderInfo_contact_name").innerHTML = contact_name;
			
			if(contact_email!="" && checkEmailSyntax(contact_email))
			{
				document.getElementById("PopupOrderInfo_contact_name").href = "mailto:"+contact_email;
			}
			
		}
		else
		{
			document.getElementById("PopupOrderInfo_contact_name").innerHTML = "&nbsp;";
		}
		
				
		if(contact_telephone!="")
		{
			document.getElementById("PopupOrderInfo_lb_contact_telephone").className = "txt11_333_b";
			document.getElementById("PopupOrderInfo_contact_telephone").innerHTML = contact_telephone;
		}
		else
		{
			document.getElementById("PopupOrderInfo_lb_contact_telephone").className = "txt11_ccc_b";
			document.getElementById("PopupOrderInfo_contact_telephone").innerHTML = "&nbsp;";
		}
		
		if(cartons!="")
		{
			document.getElementById("PopupOrderInfo_lb_contact_fax").className = "txt11_333_b";
			document.getElementById("PopupOrderInfo_contact_fax").innerHTML = contact_fax;
		}
		else
		{
			document.getElementById("PopupOrderInfo_lb_contact_fax").className = "txt11_ccc_b";
			document.getElementById("PopupOrderInfo_contact_fax").innerHTML = "&nbsp;";
		}
		
		document.getElementById("CusCo"+order_id).style.background = "#ffff99";
		document.getElementById("OrderCo"+order_id).style.background = "#ffff99";
		document.getElementById("ControlCo"+order_id).style.background = "#ffff99";
		 
		var objTop = findPosY(obj);
		var objLeft = findPosX(obj);
		
		document.getElementById("PopupOrderInfo").style.display="";
		document.getElementById("PopupOrderInfo").style.top=(parseInt(objTop)+25)+"px";
		document.getElementById("PopupOrderInfo").style.left=((objLeft-220))+"px";
		document.getElementById("PopupOrderInfo").style.zIndex=140;
		
		//hidePopupProductArtworkOption();
		
	}
	
	
}
function hidePopupOrderInfo(order_id)
{
	if(document.getElementById("PopupOrderInfo"))
	{
		document.getElementById("CusCo"+order_id).style.background = "";
		document.getElementById("OrderCo"+order_id).style.background = "";
		document.getElementById("ControlCo"+order_id).style.background = "";
		
		document.getElementById("PopupOrderInfo").style.display="none";
		
	}
	
}

//------------------------------------------------------------//

//---------------- Popup User Edit Role ----------------//

function checkPopupUserEditRole()
{
	if(trim(document.getElementById("PopupUserEditRole_role_text").value)=="")
	{
		document.getElementById("PopupUserEditRole_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
		PopupUserEditRole_ShowError();
	}
	else
	{
			PopupUserEditRole_ShowSuccess();
			document.getElementById("PopupUserEditRole_ErrorText").innerHTML = "Please wait...";
			document.getElementById("PopupUserEditRole_btnSave").disabled = true;
			document.getElementById("PopupUserEditRole_btnCancel").disabled = true;
			editUserRole();
	}
	
	if(trim(document.getElementById("PopupUserEditRole_role_text").value)=="")
	{
		document.getElementById("PopupUserEditRole_role_text").className="txtbox_error180";
	}
	else
	{
		document.getElementById("PopupUserEditRole_role_text").className="txtbox180";	
	}
	
	
	//window.location = document.getElementById("PopupUserEditRole_linkValue").value;
	
}

function editUserRole()
{
	       var user_id = document.getElementById("user_id").value;
		   var role_id = document.getElementById("PopupUserEditRole_role_id").value;
		   var role_name = document.getElementById("PopupUserEditRole_role_text").value;
		   
		   var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_user_edit_role.php?role_id="+role_id+"&role_name="+role_name+"&user_id="+user_id;  
	
			createXMLHttpRequest2();
			xmlHttp2.onreadystatechange = function () {
						if(xmlHttp2.readyState == 4) {
						if(xmlHttp2.status == 200) {
												
						CList = xmlHttp2.responseText;  
								//alert(CList)				 
						if(CList!="" && CList!="No" )
						{
							//CreateUserRole(CList,'0',"Edit");
							
							var indexValue = getIndexValueFromValue("role_id",role_id);
							document.getElementById("role_id")[indexValue].text = role_name;
							hidePopupUserEditRole();
						 }
						 					
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp2.open("POST", url, true);
									 xmlHttp2.send(pBody);
}

function getAlluserRole(temp_role,type)
{
	        var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_user_get_all_role.php";  
	
			createXMLHttpRequest2();
				xmlHttp2.onreadystatechange = function () {
						if(xmlHttp2.readyState == 4) {
						if(xmlHttp2.status == 200) {
												
						CList = xmlHttp2.responseText;  
								//alert(CList)				 
						if(CList!="" && CList!="No" )
						{
							if(type=="EditOld")
							{
							    CreateUserRole(CList,temp_role,"Edit");
								CreateUserRole(CList,temp_role,"Old");
							}
							else
							{
								CreateUserRole(CList,temp_role,type);  	
							}
						 }
						 					
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp2.open("POST", url, true);
									 xmlHttp2.send(pBody);
}

function CreateUserRole(CList,temp_role,type)
{
	//ClearChildNodes("role_id");
	if(type=="Edit")
	{
		ClearChildNodes("PopupUserEditRole_role_id");
		option=document.createElement("option");
	    option.appendChild(document.createTextNode("Please Select Role")); 
	    option.value="0";
	    document.getElementById("PopupUserEditRole_role_id").appendChild(option);
	}
	
	if(type=="Old")
	{
		ClearChildNodes("role_id");
		option=document.createElement("option");
	    option.appendChild(document.createTextNode("Please Select Role")); 
	    option.value="0";
	    document.getElementById("role_id").appendChild(option);
	}
	
	 
	
	var allResult=CList.split("!#!#!");
	for (var i = 0; i < allResult.length-1; i++)
	{
		var result=allResult[i].split("!*!");    
		var role_id = result[0];
		var role_name = result[1];
		
		option = document.createElement("option");
		option.appendChild(document.createTextNode(role_name)); 
		option.value = role_id;
		
		if(role_id==temp_role)
		{
			option.selected = true;
		}
		
		
		if(type=="Edit")
		{
		   document.getElementById("PopupUserEditRole_role_id").appendChild(option);
		}
		
		if(type=="Old")
		{
		   document.getElementById("role_id").appendChild(option);
		}
		
	} 
	
	 
	 
	 
	 
	if(type=="Edit")
	{
		showPopupUserEditRole(temp_role);
	}
	
	
}

function changePopupUserRole()
{
		if(document.getElementById("PopupUserEditRole_role_id").value!="0")
		{
		   document.getElementById("PopupUserEditRole_role_text").value = getOptionTextFromValue("PopupUserEditRole_role_id",document.getElementById("PopupUserEditRole_role_id").value);
		   document.getElementById("PopupUserEditRole_btnSave").disabled = false;
		   document.getElementById("PopupUserEditRole_role_text").disabled = false;
		   document.getElementById("PopupUserEditRole_lb_delete").style.display = "";
		   
		}
		else
		{
			document.getElementById("PopupUserEditRole_role_text").value = "";
			document.getElementById("PopupUserEditRole_btnSave").disabled = true;
			document.getElementById("PopupUserEditRole_role_text").disabled = true;
			document.getElementById("PopupUserEditRole_lb_delete").style.display = "none";
		}
}

function deleteUserRoleEdit(value)
{
	if(value==true)
	{
			
			var role_name = getOptionTextFromValue("PopupUserEditRole_role_id",document.getElementById("PopupUserEditRole_role_id").value);
			
			var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_delete_user_role.php?role_id="+document.getElementById("PopupUserEditRole_role_id").value+"&role_name="+role_name+"&user_id="+document.getElementById("user_id").value;  
	
			createXMLHttpRequest();
				xmlHttp.onreadystatechange = function () {
						if(xmlHttp.readyState == 4) {
						if(xmlHttp.status == 200) {
												
						CList = xmlHttp.responseText;  
								//alert(CList)				 
						 
						 if(CList!="No")
						 {
							
							getAlluserRole(document.getElementById("old_role_id").value,'EditOld');
							//getAlluserRole('0','Edit');
							hidePopupConfirmBox();
						 }
						
						 
												
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp.open("POST", url, true);
									 xmlHttp.send(pBody); 
	}
	else
	{
		hidePopupConfirmBox();
		showPopupUserEditRole(document.getElementById("PopupUserEditRole_role_id").value);
	}
}

function showPopupUserEditRole(temp_role)
{
	if(document.getElementById("PopupUserEditRole"))
	{
		
		document.getElementById("PopupUserEditRole_role_text").value = getOptionTextFromValue("PopupUserEditRole_role_id",temp_role);
		
		if(document.getElementById("PopupUserEditRole_role_id").value=="0")
		{
			
		   document.getElementById("PopupUserEditRole_btnSave").disabled = true;
		   document.getElementById("PopupUserEditRole_role_text").disabled = true;
		   document.getElementById("PopupUserEditRole_lb_delete").style.display = "none";
		}
		else
		{
		   document.getElementById("PopupUserEditRole_btnSave").disabled = false;
		   document.getElementById("PopupUserEditRole_role_text").disabled = false;
		   document.getElementById("PopupUserEditRole_lb_delete").style.display = "";	
		}
		
		document.getElementById("PopupUserEditRole_btnCancel").disabled = false;
		document.getElementById("PopupUserEditRole").style.display="";
		document.getElementById("PopupUserEditRole").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupUserEditRole").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupUserEditRole").style.zIndex=140;
	}
}

function hidePopupUserEditRole()
{
	if(document.getElementById("PopupUserEditRole"))
	{
		
		
		document.getElementById("PopupUserEditRole_ShowError1").style.display="none";
		document.getElementById("PopupUserEditRole_ShowError2").style.display="none";
		document.getElementById("PopupUserEditRole").style.display="none";
	}
	
}



function PopupUserEditRole_ShowError()
{
	document.getElementById("PopupUserEditRole_ShowError1").style.display="";
	document.getElementById("PopupUserEditRole_ShowError2").style.display="";
	document.getElementById("PopupUserEditRole_ShowErrorBox").className = "mode_error";
	
}

function PopupUserEditRole_ShowSuccess()
{
	document.getElementById("PopupUserEditRole_ShowError1").style.display="";
	document.getElementById("PopupUserEditRole_ShowError2").style.display="";
	document.getElementById("PopupUserEditRole_ShowErrorBox").className ="mode_success";
	
}

function PopupUserEditRole_CloseError()
{
	document.getElementById("PopupUserEditRole_ShowError1").style.display="none";
	document.getElementById("PopupUserEditRole_ShowError2").style.display="none";
	
	
}

function checkPopupUserAddRole()
{
	if(trim(document.getElementById("PopupUserAddRole_role_text").value)=="")
	{
		document.getElementById("PopupUserAddRole_ErrorText").innerHTML = "All fields highlighted in red below must be entered.";
		PopupUserAddRole_ShowError();
	}
	else
	{
			PopupUserAddRole_ShowSuccess();
			document.getElementById("PopupUserAddRole_ErrorText").innerHTML = "Please wait...";
			document.getElementById("PopupUserAddRole_btnSave").disabled = true;
			document.getElementById("PopupUserAddRole_btnCancel").disabled = true;
			addUserRole();
	}
	
	if(trim(document.getElementById("PopupUserAddRole_role_text").value)=="")
	{
		document.getElementById("PopupUserAddRole_role_text").className="txtbox_error180";
	}
	else
	{
		document.getElementById("PopupUserAddRole_role_text").className="txtbox180";	
	}
	
	
	
	
}

function addUserRole()
{
	       var user_id = document.getElementById("user_id").value;
		   var role_name = document.getElementById("PopupUserAddRole_role_text").value;
		   
		   var pForm = document.forms[0];
			var pBody = getRequestBody(pForm);
			var url = "arena_lib/ajax/ajax_user_add_role.php?role_name="+role_name+"&user_id="+user_id;  
	
			createXMLHttpRequest2();
			xmlHttp2.onreadystatechange = function () {
						if(xmlHttp2.readyState == 4) {
						if(xmlHttp2.status == 200) {
												
						CList = xmlHttp2.responseText;  
								//alert(CList)				 
						if(CList!="" && CList!="No" )
						{
							
							
							//var indexValue = getIndexValueFromValue("role_id",role_id);
							//document.getElementById("role_id")[indexValue].text = role_name;
							var role_id = CList;
							
							option = document.createElement("option");
							option.appendChild(document.createTextNode(role_name)); 
							option.value = role_id;
							option.selected = true;
							
							document.getElementById("role_id").appendChild(option);
							
							hidePopupUserAddRole();
						 }
						 					
							
							}
								else {
										alert("Network Error.Please try again.");
									 }
							}
						}
									 xmlHttp2.open("POST", url, true);
									 xmlHttp2.send(pBody);
}


function showPopupUserAddRole()
{
	if(document.getElementById("PopupUserAddRole"))
	{
		
		document.getElementById("PopupUserAddRole_role_text").value = "";
		
		document.getElementById("PopupUserAddRole_btnSave").disabled = false;
		document.getElementById("PopupUserAddRole_btnCancel").disabled = false;
		document.getElementById("PopupUserAddRole").style.display="";
		document.getElementById("PopupUserAddRole").style.top=((screen.height-200)*0.35)+"px";
		document.getElementById("PopupUserAddRole").style.left=((screen.width+200)*0.30)+"px";
		document.getElementById("PopupUserAddRole").style.zIndex=140;
	}
}

function hidePopupUserAddRole()
{
	if(document.getElementById("PopupUserAddRole"))
	{
		
		
		document.getElementById("PopupUserAddRole_ShowError1").style.display="none";
		document.getElementById("PopupUserAddRole_ShowError2").style.display="none";
		document.getElementById("PopupUserAddRole").style.display="none";
	}
	
}



function PopupUserAddRole_ShowError()
{
	document.getElementById("PopupUserAddRole_ShowError1").style.display="";
	document.getElementById("PopupUserAddRole_ShowError2").style.display="";
	document.getElementById("PopupUserAddRole_ShowErrorBox").className = "mode_error";
	
}

function PopupUserAddRole_ShowSuccess()
{
	document.getElementById("PopupUserAddRole_ShowError1").style.display="";
	document.getElementById("PopupUserAddRole_ShowError2").style.display="";
	document.getElementById("PopupUserAddRole_ShowErrorBox").className ="mode_success";
	
}

function PopupUserAddRole_CloseError()
{
	document.getElementById("PopupUserAddRole_ShowError1").style.display="none";
	document.getElementById("PopupUserAddRole_ShowError2").style.display="none";
	
	
}

//-------------------------------------------------------------//


//--------------------- Web -------------------------------//
function clickCategoryWebToggle(spnSubName,subItem,subNavSign)
{
	//alert(spnSubName)
	if($(jq(subItem)).is(':visible') )
	{
        if(document.getElementById(subNavSign))
		{
			document.getElementById(subNavSign).className='Toggle';
		}
		
		
     }
	 else
	 {
	 	 if(document.getElementById(subNavSign))
		 {
		 	document.getElementById(subNavSign).className='ToggleClick';
		 }
		 
		
		 
	 }
	   
	$(jq(subItem)).slideToggle('medium');
	
   
}

function clickCharacterWebToggle(spnSubName,subItem,subNavSign)
{
	//alert(spnSubName)
	if($(jq(subItem)).is(':visible') )
	{
        if(document.getElementById(subNavSign))
		{
			document.getElementById(subNavSign).className='Toggle';
		}
		
		
     }
	 else
	 {
	 	 if(document.getElementById(subNavSign))
		 {
		 	document.getElementById(subNavSign).className='ToggleClick';
		 }
		 
		
		 
	 }
	   
	$(jq(subItem)).slideToggle('medium');
	
   
}

function clickShowAllCharacterWebToggle(subItemNew,subItemOld)
{
	
	document.getElementById(subItemOld).style.display = "none";   
	$(jq(subItemNew)).slideToggle('medium');
	
	document.getElementById("aChaExpand").onclick = null;
	document.getElementById("aChaExpand").onclick = function(){clickCharacterWebToggle('spnSubNameCha','UlChaPens','subNavSignCha');return false;};
	
   
}

function clickProductDisplayBokToggle(targetItem,targetSign)
{
	//alert(spnSubName)
	var dCount = parseInt(document.getElementById("countAllProductDisplay").value);
	for(i=1;i<=dCount;i++)
	{
		document.getElementById("displayBox"+i).style.display = "none";	
		document.getElementById("displayArrow"+i).src = 'images/img_arrow_down_gray1.gif';
	}
	
	if($(jq(targetItem)).is(':visible') )
	{
        if(document.getElementById(targetSign))
		{
			document.getElementById(targetSign).src = 'images/img_arrow_down_gray1.gif';
		}
		
		
     }
	 else
	 {
	 	 if(document.getElementById(targetSign))
		 {
		 	document.getElementById(targetSign).src = 'images/img_arrow_down_gray2.gif';
		 }
		 
		
		 
	 }
	   
	document.getElementById(targetItem).style.display = "";   
	
	
   
}

function changeMainProductPhoto(photo)
{
	document.getElementById("mainPhoto").src = "file/photo/"+photo;  	
}

function closeAllDisplayBox()
{
	var dCount = parseInt(document.getElementById("countAllProductDisplay").value);
	for(i=1;i<=dCount;i++)
	{
		document.getElementById("displayBox"+i).style.display = "none";	
		document.getElementById("displayArrow"+i).src = 'images/img_arrow_down_gray1.gif';
	} 	
}


//----------------------------------------------------------//

//------------------------- Web Popup Sub Cat Menu ---------------------------//
function showPopupWebBrowswByChar()
{
	//document.getElementById("webSubCatMenu").style.display = "";
	document.getElementById("webMainMenuBrowswChar").src = "images/img_menu_browse_char2.jpg"
	
	$(jq("webBrowswByChar")).slideToggle('fast');
}
function hidePopupWebBrowswByChar()
{
	//document.getElementById("webSubCatMenu").style.display = "";	
	document.getElementById("webMainMenuBrowswChar").src = "images/img_menu_browse_char1.jpg"
	$(jq("webBrowswByChar")).slideToggle('fast');
}

var timePopupWebBrowswByChar;

function autoHidePopupWebBrowswByChar()
{
	timePopupWebBrowswByChar = setTimeout("hidePopupWebBrowswByChar();",500);
}

function clearAutoHidePopupWebBrowswByChar()
{
    clearTimeout(timePopupWebBrowswByChar);
}

function checkWebSignUpNewsletter()
{
	
	if(checkEmailSyntax(trim(document.getElementById("newsletterText").value)))
	{
		sendDataToCampaignMonitor();
	}
	else
	{
		webSignUpNewsletterError();
	}
}

function webSignUpNewsletterSuccess()
{
    document.getElementById("newsletterText").style.color = "#006633";
	document.getElementById("newsletterText").style.fontWeight = "bold";
	var TextX = "Thank You For Sign Up";
	var progress=0;
	var timer = setInterval(function() 
									 {progress++;
                 document.getElementById("newsletterText").value = (TextX.substring(0, progress) + (progress < TextX.length ? '_' : ''));
                if (progress >= TextX.length) {clearInterval(timer);setTimeout("clearNewsletterEmailField();",500);}
            }, 70);
	
	document.getElementById("newsletterText").value = document.getElementById("newsletterText").value.substring(0, document.getElementById("newsletterText").value.length-1);
	
	
}

function webSignUpNewsletterError()
{
    document.getElementById("newsletterText").style.color = "#c00";
	document.getElementById("newsletterText").style.fontWeight = "bold";
	var TextX = "Please enter a valid email";
	var progress=0;
	var timer = setInterval(function() 
									 {progress++;
                 document.getElementById("newsletterText").value = (TextX.substring(0, progress) + (progress < TextX.length ? '_' : ''));
                if (progress >= TextX.length) {clearInterval(timer);setTimeout("clearNewsletterEmailField();",500);}
            }, 50);
	
	document.getElementById("newsletterText").value = document.getElementById("newsletterText").value.substring(0, document.getElementById("newsletterText").value.length-1);
	
	
}



function clearNewsletterEmailField()
{
   document.getElementById("newsletterText").value = "";
   document.getElementById("newsletterText").style.color = "#333";
   document.getElementById("newsletterText").style.fontWeight = "normal";
}

function sendDataToCampaignMonitor()
{
	window.frames['editframe'].document.getElementById('nkjhjy-nkjhjy').value = document.getElementById("newsletterText").value; 
	submitForm();
	webSignUpNewsletterSuccess();
	document.getElementById("btnSubmitNewsletter").onclick = null;
}

function showWebHeadComInfo()
{
	var objPosX = 	findPosX(document.getElementById("webHeadComInfo"));
	var objPosY = 	findPosY(document.getElementById("webHeadComInfo"));
	
	document.getElementById("webHeadComInfoMenu").style.left = (objPosX-9)+"px";
	document.getElementById("webHeadComInfoMenu").style.top = (objPosY-3)+"px";
	$(jq("webHeadComInfoMenu")).slideToggle('fast');
}

function hideWebHeadComInfo()
{
	$(jq("webHeadComInfoMenu")).slideToggle(200);
}
							


//-------------------------------------------------------------//
