function switchDisplay(id,imgsrc,mainimage)
{
	ctrl = document.getElementById(id);
		
	if (ctrl.style.display == "")
	{
		if(mainimage.name != '')
		{
			mainimage.src = "images/plus.gif";
			ctrl.style.display = "none";
		}
	}
	else
	{
		if(mainimage.name != '')
		{
			ctrl.style.display = "";
			mainimage.src="images/minus.gif";
		}
	}	
	//Close all other menu items
	var catids = document.getElementById('catids');
	catids = catids.value.split(",");
	var len = catids.length;
	for(var i=0;i<len;i++)
		if(catids[i]!=id)
		{
			menuItem = document.getElementById(catids[i]);
			menuItem.style.display="none";
			menuImageItem = document.getElementById("img"+catids[i]);
			menuImageItem.src = "images/plus.gif";
		}
}

function Scroller_onmouseover(id)
{
	id.scrollAmount =0;
}

function Scroller_onmouseout(id)
{
	id.scrollAmount =1;
}

function emailCheck (emailStr) {
	
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		return false
	}
	
	var user=matchArray[1]
	var domain=matchArray[2]

	if (user.match(userPat)==null) {
    	return false
	}

	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
		  	if (IPArray[i]>255) {
		  		return false
		  	}
		}
	   return true
	}

	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		return false
	}

	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
   	return false
	}

	if (len<2) {
	   return false
	}
	
	return true;
}
function go(form) 
{
	var URL = form.selectmenu.value;
	if ( URL != "")
	{
		window.open(URL, '_blank');
		return false;
	}
	else
		return false;
}

function hienmenu(id)
{
	ctrl = document.getElementById(id);
	if (ctrl.style.display == "")
		ctrl.style.display = "none";
	else
		ctrl.style.display = "";
}

function search(url, lang) {
	var billing_no = document.getElementById("txtBillingNo").value;
	var containter_no = document.getElementById("txtContainerNo").value;
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("get", "./includes/index.php?act="+url+"&billing_no="+escape(billing_no)+"&containter_no="+escape(containter_no)+"&lang="+escape(lang), true);
    oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                display_cargo(oXmlHttp.responseText);
            } else {
                display_cargo("An error occurred: " + oXmlHttp.statusText); //statusText is not always accurate
            }
        }            
    };
    oXmlHttp.send(null);
}

function display_cargo(sText) {
    var divContent = document.getElementById("show_cargo");
    divContent.innerHTML = sText;
}


//Ajax for display area of business
function request(url) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("get", "./includes/index.php?act="+url, true);
    display_content('<center><img src="./images/loading.gif" border="0" style="margin:30px"></center>');
    oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                display_content(oXmlHttp.responseText);
            } else {
                display_content("An error occurred: " + oXmlHttp.statusText); //statusText is not always accurate
            }
        }            
    };
    oXmlHttp.send(null);
}

function request_full(url) {
    var oXmlHttp = zXmlHttp.createRequest();
    oXmlHttp.open("get", "./includes/index.php?"+url, true);
    oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                display_content(oXmlHttp.responseText);
            } else {
                display_content("An error occurred: " + oXmlHttp.statusText); //statusText is not always accurate
            }
        }            
    };
    oXmlHttp.send(null);
}

function display_content(sText) {
    var divContent = document.getElementById("show_content");
    divContent.innerHTML = sText;
}

function clear()
{
	document.getElementById('txtBillingNo').value="";
	document.getElementById('txtContainerNo').value="";											}
