//binh.tang
function chkInput(nav)
{
	var frm = document.myfrm;
	switch (nav.toLowerCase())
	{
		case "nlogin":
			if (frm.username.value =="")
			{
				alert("User name must not be left blank.");
				frm.username.focus();
				return false;
			}
			
			if (frm.password.value =="")
			{
				alert("Password must not be left blank.");
				frm.password.focus();
				return false;
			}
			break;
	}
	return true;
}

function chklogin()
{
	var frm = document.frmSignin;

	if (frm.username.value =="")
	{
		showError(frm, "Username must not be left blank.", "error", frm.username);
		frm.username.focus();
		return false;
	}
	
	if (frm.password.value =="")
	{
		showError(frm, "Password must not be left blank.", frm.password);
		frm.password.focus();
		return false;
	}

	return true;
}


function fOpenWindow(url,width,height) {
	
	var leftPos = (screen.availWidth-width) / 2;
	var topPos = (screen.availHeight-height) / 2;
	window.open(url,'','scrollbars=no,status=no,toolbar=no,location=no,menubar=no,resizable=yes,width='+width+',height='+height+',top=' + topPos + ',left=' + leftPos);
}

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

// Open PopupWindow
function openPicture(imageType,imageName,imageWidth,imageHeight,alt,posLeft,posTop) {  // v4.01
	var posLeft = (screen.availWidth-imageWidth) / 2
	var posTop 	= (screen.availHeight-imageHeight) / 2 
	
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onClick="self.close()">'); 
	if (imageType == "swf"){
		newWindow.document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
		newWindow.document.write('<param name=movie value=\"'+imageName+'\"><param name=quality value=high>');
		newWindow.document.write('<embed src=\"'+imageName+'\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
		newWindow.document.write('</embed></object>');	}else{
		newWindow.document.write('<img src=\"'+imageName+'\" width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\">'); 	
	}
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
// use : onClick="openPicture('jpg','images/ps5_z.jpg','638','272','Image alt','','')"
}
function initLogin(id) {
	var tmpObj=document.getElementById(id);
	if (tmpObj) {
		tmpObj.onfocus=function () {
			if(this.value==id) this.value="";
		}
		tmpObj.onblur = function () {
			if (id!="password") {
				if(this.value=="") this.value=id;
			}
		}
	}
}

function getElementsByBaseTagClass(base, tag, className) { 
    var classPat = new RegExp('\\b'+className+'\\b'); 
    var nodes = base.getElementsByTagName(tag); 
    var matching = []; 
    for (var i = 0; i < nodes.length; i++) { 
        if (classPat.test(nodes[i].className)) { 
            matching.push(nodes[i]); 
        } 
    } 
	return matching; 
}

/*================================================================================================*/
/*START Hover input and image named with _n at the end of name. */

var W3CDOM = (document.createElement && document.getElementsByTagName);
var mouseOvers = new Array();
var mouseOuts = new Array();

function init()
{
	if (!W3CDOM) return;
	/*var nav = document.getElementById('container');*/
	var inputImgs = document.getElementsByTagName('input');
	var imageImgs = document.getElementsByTagName('img');
	var imgs = new Array();
	for (var i=0; i<imageImgs.length; i++) {imgs.push(imageImgs[i]);}
	for (var i=0; i<inputImgs.length; i++) {imgs.push(inputImgs[i]);}
	//alert (imgs.length);
	for (var i=0; i<imgs.length; i++)
	{
		if (imgs[i].src.indexOf('.gif') != -1) // On cible seulement les lments input de type image avec une extension de type .gif
		{			
			// Get image name
			//alert ( (imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).substring(0,(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).lastIndexOf('.')) );
			tmp=(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).substring(0,(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).lastIndexOf('.'));
			
			if ( tmp.indexOf('_') != -1) /* search all img have "_" */
			{
				if (tmp.substring(tmp.lastIndexOf('_')+1) == "n" )
					{
						//alert ( (imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).substring(0,(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).lastIndexOf('.')) );
						imgs[i].onmouseover = mouseGoesOver;
						imgs[i].onmouseout = mouseGoesOut;
						mouseOuts[i] = new Image();
						mouseOuts[i].src = imgs[i].src;
						mouseOvers[i] = new Image();	
						
						/*	
						if (imgs[i].src.lastIndexOf('_') != -1) { mouseOvers[i].src = imgs[i].src.substring(0,imgs[i].src.lastIndexOf('_')) + "_over" + suffix;}
						else { mouseOvers[i].src = imgs[i].src.substring(0,imgs[i].src.lastIndexOf('.')) + "_over" + suffix;}
						*/
						var suffix = imgs[i].src.substring(imgs[i].src.lastIndexOf('.'));
						if (imgs[i].src.lastIndexOf('.') != -1) { mouseOvers[i].src = imgs[i].src.substring(0,imgs[i].src.lastIndexOf('_')) + "_o" + suffix;}
						imgs[i].number = i;
					}
			}
		}
	} //end for
} //end init

function initreset()
{
	if (!W3CDOM) return;
	var imgs = document.getElementsByTagName('img');
	for (var i=0; i<imgs.length; i++)
	{
		if (imgs[i].src.indexOf('.gif') != -1) // On cible seulement les lments input de type image avec une extension de type .gif
		{			
			tmp=(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).substring(0,(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).lastIndexOf('.'));
			
			if ( tmp.indexOf('_') != -1) /* search all img have "_" */
			{
				if (tmp.substring(tmp.lastIndexOf('_')+1) == "o" )
				{
					//alert ( (imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).substring(0,(imgs[i].src.substring(imgs[i].src.lastIndexOf('/') + 1)).lastIndexOf('.')) );
					var suffix = imgs[i].src.substring(imgs[i].src.lastIndexOf('.'));
					var tmpimg= new Image();
						tmpimg.src=imgs[i].src.substring(0,imgs[i].src.lastIndexOf('_')) + "_n.gif";
					imgs[i].src=tmpimg.src;
				}
			}
		}
	} //end for
} //end initreset

var fsub=false;
var mobj;
var osrc="";
function mouseGoesOver(fsub, mEvent) {
	if (checkIt("msie") != 0) { // use in IE
		if (fsub==true) {
			mobj.src=osrc;
			fsub=false;
		} else {
			this.src = mouseOvers[this.number].src;
		}
		osrc=event.srcElement.src;
		mobj=event.srcElement;
	}
	else {	// use in firefox
		if (fsub==true) {
			mobj.src=osrc;
			fsub=false;
		} else if (fsub=='')  {
			osrc=mEvent.target.src;
			mobj=mEvent.target;
		} else {
			this.src = mouseOvers[this.number].src;
		}
	}
}

function mouseGoesOut() {this.src = mouseOuts[this.number].src;	}


var detect = navigator.userAgent.toLowerCase();
var OS,browser,total,thestring;
var version = 0;
function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
/*END Hover input and image */

/*================================================================================================*/
function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new Browser();

function getPageOffsetLeft(el) {
  var x;
  // Return the x coordinate of an element relative to the page.
  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);
  return x;
}
function getPageOffsetTop(el) {
  var y;
  // Return the x coordinate of an element relative to the page.
  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);
  return y;
}
/* add Array.push if needed */
if(Array.prototype.push == null){
	Array.prototype.push = function(item) {this[this.length] = item; return this.length;}
}

