
function popupgoToLink(aTag){
		newWindow = window.open(aTag.href,'CommerceCM_Popup','width=580,height=400,scrollbars=yes,menubar=no,toolbar=no,location=no,directories=no,resizable=yes,top=0,left=0')
		self.name = 'mainWindow'
		newWindow.focus()
		return false;
		//alert("Should be going to" + aTag.href);
	}

function isValidEmail(emailAddress){
     var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
     var regex = new RegExp(emailReg);
     return regex.test(emailAddress);
}

function checkEmail(){
	try{
		var strTest = new String(document.getElementById("txtEmail").value);
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(strTest)){
			return true;
		}else{
			alert("Please enter a valid email address (abc@123.com)");
			return false;
		}
	}catch(e){
		return false;
	}
}

function popwindow_small(url)
{
	var newwindow;
	newwindow=window.open(url,'name','height=350,width=430, left=300, top=40');
	if (window.focus) {newwindow.focus()}
}
function popwindow(url, height, width, returnvalue)
{
	try{
		if (!height) height=550;
		if (!width)  width=430;
			var newwindow;
			var options = 'height='+height+',width='+width+', left=300, top=40'
			newwindow=window.open(url,null,options);
			if (window.focus) {newwindow.focus()}
			return returnvalue
		}
	catch(e){
		return true;
	}
}
function popwindowscroll(url, height, width)
{
	try{
		if (!height) height=550;
		if (!width)  width=430;

		newwindow=window.open(url,'name','height='+height+',width='+width+', left=300, top=40, scrollbars=yes');
	//	newwindow=window.open(url,'name','height=550,width=430, left=300, top=40');
		if (window.focus) {newwindow.focus()}
		return false
	}
	catch(e){
		return true;
	}
}

var myOffset1 = 0;
var myOffset2 = 270;
var myOffset3 = 0;
var myOffset4 = 0;
var myOffset5 = 0;
		
var myMenu1, myMenu2, myMenu3, myMenu4, myMenu5;
		
function setupMenus(){
	try{
		myMenu1 = new ypSlideOutMenu("menu1", "down", 0, 0, 0, 0)
		myMenu2 = new ypSlideOutMenu("menu2", "down", 0, 80, 125, 300)
		myMenu3 = new ypSlideOutMenu("menu3", "down", 0, 0, 0, 0)
		myMenu4 = new ypSlideOutMenu("menu4", "down", 0, 0, 0, 0)
		myMenu5 = new ypSlideOutMenu("menu5", "down", 0, 0, 0, 0)

		myMenu1.onactivate = repositionMenu1
		myMenu2.onactivate = repositionMenu2
		myMenu3.onactivate = repositionMenu3
		myMenu4.onactivate = repositionMenu4
		myMenu5.onactivate = repositionMenu5
	}catch(e){
		window.setTimeout("setupMenus();", 10);
	}
}

function repositionMenu1(){
	var newLeft = getWindowWidth() / 2 + myOffset1;
	myMenu1.container.style ? myMenu1.container.style.left = newLeft + "px" : myMenu1.container.left = newLeft;
}

function repositionMenu2(){
	var newLeft = getWindowWidth() / 2 + myOffset2;
	myMenu2.container.style ? myMenu2.container.style.left = newLeft + "px" : myMenu2.container.left = newLeft;
}
		
function repositionMenu3(){
	var newLeft = getWindowWidth() / 2 + myOffset3;
	myMenu3.container.style ? myMenu3.container.style.left = newLeft + "px" : myMenu3.container.left = newLeft;
}

function repositionMenu4(){
	var newLeft = getWindowWidth() / 2 + myOffset4;
	myMenu4.container.style ? myMenu4.container.style.left = newLeft + "px" : myMenu4.container.left = newLeft;
}

function repositionMenu5(){
	var newLeft = getWindowWidth() / 2 + myOffset5;
	myMenu5.container.style ? myMenu5.container.style.left = newLeft + "px" : myMenu5.container.left = newLeft;
}
 
function getWindowWidth(){
	return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
}	

setupMenus();

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

