function ValidateForm(form)
{
	var x = form.elements;
	for (var i=0;i<x.length;i++)
	{
		EleObj=x[i].id;
		LastIndex = EleObj.substring(EleObj.length-2,EleObj.length)
		switch(LastIndex)
		{
			case "_R":
				if(ValidateForm_Required(x[i],x[i].title)==false)
					return false;
			break;
			case "_E":
				if(ValidateForm_Email(x[i],x[i].title)==false)
					return false;
			break;
			case "_C":
				if(ValidateForm_Confirm(x[i-1],x[i],x[i].title)==false)
					return false;
			break;
			case "_I":
				if(ValidateForm_Required(x[i],x[i].title)==false)
					return false;
				if(ValidateForm_Numeric(x[i],'0123456789',x[i].title)==false)
					return false;
			break;
			case "_N":
				if(ValidateForm_Numeric(x[i],'0123456789',x[i].title)==false)
					return false;
			break;
			case "_A":
			FieldArray = form.elements[x[i].name];
			if(ValidateForm_CheckArray(x[i],FieldArray,x[i].title)==false)			
				return false;
			break;
		}		
	}
return true;
}
function ValidateForm_Required(Ctrl,msg)
{
	ElementType = Ctrl.type;
	ElementTypeString = ElementType.toUpperCase();
	switch(ElementTypeString)
	{
		case "CHECKBOX":
			if(Ctrl.checked == false)
			{
				alert(msg);
				Ctrl.focus();
				return false;
			}
		break;
		default :
			if(trimString(Ctrl.value) == "")
			{
				alert(msg);
				Ctrl.focus();
				return false;
			}
		break;		
		
	}
	return true;
}
function ValidateForm_CheckArray(Ctrl,FieldArray,msg)
{
	MyCheck = true;
	for (var j=0;j<FieldArray.length;j++)
	{
		if(FieldArray[j].checked)
			MyCheck = false;
		
	}
	if(MyCheck)
	{
		alert(msg);
		Ctrl.focus();
		return false;
	}	
	return true;
}
function ValidateForm_Checked(Ctrl,msg)
{
	if(Ctrl.checked == false)
	{
		alert(msg);
		Ctrl.focus();
		return false;
	}
	return true;
}
function ValidateForm_Numeric(Ctrl,valid_chars,msg)
{
	if(chkNumericValidate(Ctrl.value,valid_chars) == false)
	{
		alert(msg);
		Ctrl.focus();
		return false;
	}
	return true;
}
function chkNumericValidate(strString,strValidChars)
{
   var strChar;
   var blnResult = true; 
  	for (i = 0; i < strString.length && blnResult == true; i++)
   {
	  strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
      {
    	   blnResult = false;
      }
   }
   return blnResult;
}
function ValidateForm_Email(Ctrl,msg)
{
	if(chkEmailValidate(Ctrl.value) == false)
	{
		alert(msg);
		Ctrl.focus();
		return false;
	}
	return true;
}

function ValidateForm_Confirm(Ctrl1,Ctrl2,msg)
{
	if(Ctrl1.value != Ctrl2.value)
	{
		alert(msg);
		Ctrl2.focus();
		return false;
	}
	return true;
}

function chkEmailValidate(str)
{
	return(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str));
}
function trimString (str)
{
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function AddressSame(Obj)
{
	if(Obj.checked==true)
	{
		document.getElementById('sfname_R').value = document.getElementById('bfname_R').value;
		document.getElementById('slname_R').value = document.getElementById('blname_R').value;
		document.getElementById('sfaddress_R').value = document.getElementById('bfaddress_R').value;
		document.getElementById('ssaddress').value = document.getElementById('bsaddress').value;
		document.getElementById('sphone_R').value = document.getElementById('phone_R').value;
		document.getElementById('scity_R').value = document.getElementById('city_R').value;
		document.getElementById('scounty_R').value = document.getElementById('county_R').value;
		document.getElementById('spincode_R').value = document.getElementById('pincode_R').value;		
		document.getElementById('scountry').value = document.getElementById('country').value;		
		
	}
	
}


// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 20;
PositionY = 20;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;

function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(510,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}

	function MyAlert(Mymsg)
	{
		MyString = "<table width='300' style='border:#D3C3AF solid 1px;'><tr><td align='left' bgcolor='#D3C3AF'><b>The French Furniture Company's Alert</b></td><td width='45' align='right' bgcolor='#D3C3AF'><a href='javascript:HideMyAlertDiv();'>X Close</a></td></tr>";
		MyString = MyString + "<tr><td colspan='2' align='center' bgcolor='#ede9e0'><br>"+Mymsg+"<br></td></tr>";
		MyString = MyString + "<tr><td colspan='2' align='center' bgcolor='#ede9e0'><br><input type='button' value='OK' onclick='javascript:HideMyAlertDiv();'><br><br></td></tr>";
		MyString = MyString + "</table>";
	    document.getElementById('DivDetPro').innerHTML =MyString;
	    document.getElementById('DivDetPro').style.display="block";
	}
	function HideMyAlertDiv()
	{
		 document.getElementById('DivDetPro').innerHTML ="";
		 document.getElementById('DivDetPro').style.display="none";
		 
	}
	function MYConfirm(Redirect,Mymsg)
	{
		MyString = "<table width='300' style='border:#D3C3AF solid 1px;'><tr><td align='left' bgcolor='#D3C3AF'><b>The French Furniture Company's Confirm</b></td><td width='45' align='right' bgcolor='#D3C3AF'><a href='javascript:HideMyAlertDiv();'>X Close</a></td></tr>";
		MyString = MyString + "<tr><td colspan='2' align='center' bgcolor='#ede9e0'><br>"+Mymsg+"<br></td></tr>";
		MyString = MyString + "<tr><td colspan='2' align='center' bgcolor='#ede9e0'><br><input type='button' value='OK' onclick=\"javascript:RedirectConfirm('"+Redirect+"');\">&nbsp;&nbsp;&nbsp;<input type='button' value='CANCEL' onclick='javascript:HideMyAlertDiv();return flase;'><br><br></td></tr>";
		MyString = MyString + "</table>";
	    document.getElementById('DivDetPro').innerHTML =MyString;
	    document.getElementById('DivDetPro').style.display="block";
	    return false;
	}
	function RedirectConfirm(Redirect)
	{
		document.location.href = Redirect;
	}
	
	var IE = document.all?true:false;
	if (!IE) document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = setMouseXY;

	var tempX = 0;
	var tempY = 0;

	function setMouseXY(e) {
	  if (IE) {
	    tempX = event.clientX + document.body.scrollLeft;
	    tempY = event.clientY + document.body.scrollTop;
	    
	  } else {
	    tempX = e.pageX;
	    tempY = e.pageY;			    
	  }
	  Is_ie = ( /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) );
	  Is_ie7 = ( Is_ie && /msie 7\.0/i.test(navigator.userAgent) );
	  if(Is_ie7)
	  {
	  	 tempY = tempY + document.documentElement.scrollTop;	
	  }
	  
	  if (tempX < 0){tempX = 0;}
	  if (tempY < 0){tempY = 0;} 
	 				
	}
	function DisplayDivPrevOrg(oDIV,msg)
	{
		document.getElementById(oDIV).style.left = (tempX) + "px";
		document.getElementById(oDIV).style.top = (tempY+15) + "px";
		document.getElementById(oDIV).innerHTML = msg;
		document.getElementById(oDIV).style.display = "block";
	}
	
