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_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_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];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function setClass(el,newClass){
el.className=newClass;
}

function Theatre( daLink ) {
	var comwin = window.open(daLink,'Help','width=566,height=354,scrollbars=yes,resize=no');
    comwin.focus() ;
}

function viewPrinter(PLink){
		void(window.open(PLink,'Help','width=668 height=400 scrollbars=yes,resize=yes toolbar=yes'));
	}


/* -- Common functions -- */

function xGetElementById(e)
{
	if(typeof(e)!='string') return e;
	if(document.getElementById) e=document.getElementById(e);
	else if(document.all) e=document.all[e];
	else e=null;
	return e;
}

function checkUrl(url)
{
	if ( (url.indexOf('http://') != -1) || (url.indexOf('https://') != -1) ) return true;
	else return false;
}

function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = document.forms[0].email.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
      return false;
    } 
    return true; 
}



function checkContactForm()
{
	var email = xGetElementById("email");
	var firstname = xGetElementById("firstname");
	var lastname = xGetElementById("lastname");
	var Company = xGetElementById("Company");
	
	errors = "";
	
	if ( email.value.length < 1 || isValidEmail(email.value) == false) errors += "Email Address is not correct\n";
	if ( firstname.value.length < 1) errors += "First Name is not correct\n";
	if ( lastname.value.length < 1) errors += "Last Name is not correct\n";
	if ( Company.value.length < 1) errors += "Company Name is not correct\n";
	
	if (errors.length == 0) {
		document.forms[0].submit();
	} else {
		alert(errors);
	}
}

function checkAssessmentForm()
{
	
	
	var email = xGetElementById("email");
	var firstname = xGetElementById("firstname");
	var lastname = xGetElementById("lastname");
	var company = xGetElementById("company");
	var address = xGetElementById("address");
	var city_state_zip = xGetElementById("city_state_zip");
	//var businesssegment = xGetElementById("businesssegment");
	
	errors = "";
	
	if ( email.value.length < 1 || isValidEmail(email.value) == false) errors += "Email Address is not correct\n";
	if ( firstname.value.length < 1) errors += "First Name is not correct\n";
	if ( lastname.value.length < 1) errors += "Last Name is not correct\n";
	if ( company.value.length < 1) errors += "Company Name is not correct\n";
	if ( address.value.length < 1) errors += "Address is not correct\n";
	if ( city_state_zip.value.length < 1) errors += "City\State\Zip is not correct\n";
	//if ( businesssegment.value.length < 1) errors += "Business Segment is not correct\n";

	if (errors.length == 0) {
		document.forms[0].submit();
	} else {
		alert(errors);
	}
}
function additup(){
	var question1 = xGetElementById("question1");
	var question2 = xGetElementById("question2");
	var question3 = xGetElementById("question3");
	var question4 = xGetElementById("question4");
	var question5 = xGetElementById("question5");
	var question6 = xGetElementById("question6");
	var question7 = xGetElementById("question7");
	var question8 = xGetElementById("question8");
	var question9 = xGetElementById("question9");
	var question10 = xGetElementById("question10");
	var totalranking = xGetElementById("totalranking");
	var total = 0;

	var one = question1.value;
	var two = question2.value;
	var three =question3.value;
	var four = question4.value;
	var five = question5.value;
	var six = question6.value;
	var seven = question7.value;
	var eight = question8.value;
	var nine =question9.value;
	var ten = question10.value;
	
	total+=eval(one);
	total+=eval(two);
	total+=eval(three);
	total+=eval(four);
	total+=eval(five);
	total+=eval(six);
	total+=eval(seven);
	total+=eval(eight);
	total+=eval(nine);
	total+=eval(ten);	
	totalranking.value = total;

}
function clearContactForm()
{
	var brides_name = xGetElementById("brides_name");
	var grooms_name = xGetElementById("grooms_name");
	var work_phone = xGetElementById("work_phone");
	var home_phone = xGetElementById("home_phone");
	var cellular_phone = xGetElementById("cellular_phone");
	var email = xGetElementById("email");
	var wedding_date = xGetElementById("wedding_date");
	var comments = xGetElementById("comments");
	var how = xGetElementById("how");
	
	brides_name.value = '';
	grooms_name.value = '';
	work_phone.value = '';
	home_phone.value = '';
	cellular_phone.value = '';
	email.value = '';
	wedding_date.value = '';
	comments.value = '';
	how.value = '';
}
