// ---------------------------  Global Message --------------------
function GMess(MessageField)
{
var Message="";
var msg = "________________________________________________________________\n\n";
			msg += "The form has not been submitted because there are problem(s) with the form. \n";
			msg += "Please correct the problem(s) and resubmit the form. \n";
			msg += "_______________________________________________________________\n\n";
		
			Message += "The following field(s) need to be corrected :- "
			Message =Message+MessageField;
			Message += alert(msg + Message  );
			return Message;
}

function validDigits(FormName,ElemName){
	var digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@_.";
	var frmElement=document.forms[FormName].elements[ElemName];
	var temp;
	for(var i=0;i<frmElement.value.length;i++){
		temp=frmElement.value.substring(i,i+1);
		if(digits.indexOf(temp)==-1){
			return (false);
		}
	}
	return (true);
}

function validOrderNum(FormName,ElemName){
	var digits="PB0123456789-/";
	var frmElement=document.forms[FormName].elements[ElemName];
	var temp;
	for(var i=0;i<frmElement.value.length;i++){
		temp=frmElement.value.substring(i,i+1);
		if(digits.indexOf(temp)==-1){
			return (false);
		}
	}
	return (true);
}

function validDigits2(FormName,ElemName){
	var digits="+0123456789";
	var frmElement=document.forms[FormName].elements[ElemName];
	var temp;
	for(var i=0;i<frmElement.value.length;i++){
		temp=frmElement.value.substring(i,i+1);
		if(digits.indexOf(temp)==-1){
			return (false);
		}
	}
	return (true);
}



function IsEmailValid(FormName,ElemName)
	{
	if (validDigits(FormName,ElemName)==false){
		return (false);
	}
	var EmailOk  = true
	var Temp     = document.forms[FormName].elements[ElemName]
	var AtSym    = Temp.value.indexOf('@')
	var Period   = Temp.value.lastIndexOf('.')
	var Space    = Temp.value.indexOf(' ')
	var Dot      = Temp.value.indexOf('.')
	var Length   = Temp.value.length - 1   // Array is from 0 to length-1

	if ((AtSym < 1) ||                     // '@' cannot be in first position
	    (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
	    (Period == Length ) ||             // Must be atleast one valid char after '.'
	    (Space  != -1)      ||              // No empty spaces permitted
	    (Dot ==0 )          ||            // No Dot on first position permitted
	    (Dot+1 ==AtSym ))                      // No Dot on first position permitted
	   {  
	      EmailOk = false
	   }
	return EmailOk
}

function PopWindow(uri) { 

	mywin=window.open(uri,'profile','height=500,width=650,left=100,top=10,location=0,menubar=0,statusbar=0,locationbar=0,scrollbars=1,resizable=0');
	mywin.focus();
	return mywin;
}

function ChatLayer(){
	isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;


document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");
}

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function showMe(){
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.theLayer.visibility="show";
}