function isEmail(s){
	if (s.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,4}$/) != -1)
		return true ;
	return false ;
}

function isBlank(s) {
	if(trim(s) == "" ) 
		return true ;
	return false ;
}

function compareString(s1, s2) {
	if(s1 == s2) 
		return true ;
	return false ;
}
function trim(s) {
	return s.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function isPhone(s) {
	if (isNaN(s))
		return true ;
	return false ;
}

function checkContact(frmObj) {
	var fo = frmObj;
	//alert(fo.inquiry.value);
	if (isBlank(fo.fullname.value)) {
		showError(fo,"Please enter your first name.","error",fo.fullname);
        return false;
	}
	if (isBlank(fo.email.value)) {
		showError(fo,"Please enter your email.","error",fo.email);
        return false;
	}	
	if (!isEmail(fo.email.value)) {
		showError(fo,"Invalid Email format.","error",fo.email);
        return false;
	}/*
	if (isBlank(fo.phone.value)) {
		showError(fo,"Please enter your phone number.","error",fo.phone);
        return false;
	}
	if (!isBlank(fo.phone.value)) {
		if (!chkNum(fo.phone.value)) {
			showError(fo,"Phone must be in numeric.","error",fo.phone);
			return false;
		}	
	}*/
	if (fo.subject.value=="") {
		showError(fo,"Please choose one subject.","error",fo.subject);
        return false;
	}	
	if (fo.inquiry.value=="") {
		showError(fo,"Feel free to fill Inquiry.","error",fo.inquiry);
        return false;
	}	
	return true;
}

function checkJob(frmObj) {
	var fo = frmObj;
	//alert(fo.inquiry.value);
	if (isBlank(fo.firstname.value)) {
		showError(fo,"Please enter your first name.","error",fo.firstname);
        return false;
	}
	if (isBlank(fo.lastname.value)) {
		showError(fo,"Please enter your last name.","error",fo.lastname);
        return false;
	}
	if (isBlank(fo.email.value)) {
		showError(fo,"Please enter your email address.","error",fo.email);
        return false;
	}	
	if (!isEmail(fo.email.value)) {
		showError(fo,"Invalid Email format.","error",fo.email);
        return false;
	}	
	if (fo.category.value=="") {
		showError(fo,"Please choose one category.","error",fo.category);
        return false;
	}
	if (fo.position.value=="") {
		showError(fo,"Please choose your position.","error",fo.position);
        return false;
	}	
	if (fo.comment.value=="") {
		showError(fo,"Don't hesitate putting comment.","error",fo.comment);
        return false;
	}	
	return true;
}
function checkNewsLetter(frmObj) {
	
	var fo = frmObj;
	if (isBlank(fo.yourname.value)) {
		showError(fo,"Your name must not be left blank.","error",fo.yourname);
        return false;
	}
	if (isBlank(fo.youremail.value)) {
		showError(fo,"Your email must not be left blank.","error",fo.youremail);
        return false;
	}	
	if (!isEmail(fo.youremail.value)) {
		showError(fo,"Invalid email format","error",fo.youremail);
        return false;
	}	
	return true;
}



function checkForgotPsw(frmObj) 
{
	var fo = frmObj;
	if (isBlank(fo.username.value)) {
		showError(fo,"Username must not be left blank.","error",fo.username);
        return false;
	}
	if (isBlank(fo.youremail.value)) {
		showError(fo,"Your email must not be left blank.","error",fo.youremail);
        return false;
	}	
	if (!isEmail(fo.youremail.value)) {
		showError(fo,"Invalid email format","error",fo.youremail);
        return false;
	}	

	return true;
}
function checkTrackBack(frmObj) {
	var fo = frmObj;
	//alert(fo.inquiry.value);
	if (isBlank(fo.fullname.value)) {
		showError(fo,"Full name must not be left blank.","error",fo.fullname);
        return false;
	}
	if (isBlank(fo.email.value)) {
		showError(fo,"Email must not be left blank.","error",fo.email);
        return false;
	}	
	if (!isEmail(fo.email.value)) {
		showError(fo,"Invalid Email format","error",fo.email);
        return false;
	}	
	
	if (fo.inquiry.value=="") {
		showError(fo,"Inquiry must not be left blank.","error",fo.inquiry);
        return false;
	}	
	return true;
}

function checkSend2Friend(frmObj) {
	var fo = frmObj;
	//alert(fo.inquiry.value);
	if (isBlank(fo.yname.value)) {
		showError(fo,"Your name must not be left blank.","error",fo.yname);
        return false;
	}
	if (isBlank(fo.yemail.value)) {
		showError(fo,"Your email must not be left blank.","error",fo.yemail);
        return false;
	}	
	if (!isEmail(fo.yemail.value)) {
		showError(fo,"Invalid your email format","error",fo.yemail);
        return false;
	}	

	if (isBlank(fo.femail.value)) {
		showError(fo,"Friends email must not be left blank.","error",fo.femail);
        return false;
	}	
	if (!isEmail(fo.femail.value)) {
		showError(fo,"Invalid friends email format","error",fo.femail);
        return false;
	}	

	if (fo.msg.value=="") {
		showError(fo,"Message must not be left blank.","error",fo.msg);
        return false;
	}	
	return true;
}

function showError(formobj,err_str,err_div,input) {
	var x = getPageOffsetLeft(input);
	var y = getPageOffsetTop(input);
	var objCon = MM_findObj(err_div+"Content");
	var divObj = MM_findObj(err_div);
	if (objCon != null) {
		objCon.innerHTML="<p>"+err_str+"</p>";
	}
	if (divObj != null) {
		divObj.style.left = (x+5)+"px";
		divObj.style.top = y+20+"px";
		divObj.style.visibility = "visible";
	}

	if (browser.isIE) {
		var iframeObj = MM_findObj(err_div+"Iframe");
		if (iframeObj != null && divObj!=null) {
			iframeObj.style.width = divObj.offsetWidth+"px";
			iframeObj.style.height = divObj.offsetHeight+"px";
			iframeObj.style.left = divObj.style.left;
			iframeObj.style.top = divObj.style.top;
			iframeObj.style.visibility = "visible";
		}
	}
	//resetFrmFeedBack(formobj);
	input.focus();
	input.style.backgroundColor="#ebebeb";
	return false;
}

function closeError(err_div) {
	var divObj=MM_findObj(err_div);
	if (divObj!=null) {
		divObj.style.visibility="hidden";
	}
	if (browser.isIE) {
		var iframeObj = MM_findObj(err_div+"Iframe");
		if (iframeObj!=null) {
			iframeObj.style.visibility="hidden";
		}
	}
}


/*================================================================================================*/
/* Functions */

function showSub (id, ObjArr) {	
	if (ObjArr.length == 1){
        ObjArr=ObjArr[0];
		if (ObjArr.style.display=="") {
			ObjArr.style.display="block";
		} else if (ObjArr.style.display=="none") {
			ObjArr.style.display="block";
		} else if (ObjArr.style.display=="block") {
			ObjArr.style.display="none";
		}
	}
	else{
		for (i=0; i<ObjArr.length; i++){
			if (i != id) ObjArr[i].style.display = "none";
			ObjArr[id].style.display="block";
		}
	}
}

function hili (id, ObjArr) {
	for (i=0; i<ObjArr.length; i++){
		if (i != id) ObjArr[i].style.color= "#154a40";
		ObjArr[id].style.color="#e28c05";
	}
}

//Show Glossary Tabs
function showGlosTab(str) {
	var partern = "ABCDEFGHIJKLMNOPQRSTUVWXYZNUM";
	var pos = partern.indexOf(str);
	if (document.currentGlosTab == null) document.currentGlosTab = "A";
	var oldTabBtn = MM_findObj("glosTabBtn"+document.currentGlosTab);
	if (oldTabBtn != null) oldTabBtn.className = "";
	var tabBtn = MM_findObj("glosTabBtn"+str);
	if (tabBtn != null) tabBtn.className = "glosTabBtnOn";
	var tabBar = MM_findObj("glosTabList");
	if (tabBar != null) tabBar.style.backgroundPosition = (pos*17)+"px "+((pos==0)?"0":((pos==26)?"-40px":"-20px"));
	var oldTab = MM_findObj("glosContent"+document.currentGlosTab);
	if (oldTab != null) oldTab.className = "glosContent";
	var tabCont = MM_findObj("glosContent"+str);
	if (tabCont != null) tabCont.className = "glosContentActive";
	document.currentGlosTab = str;
}


//Show News Tabs
function showNewsTab(str) {
	var partern = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
	var pos = partern.indexOf(str);
	//alert (pos);
	if (document.currentNewsTab == null) document.currentNewsTab = "JAN";
	var oldTabBtn = MM_findObj("newsTabBtn"+document.currentNewsTab);
	if (oldTabBtn != null) oldTabBtn.className = "";
	var tabBtn = MM_findObj("newsTabBtn"+str);
	if (tabBtn != null) tabBtn.className = "newsTabBtnOn";
	var tabBar = MM_findObj("newsTabList");
	if (tabBar != null) tabBar.style.backgroundPosition = (pos*13.67)+"px "+((pos==0)?"0":((pos==33)?"-41px":"-21px"));
	var oldTab = MM_findObj("newsContent"+document.currentNewsTab);
	if (oldTab != null) oldTab.className = "newsContent";
	var tabCont = MM_findObj("newsContent"+str);
	if (tabCont != null) tabCont.className = "newsContentActive";
	document.currentNewsTab = str;
}

//Show Comparison Tabs
function showCompTab(str) {
	var partern = "CAPABILITIESCOMPARISONSUMMARIZINGTHESCOREDATASAFEANDSECURE";
	var pos = partern.indexOf(str);
	//alert (pos);
	if (document.currentCompTab == null) document.currentCompTab = "CAPABILITIESCOMPARISON";
	var oldTabBtn = MM_findObj("compTabBtn"+document.currentCompTab);
	if (oldTabBtn != null) oldTabBtn.className = "";
	var tabBtn = MM_findObj("compTabBtn"+str);
	if (tabBtn != null) tabBtn.className = "compTabBtnOn";
	var tabBar = MM_findObj("compTabList");
	if (tabBar != null) tabBar.style.backgroundPosition = (pos*7.46)+"px "+((pos==0)?"0":"-32px");
	if (pos==45) tabBar.style.backgroundPosition= "327px -65px";
	var oldTab = MM_findObj("compContent"+document.currentCompTab);
	if (oldTab != null) oldTab.className = "compContent";
	var tabCont = MM_findObj("compContent"+str);
	if (tabCont != null) tabCont.className = "compContentActive";
	document.currentCompTab = str;
}

function showCompTab2(str) {
	var partern = "AnnualForumOtherEvents";
	var pos = partern.indexOf(str);
	//alert (pos);
	if (document.currentCompTab == null) document.currentCompTab = "AnnualForum";
	var oldTabBtn = MM_findObj("compTabBtn"+document.currentCompTab);
	if (oldTabBtn != null) oldTabBtn.className = "";
	var tabBtn = MM_findObj("compTabBtn"+str);
	if (tabBtn != null) tabBtn.className = "compTabBtnOn";
	var tabBar = MM_findObj("compTabList");
	if (tabBar != null) tabBar.style.backgroundPosition = (pos*7.46)+"px "+((pos==0)?"0":"-33px");
	if (pos==11) tabBar.style.backgroundPosition= "247px -66px";
	var oldTab = MM_findObj("compContent"+document.currentCompTab);
	if (oldTab != null) oldTab.className = "compContent";
	var tabCont = MM_findObj("compContent"+str);
	if (tabCont != null) tabCont.className = "compContentActive";
	document.currentCompTab = str;
}

function toggleNews(obj) {
	if (obj.className=="strongLink2") {
		obj.className="strongLink21";	
	} else {
		obj.className="strongLink2";					
	}
}



function showHideDiv(btnId, divId, dx, dy) {
	if (!W3CDOM) return;
	var btnObj,btnX,btnY,divObj,divStyle;
	if ((btnObj=MM_findObj(btnId))==null) return;
	if ((divObj=MM_findObj(divId))==null) return;
	if (!(divStyle=divObj.style)) return;
	btnX=getPageOffsetLeft(btnObj);
	btnY=getPageOffsetTop(btnObj);
	//alert("x:"+btnX+"  /  y:"+btnY);
	if (divStyle.visibility!="visible") {
		divStyle.left=(btnX+dx)+"px";
		divStyle.top=(btnY+dy)+"px";
		divStyle.visibility="visible";
		return "show";
	} else {
		divStyle.left="0px";
		divStyle.top="0px";
		divStyle.visibility="hidden";
		return "hide";
	}
}

function hideDiv(divId, x, y) {
	if (!W3CDOM) return;
	var divStyle;
	if ((divObj=MM_findObj(divId))==null) return;
	if (!(divStyle=divObj.style)) return;
	divStyle.visibility="hidden";
	//divStyle.left="0px";
	//divStyle.top="0px";
}

/*-----------------------------------------------------------------------------------------------*/
function showLink(objId, divid) {
	showHideDiv(objId, divid, -104, 15);
}
function showLink2(objId, divid) {
	showHideDiv(objId, divid, -370, 15);
}


/*-----------------------------------------------------------------------------------------------*/
function hideLink(divid) {
	hideDiv(divid, 0, 0);
}

/*-----------------------------------------------------------------------------------------------*/
/* Show Animation Popup Layer */
/*-----------------------------------------------------------------------------------------------*/
/*postal code*/
var animCount = 0;
var speed = 200;
var distance = 0;

function showMonpanier(proid,pName,act){
	var p = MM_findObj("popLayer");
	var s = MM_findObj("popLayerShadow");
	var n = MM_findObj("nomProduit");

	if (pName != undefined && pName != null && pName != "") {
		p.style.left = "40px";
		p.style.top = (getPageY() + 150) + "px";
		s.style.left = "45px";
		s.style.top = (getPageY() + 155) + "px";
		p.style.visibility = "visible";
		s.style.visibility = "visible";
		if (document.all){
			var e = MM_findObj("mIEFix");
			e.style.left = "40px";
			e.style.top = (getPageY() + 150) + "px";
			e.style.visibility = "visible";
			e.innerHTML = "<iframe id=\"IEFix2\" src=\"\" width=\"361\" height=\"204\" frameborder=\"0\" scrolling=\"no\">no content<\/iframe>";
		}
		n.innerHTML = pName;
		
		animCount = 0;
		distance = 0;
		
		//call addcart page	
		url_to = "ecommerce/index.php?act=addcart&proid="+proid+"&ToDo="+act;
		add2cart.window.location = url_to;
		var a = MM_findObj("numincart");
		//show popup
		showAnimMonpanier();
		quantity_in_cart = (quantity_in_cart+1);
		a.innerHTML="("+quantity_in_cart + ")";
	}
}

function showAnimMonpanier(){
	var p = MM_findObj("popLayer");
	var s = MM_findObj("popLayerShadow");
	
	animCount++;
	distance += Math.round(speed / animCount / animCount);
	p.style.left = (40 + distance) + "px";
	s.style.left = (45 + distance) + "px";
	if (document.all) {
		var e = MM_findObj("mIEFix");
		e.style.left = (45 + distance) + "px";
	}	
	
	if (animCount == 10) return;	
	setTimeout("showAnimMonpanier()", 10);
}

function hideMonpanier(){
	var p = MM_findObj("popLayer");
	var s = MM_findObj("popLayerShadow");
	var e = MM_findObj("mIEFix");
	p.style.visibility = "hidden";
	s.style.visibility = "hidden";
	e.style.visibility = "hidden";
}

function getPageY(){
	if(window.scrollY) return window.scrollY; // Mozilla
	if(window.pageYOffset) return window.pageYOffset; // Opera, NN4
	if(document.documentElement && document.documentElement.scrollTop){ // IE
		return document.documentElement.scrollTop;
	} else if(document.body && document.body.scrollTop){
		return document.body.scrollTop;
	}
	return 0;
}

function showHideContent (id, curfaq) {
	if (curfaq.length == 1){
		curfaq=curfaq[0];
		if (curfaq.style.display=="") {
			curfaq.style.display="block";
		} else if (curfaq.style.display=="none") {
			curfaq.style.display="block";
		} else if (curfaq.style.display=="block") {
				curfaq.style.display="none";
		}
	}
	else{
		for (i=0; i<curfaq.length; i++){
			if (i != id)
				curfaq[i].style.display = "none";
				curfaq[id].style.display="block";
		}
	}
}
/* show/hide video layer */
function setFlashVariable(varname, value, flashID) {
	var fo = new flashMovie(flashID+"_abc");
	fo.set(varname, value);
}

function showVideoLayer(videoFile)
{
	//setFlashVariable("_root.newVideo", videoFile, videoFile);
	var frmObj = document.getElementById(videoFile);
	frmObj.style.top = getPageY()+50+"px";
	frmObj.style.visibility = "visible";
}

function hideVideoLayer(videoFile)
{
	setFlashVariable("_root.movieStop", "true", videoFile);
	var frmObj = document.getElementById(videoFile);
	frmObj.style.visibility = "hidden";
}

function viewVideo(fileName) {
	setFlashVariable("_root.newVideo", fileName);
}

function getPageY(){
	if(window.scrollY) return window.scrollY; // Mozilla
	if(window.pageYOffset) return window.pageYOffset; // Opera, NN4
	if(document.documentElement && document.documentElement.scrollTop){ // IE
		return document.documentElement.scrollTop;
	} else if(document.body && document.body.scrollTop){
		return document.body.scrollTop;
	}
	return 0;
}
function filterKey(e) {
	var keynum
	var keychar
	var numcheck
	
	if(window.event) {
		keynum = e.keyCode
	} else if(e.which) {
		keynum = e.which
	}
	keychar = String.fromCharCode(keynum);
	numcheck = /[0-9]/;
	if(!numcheck.test(keychar)) {
		if (keynum!=8&&typeof(keynum)!="undefined") {
			//alert("Please enter only numeric characters");
			return false;
		}
	}
	return true;
}

function filterDecimal(e) {
	var keynum
	var keychar
	var numcheck
	
	if(window.event) {
		keynum = e.keyCode
	} else if(e.which) {
		keynum = e.which
	}
	keychar = String.fromCharCode(keynum);
	numcheck = /[0-9\\.]/;
	if(!numcheck.test(keychar)) {
		if (keynum!=8&&typeof(keynum)!="undefined") {
			//alert("Please enter only numeric characters");
			return false;
		}
	}
	return true;
}
function initFileUploads()
{
	if (!W3CDOM) return;
	var baseInput = document.getElementById("file_to_upload");
	if (baseInput != null) {
		baseInput.size=1;
		baseInput.style.width = "87px";
		baseInput.style.height = "22px";
		baseInput.style.position = "absolute";
		baseInput.style.left = "500px";
		baseInput.style.filter = "alpha(opacity=0)";
		baseInput.style.mozOpacity = "0";
		baseInput.style.opacity = "0";
		baseInput.style.cursor = "pointer";
	}
	var fakeFileUpload = document.getElementById("fakeInputHolder");
	var input = document.createElement('input');
	input.id = "fakeInput";
	input.name = "fakeInput";
	fakeFileUpload.appendChild(input);
	var image = document.createElement('input');
	image.id = "fakeFileBtn";
	image.type= "image";
	image.style.height = "19px";
	image.className = "imgBtn";
	image.src='images/btn_browse_n.gif';
	image.onclick = function() {
		return false;
	}
	fakeFileUpload.appendChild(image);
	/*
	baseInput.onfocus = function() {
		var fakeInputObj = document.getElementById("fakeInput");
		fakeInputObj.focus();
	};*/
		
	baseInput.onchange = function() {
		var fakeInputObj = document.getElementById("fakeInput");
		fakeInputObj.value = this.value;
	}
	
	/*baseInput.onclick = function() {
		var fakeInputObj = document.getElementById("fakeInput");
		fakeInputObj.focus();
	};*/
	
	baseInput.onmouseover = function() {
		var fakeInputObj = document.getElementById("fakeFileBtn");
		fakeInputObj.src = "images/btn_browse_o.gif";
	};

	baseInput.onmouseout = function() {
		var fakeInputObj = document.getElementById("fakeInput");
		fakeInputObj.value = this.value;
		var fakeInputObj = document.getElementById("fakeFileBtn");
		fakeInputObj.src = "images/btn_browse_n.gif";
	}

	baseInput.onselect  = function() {
		var fakeInputObj = document.getElementById("fakeInput");
		fakeInputObj.select();
	}
}

function chkNum(strString)   {  //  check for valid numeric strings 
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++) {
strChar = strString.charAt(i);
   if (strValidChars.indexOf(strChar) == -1) {blnResult = false;}
   }
   return blnResult;
}

