function CheckForm(form, required, hold)
{
	//alert("Hello-"+hold);
    //if (hold == 5) return true;
	var msg = "", e, missing_field = false;
	for (var i = 0; i < form.length; i++)
	{
		e = form.elements[i];
		if (required.indexOf("|" + e.name + "|") >= 0 && e.value == "")
		{
			if (e.title == null)
			{
				msg += "- " + e.name + "\n";
			}
			else
			{
				msg += "- " + e.title + "\n";
			}
			missing_field = true;
		}
	}
	if (missing_field)
	{
		alert("Fields Marked with a red asterisk(*) are required fields.\nMissing Fields: \n" + msg);
		return false;
	}
	else
	{
		var emailCheck = CheckEmail(form);
        //var passCheck =    CheckPasswd(form,"cust[password]","cust[password2]");
		var passCheck = true;
        if ( emailCheck == true && passCheck == true ){
            return true;
        }else{
            if ( emailCheck != true )
			{
				alert("Incorrect/Invalid email(s) entered: \n");
                //return !confirm("Incorrect/Invalid email(s) entered: \n" + msg + '\n\nWould you like to correct it? (Or press Cancel to continue.)');
            //}else{
                return false;
            }
        }
    }
}

function CheckEmail(form) {
    var e, invalid_email=false, msg="";
     var re = /^.*@.*\.[a-z]+$|^$/i;
     var email = /^email/i;
     for (var i=0; i < form.length; i++) {
          e = form.elements[i];
          if (email.test(e.name) && !re.test(e.value)) {
               if (e.title == null) {
                   msg += "- " + e.name + "\n";
               } else {
                   msg += "- " + e.title + "\n";
               }
               invalid_email = true;
          }
     }
     if (invalid_email) {
          return false;
     }
     return true;
}

function CheckEmailGeneral(form) {
	var e, invalid_email=false, msg="";
 	var re = /^.*@.*\.[a-z]+$|^$/i;
 	//var email = /^email/i;
	var email = /^element\[email/i;
 	for (var i=0; i < form.length; i++) {
  		e = form.elements[i];
  		if (email.test(e.name) && !re.test(e.value)) {
   			if (e.title == null) {
   				msg += "- " + e.name + "\n";
   			} else {
   				msg += "- " + e.title + "\n";
   			}
   			invalid_email = true;
  		}
 	}
 	if (invalid_email) {
  		//return !confirm("Incorrect/Invalid email(s) entered: \n" + msg + '\n\nWould you like to correct it? (Or press Cancel to continue.)');
		alert("Incorrect/Invalid email(s) entered: \n" + msg);
		return false;
 	}
 	return true;
}

function CheckPasswd(form, field1, field2) {
    var e, e1, e2;
    for (var i=0; i < form.length; i++) {
    	e = form.elements[i];
  		if ((e1 == null) && e.name.indexOf(field1) == 0) { e1 = e; }
		if ((e2 == null) && e.name.indexOf(field2) == 0) { e2 = e; }
 	}
 	if (e1.value != e2.value) {
  		alert("Password and Confirmation do not match. Please retype.");
  		e1.value = "";
  		e2.value = "";
  		e1.focus();
  		return false;
 	}
 	return true;
}

function ClearForm(form){
    for (var i=0; i < form.length; i++) {
        if (form.elements[i].type != 'hidden' &&
            form.elements[i].type != 'image' &&
            form.elements[i].type != 'submit' &&
            form.elements[i].type != 'reset')
        {
            form.elements[i].value = '';
        }
    }
    return 1;
}


function WinOpen(mypage, myname, w, h, s) {
    var wint = (screen.height - h) / 2;
    var winl = (screen.width - w) / 2;

    winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+ ',scrollbars='+s+',resizable=no,horizontalscrollbar=no, screenX='+winl+',screenY='+wint+'';

    win = window.open(mypage, myname, winprops)

    if (parseInt(navigator.appVersion) >= 4) {
        win.window.focus();
    }
}


function add_option(elemId) {
    selectElem = document.getElementById(elemId)
    selectElem.options[selectElem.length] = new Option(this.desc, this.value)
}

function state_record(abbrv, desc) {
    this.value = abbrv
    this.desc  = desc
    this.add_option = add_option
}

function set_state_options(stateId) {
    stateElem = document.getElementById(stateId)
    stateElem.options.length = 0
    stateElem.options[0] = new Option('- Select -', '')

    for (var i in this.states) {
        this.states[i].add_option(stateId)
    }
}

function add_state(abbrv, desc) {
    this.states[this.states.length] = new state_record(abbrv, desc)
}

function country_record(country_cd, country) {
    this.value = country_cd
    this.desc  = country
    this.add_option = add_option
    this.add_state = add_state
    this.set_state_options = set_state_options
    this.states = new Array()
}

function change_country(value, stateId) {
    this.records[value].set_state_options(stateId)
}

function countries() {
    this.records = new Array()
    this.change_country = change_country
}

country_list = new countries()



/******************************************
* Popup Box- By Jim Silver @ jimsilver47@yahoo.com
* Visit http://www.dynamicdrive.com/ for full source code
* This notice must stay intact for use
******************************************/

var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

//drag drop function for NS 4////
/////////////////////////////////

var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for ie4+ and NS6////
/////////////////////////////////


function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
return false
}
}

function initializedrag(e){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}

if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmouseup=new Function("dragapproved=false")

////drag drop functions end here//////

function hidebox(){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
if (ie4||ns6)
crossobj.style.visibility="hidden"
else if (ns4)
document.showimage.visibility="hide"
}