function fRedeem() {
	var f= document.frmStep3;
	if(f.txtCoupon.value=="") {
		alert("Please enter Redeem Code");
		f.txtCoupon.focus();
		return false;
	}
	f.ToDo.value = "redeem";
	return true;
}

function fCheckOutStep4() {
	var f= document.frmStep3;
	if(!f.accept.checked) {
		alert("Please check to confirm that you accept the general conditions of sales");
		return false;
	}
	f.ToDo.value = "checkout";
	return true;
}

function fSubmitStep3() {
	var f= document.frmStep3;
	if(f.ToDo.value == "redeem") return fRedeem();
	return fCheckOutStep4();
}




function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

	function UpdateBasket(Qty, unitPrice, idSubTotal, idHideSubTotal) {
		var Total=0;
		var msubTotal=Qty.value * unitPrice;
		idHideSubTotal.value=msubTotal;
		document.getElementById(idSubTotal).innerHTML=formatCurrency(msubTotal);
	
		var numProd=document.getElementById("total_product").value;

		for (i=1; i<=numProd; i++) {
			mObjHidden = MM_findObj('hsubtotalcart'+i);
			//alert (mObjHidden);
			Total += eval(mObjHidden.value);
		}
		document.getElementById("subtotal").innerHTML=formatCurrency(Total);
	}
	
	
	
function shContTab(curid, arrObj, arrObjLnk) {
	if (arrObj.length == 1){
		arrObj=curfaq[0];
		if (arrObj.style.display=="") {
			arrObj.style.display="block";
		} else if (arrObj.style.display=="none") {
			arrObj.style.display="block";
		} else if (arrObj.style.display=="block") {
			arrObj.style.display="none";
		}
	}
	else{
		for (i=0; i<arrObj.length; i++){
			if (i != curid) arrObj[i].style.display = "none";
			arrObj[curid].style.display="block";			
		}
		hiliContTab(curid, arrObjLnk);
	}
}

function hiliContTab(curid, arrObj) {
	if (arrObj.length<=6) {
		for (i=0; i<arrObj.length; i++){
			if (i != curid) arrObj[i].className = "tdTab norTab";
			arrObj[curid].className="tdTab curTab2";
		}
	} else {
		for (i=0; i<arrObj.length; i++){
			if (i != curid) arrObj[i].className = "tdTab norTab";
			if (curid>=6) {
				arrObj[curid].className="tdTab curTab2";
			} else {
				arrObj[curid].className="tdTab curTab";
			}
		}		
	}
}
function showHide(id,curfaq) {
for (i=0; i<curfaq.length; i++){
		if (i != id) {
			curfaq[i].style.display = "none";
		}
		curfaq[id].style.display="block";
	}
}

function hideallsub(curfaq) {
	for (i=0; i<curfaq.length; i++){
			curfaq[i].style.display = "none";
	}
}

function tabContent (id, curfaq) {
	for (i=0; i<curfaq.length; i++){
		if (i != id) {
			curfaq[i].style.display = "none";
		}
		curfaq[id].style.display="block";
	}
}

function highlight2 (id, curfaq) {
	for (i=0; i<curfaq.length; i++){
		if (i != id) {
			curfaq[i].className="normalTab"
		}
		curfaq[id].className="activeTab"
	}
}

function shPop (popupid, status) {
	var mpop=MM_findObj(popupid);
	if (status==0) {
		mpop.style.display="none";
		
	} else {
		mpop.style.display="block";
	}
}

function showHideSub(id, submenu)
{
	if (submenu.length == 1)
	{
		submenu = submenu[0];
		if (submenu.style.display == "")
			submenu.style.display = "block";
		else if (submenu.style.display == "none")
			submenu.style.display = "block";
		else if (submenu.style.display == "block")
			submenu.style.display = "none";
	}
	else
	{
		for (i = 0; i < submenu.length; i++)
		{
			if (i != id)
				submenu[i].style.display = "none";
			submenu[id].style.display = "block";
		}
	}
}

function highlight(id, curlink) {
	if (curlink.length == 1)
	{
		//alert ("the length = 1");
	}
	else
	{
		for (i = 0; i < curlink.length; i++)
		{
			if (i != id)
				curlink[i].className="";
		}
		curlink[id].className="";
	}
}

/* form validation functions*/
function checkForm(frm, arr_ctrl) {

	var count= arr_ctrl.length ;
	var i=0  ;
	for(i=0; i< count; i++) {
		func= trim( arr_ctrl[i][0] ) ;
		if( eval( func ) ) { //== 
			showError(frm, arr_ctrl[i][1], "error", eval("frm." + arr_ctrl[i][2]));
        return false;
			if( arr_ctrl[i][2] != "" )
				eval( "frm."  + arr_ctrl[i][2] ).focus() ;
			return false ; //== Error
		}
	}
	return true ; //== OK
}

function trim(str) {
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function isBlank(str) {
	if( str == "" ) 
		return true ;
	return false ;
}
function isEmail(s){
	if (s.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,4}$/) != -1)
		return true ;
	return false ;
}

function isName(s) {
	if (s.search(/^([a-z0-9.]|\s)+$/i) != -1)
		return true ;
	return false ;
}

function inputPhone(number)
{
	var pattern = "0123456789-+ ()[].";
	
	if (len != 0)
	{
		var index = 0;
		var len = number.value.length;
		
		while ((index < len) && (len != 0))
			if (pattern.indexOf(number.value.charAt(index)) == -1)
			{
				if (index == len-1)
					number.value = number.value.substring(0, len-1);
				else if (index == 0)
					 	number.value = number.value.substring(1, len);
					 else number.value = number.value.substring(0, index)+number.value.substring(index+1, len);
				index = 0;
				len = number.value.length;
			}
			else index++;
	}
}

/* log in form validation */
function checkLogin(frmObj) {
	var fo = frmObj;
	//alert(fo.inquiry.value);
	if (isBlank(fo.username.value) || fo.username.value=="username") {		
		showError(fo,"Please enter your username.","error",fo.username);
        return false;
	}
	if (isBlank(fo.password.value)) {
		showError(fo,"Please enter your password.","error",fo.password);
        return false;
	}
	return true;
}

function checkLogin2(frmObj) {
	var fo = frmObj;
	//alert(fo.inquiry.value);
	if (isBlank(fo.username3.value) || fo.username3.value=="username") {		
		showError(fo,"Please enter your username.","error",fo.username3);
        return false;
	}
	if (isBlank(fo.password3.value)) {
		showError(fo,"Please enter your password.","error",fo.password3);
        return false;
	}
	return true;
}

function CheckForgotPwd(frmObj) {
	var fo = frmObj;
	//alert(fo.inquiry.value);
	if (isBlank(fo.email3.value) || !isEmail(fo.email3.value)) {	
		showError(fo,"Please enter your valid email address.","error",fo.email3);
        return false;
	}
	return true;
}


/* end log in form validation */

/* contact us form validation */
function validateFrmContact(frm)
{
	var array_control= new Array( 
		new Array("isBlank( trim(frm.subject.value) )", "Please enter your subject.", "subject"),
		new Array("!isEmail(trim(frm.email.value))", "Please enter your valid email address.", "email"),
		new Array("isBlank( trim(frm.category.value) )", "Please select one category.", "category")
	);
	
	if(checkForm(frm, array_control))
	{ 
		frm.submit();
		return true;
	}
	else
		return false;
}

function validateFrmContact2(frm)
{
	var array_control= new Array( 
		new Array("!isEmail(trim(frm.email.value))", "Please enter your valid email address.", "email")
	);
	
	if(checkForm(frm, array_control))
	{ 
		frm.submit();
		return true;
	}
	else
		return false;
}

function validateFrmServices(frm)
{
	var array_control= new Array( 
		new Array("isBlank( trim(frm.username.value) )", "Please enter your Username.", "username"),
		new Array("isBlank(trim(frm.password.value))", "Please enter your Password.", "password")
	)
	
	if(checkForm(frm, array_control))
	{ 
		frm.submit();
		return true;
	}
	else
		return false;
}

/* end contact us form validation */

/* recruitment form validation */
function validateFrmRecruit(frm)
{
	var array_control= new Array(
		new Array("isBlank( trim(frm.subject.value) )", "Please enter your subject.", "subject"),
		new Array("!isEmail(trim(frm.email.value))", "Please enter your valid email address.", "email")
	);
	
	if(checkForm(frm, array_control))
	{ 
		frm.submit();
		return true;
	}
	else
		return false;
}
/* end recruitment form validation */

/* registration form validation */
function validateFrmRegister(frm)
{
	var array_control= new Array( 
		new Array("isBlank( trim(frm.type_of_trading.value) )", "Please select one type of trading.", "type_of_trading"),
		new Array("isBlank( trim(frm.product_range.value) )", "Please select one product range.", "product_range"),
		new Array("isBlank( trim(frm.companyname.value) )", "Please enter your company name.", "companyname"),
		new Array("isBlank( trim(frm.jobtitle.value) )", "Please enter your job title.", "jobtitle"),
		new Array("isBlank( trim(frm.firstname.value) )", "Please enter your first name.", "firstname"),
		new Array("isBlank( trim(frm.lastname.value) )", "Please enter your last name.", "lastname"),
		
		new Array("isBlank( trim(frm.address1.value) )", "Please enter your address 1.", "address1"),
		new Array("isBlank( trim(frm.address2.value) )", "Please enter your address 2.", "address2"),
		new Array("isBlank( trim(frm.city.value) )", "Please enter your city.", "city"),
		new Array("isBlank( trim(frm.country.value) )", "Please enter your country.", "country"),		
		
		new Array("isBlank( trim(frm.phone.value) )", "Please enter your phone.", "phone"),
		new Array("!isEmail(trim(frm.email.value))", "Please enter your valid email address.", "email"),
		new Array("isBlank( trim(frm.username2.value) )", "Please enter your username.", "username2"),
		new Array("isBlank( trim(frm.password2.value) )", "Please enter your password.", "password2"),
		new Array("isBlank( trim(frm.retypepassword.value) )", "Please enter your password again.", "retypepassword"),
		new Array("!compareString(trim(frm.password2.value), trim(frm.retypepassword.value))", "Your password does not match. Please check again.", "retypepassword")
	);
	
	if(checkForm(frm, array_control))
	{ 
		frm.submit();
		return true;
	}
	else
		return false;
}


function validateFrmRegister2(frm)
{
	var array_control= new Array( 
		new Array("isBlank( trim(frm.type_of_trading.value) )", "Please select one type of trading.", "type_of_trading"),
		new Array("isBlank( trim(frm.companyname.value) )", "Please enter your company name.", "companyname"),
		new Array("isBlank( trim(frm.jobtitle.value) )", "Please enter your job title.", "jobtitle"),
		new Array("isBlank( trim(frm.firstname.value) )", "Please enter your first name.", "firstname"),
		new Array("isBlank( trim(frm.lastname.value) )", "Please enter your last name.", "lastname"),
		new Array("isBlank( trim(frm.phone.value) )", "Please enter your phone.", "phone")
		//new Array("!isEmail(trim(frm.email.value))", "Please enter your valid email address.", "email"),
		//new Array("isBlank( trim(frm.username2.value) )", "Please enter your username.", "username2"),
		//new Array("isBlank( trim(frm.password2.value) )", "Please enter your password.", "password2"),
		//new Array("isBlank( trim(frm.retypepassword.value) )", "Please enter your password again.", "retypepassword"),
		//new Array("!compareString(trim(frm.password2.value), trim(frm.retypepassword.value))", "Your password does not match. Please check again.", "retypepassword")
	);
	
	if(checkForm(frm, array_control))
	{ 
		frm.submit();
		return true;
	}
	else
		return false;
}
/* end registration form validation */

function validateFrmRegister3(frm)
{
	var array_control= new Array( 
		new Array("isBlank( trim(frm.type_of_trading.value) )", "Please select one type of trading.", "type_of_trading"),
		new Array("isBlank( trim(frm.companyname.value) )", "Please enter your company name.", "companyname"),
		new Array("isBlank( trim(frm.jobtitle.value) )", "Please enter your job title.", "jobtitle"),
		new Array("isBlank( trim(frm.firstname.value) )", "Please enter your first name.", "firstname"),
		new Array("isBlank( trim(frm.lastname.value) )", "Please enter your last name.", "lastname"),
		new Array("isBlank( trim(frm.phone.value) )", "Please enter your phone.", "phone"),
		
		//new Array("isBlank( trim(frm.MarketArea.value) )", "Please enter market area.", "MarketArea"),
		new Array("isBlank( trim(frm.ShipDate.value) )", "Please enter ship date.", "ShipDate"),
		new Array("isLessDate( trim(frm.ShipDate.value))", "Please enter ship date greater than today.", "ShipDate"),
		
		new Array("isBlank( trim(frm.PortOfDischarge.value) )", "Please enter port of discharge.", "PortOfDischarge"),
		new Array("isBlank( trim(frm.Consignee.value) )", "Please enter consignee.", "Consignee"),
		new Array("isBlank( trim(frm.Notify.value) )", "Please enter notify.", "Notify"),
		new Array("isBlank( trim(frm.FowardingAgent.value) )", "Please enter fowarding agent.", "FowardingAgent"),
		new Array("isBlank( trim(frm.BankingDetails.value) )", "Please enter banking details.", "BankingDetails")
		
	);
	
	if(checkForm(frm, array_control))
	{ 
		frm.submit();
		return true;
	}
	else
		return false;
}


function validateFrmRegister4(frm)
{
	var array_control= new Array( 
		new Array("isBlank( trim(frm.ShipDate.value) )", "Please enter ship date.", "ShipDate"),
		new Array("isLessDate( trim(frm.ShipDate.value))", "Please enter ship date greater than today.", "ShipDate"),
		
		new Array("isBlank( trim(frm.PortOfDischarge.value) )", "Please enter port of discharge.", "PortOfDischarge"),
		new Array("isBlank( trim(frm.Consignee.value) )", "Please enter consignee.", "Consignee"),
		new Array("isBlank( trim(frm.Notify.value) )", "Please enter notify.", "Notify"),
		new Array("isBlank( trim(frm.FowardingAgent.value) )", "Please enter fowarding agent.", "FowardingAgent"),
		new Array("isBlank( trim(frm.BankingDetails.value) )", "Please enter banking details.", "BankingDetails")
		
	);
	
	if(checkForm(frm, array_control))
	{ 
		return true;
	}
	else
		return false;
}


function hasClass(obj,cName) { return new RegExp('\\b'+cName+'\\b').test(obj.className); }

function removeClass(obj,cName) { if (!hasClass(obj,cName)) return false; var rep=obj.className.match(' '+cName)?' '+cName:cName; obj.className=obj.className.replace(rep,''); return true; }

function addClass(obj,cName) { if (!hasClass(obj,cName)) { obj.className+=obj.className?' '+cName:cName; } return true; }

function activateContent(id)
{
	removeClass(document.getElementById(id), "hide");
	addClass(document.getElementById(id), "show");
}

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];		
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}	
	}
	return (arrReturnElements)
}
// To cover IE 5 Mac lack of the push method
Array.prototype.push = function(value) {this[this.length] = value; };



function resetContentBlocks()
{
	var allBlocks = getElementsByClassName(document.getElementById("main"), "span", "show");

	for (var i = 0; i < allBlocks.length; i++)
		removeClass(allBlocks[i], "hide");
}


function Open_NewWindow(mypage,myname,w,h,scroll,pos)
{
	if (mypage!="")
	{
		if(pos=="random") {
			LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
			TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
		}

		if(pos=="center") {
			LeftPosition=(screen.width)?(screen.width-w)/2:100;
			TopPosition=(screen.height)?(screen.height-h)/2:100;
		}
		else if((pos!="center" && pos!="random") || pos==null) {
				LeftPosition=0;TopPosition=0
		}
		settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
		myname1 = myname + Math.round(1099999999*Math.random());
		win=window.open(mypage,myname1,settings);
	}
}

function compareDate(date1,date2,type){
	var dateInput=(type==1)?1:0;
	var dateType=new Array();
	dateType[0]=/^\d{1,2}(\-|\/|\.|\s)\d{1,2}(\-|\/|\.|\s)\d+$/;	//date format dd mm yyyy
	dateType[1]=/^\d{1,2}(\-|\/|\.|\s)\d{1,2}(\-|\/|\.|\s)\d+$/;	//date format mm dd yyyy

	if (date1.search(dateType[dateInput])==-1||date2.search(dateType[dateInput])==-1) return 0;
	
	var seperator1=(date1.indexOf("-")!=-1)?"-":(date1.indexOf("/")!=-1)?"/":(date1.indexOf(".")!=-1)?".":(date1.indexOf(" ")!=-1)?" ":"";
	var seperator2=(date2.indexOf("-")!=-1)?"-":(date2.indexOf("/")!=-1)?"/":(date2.indexOf(".")!=-1)?".":(date2.indexOf(" ")!=-1)?" ":"";
	
	if (seperator1==""||seperator2=="") return 0;
	
	var dateArr1=date1.split(seperator1);
	var dateArr2=date2.split(seperator2);
	
	if (dateArr1.length!=3||dateArr2.length!=3) return 0;
	
	if (dateInput==1){
		var year1 = dateArr1[2];
		var year2 = dateArr2[2];
		var month1 = dateArr1[0];
		var month2 = dateArr2[0];
		var day1 = dateArr1[1];
		var day2 = dateArr2[1];
	}else{
		var year1 = dateArr1[2];
		var year2 = dateArr2[2];
		var month1 = dateArr1[1];
		var month2 = dateArr2[1];
		var day1 = dateArr1[0];
		var day2 = dateArr2[0];
	}

	if (compareNumber(year1, year2) != 3) return compareNumber(year1, year2);
	if (compareNumber(month1, month2) != 3) return compareNumber(month1, month2);
	if (compareNumber(day1, day2) != 3) return compareNumber(day1, day2);
	return 3;
}

function compareNumber(num1, num2){
	if (num1>num2){
		return 1;
	}else if (num1<num2){
		return 2;
	}else{
		return 3;
	}
}

function isLessDate(date)
{
	if (compareDate(date, today, 0) != 1)
	{
		return true;
	}
	return false;
}



