function doClear(theText) 
{
     if (theText.value == theText.defaultValue)
     {
          theText.value = ""
     }
}

/*
function addressSame(theCheckBox)
  {
	    
	   
	   if (theCheckBox.checked)
	    {
          //Populate the billing address
          document.form1.billLine1.value = document.form1.mailLine1.value;
          document.form1.billLine2.value = document.form1.mailLine2.value;
          document.form1.billCity.value = document.form1.mailCity.value;
          document.form1.billState.value = document.form1.mailState.value;
          document.form1.billZip.value = document.form1.mailZip.value;
          
        }
  
	    //Manually fire onchange event after the fields get updated
	    //Works in IE 5.5 and up
	    document.form1.billLine1.fireEvent('onchange');
	    document.form1.billLine2.fireEvent('onchange');
	    document.form1.billCity.fireEvent('onchange');
	    document.form1.billState.fireEvent('onchange');
	    document.form1.billZip.fireEvent('onchange');
  
	    var evt = document.createEvent('HTMLEvents');
	    evt.initEvent('change', true, true);
	    document.form1.billLine1.dispatchEvent(evt);
	    document.form1.billLine2.dispatchEvent(evt);
	    document.form1.billCity.dispatchEvent(evt);
	    document.form1.billState.dispatchEvent(evt);
	    document.form1.billZip.dispatchEvent(evt);
   
}

function addressUpdateSame(theCheckBox)
{
     
   if (theCheckBox.checked)
    {
          //Populate the billing address
          document.form1.billLine1.value = document.form1.mailLine1.value;
          document.form1.billLine2.value = document.form1.mailLine2.value;
          document.form1.billCity.value = document.form1.mailCity.value;
          document.form1.billState.value = document.form1.mailState.value;
          document.form1.billZip.value = document.form1.mailZip.value;
          
    }  
    
}
*/

function alertfunction(alertMsg)
{
   alert(alertMsg)
}

function theaterLocater()
{
	//document.frmThearerLocater.action="theaters.jsp";
    //document.frmThearerLocater.submit();

	var zip = document.frmThearerLocater.txtZip.value;
    var zipVal = zip.substr(0,3);
   
   
	if( zipVal.indexOf('75') != -1)
	{
	   document.frmThearerLocater.action="theaters.jsp#Magnolia";
       document.frmThearerLocater.submit(); 
    }
    else if( zipVal.indexOf('483') != -1)
	{
	   document.frmThearerLocater.action="theaters.jsp#Novi";
       document.frmThearerLocater.submit(); 
    }
    else if( zipVal.indexOf('481') != -1)
	{
	   document.frmThearerLocater.action="theaters.jsp#Canton";
       document.frmThearerLocater.submit(); 
    }
    else if( zipVal.indexOf('484') != -1)
	{
	   document.frmThearerLocater.action="theaters.jsp#BirchRun";
       document.frmThearerLocater.submit(); 
    }
    else
    {
       document.frmThearerLocater.action="theaters.jsp";
       document.frmThearerLocater.submit(); 
    }
   
}

function newsLetterSignUp()
{
    //Validate Form
	if(checkMailId(document.frmNewsLetterSignUp.txtEmail.value))
	{
		document.frmNewsLetterSignUp.action="newslettersignup.jsp";
		document.frmNewsLetterSignUp.submit();
	}
}

function login(loginPage)
{
    document.frmLogin.action=loginPage;
    document.frmLogin.submit();
}

function populateSelectField(fieldName, dbVal, n)
{      
    for(var i=0; i<n; i++)
    {
        if(fieldName.options[i].value == dbVal)
        {
            fieldName.options[i].selected = true;
            break;
        }
    }       								            
}

function createGreeting( greetID)
{
    
    document.formSelectGreeting.greetID.value=greetID;
    document.formSelectGreeting.action="createGreeting.jsp";
	document.formSelectGreeting.submit();
}

function checkMailId(mailids)
{
	var arr = new Array('.com','.net','.org','.biz','.coop','.info','.museum','.name','.pro'
	,'.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag','.ai','.al',
	'.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw','.az','.ba','.bb',
	'.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm','.bn','.bo','.br','.bs',
	'.bt','.bv','.bw','.by','.bz','.ca','.cc','.cd','.cf','.cg','.ch','.ci',
	'.ck','.cl','.cm','.cn','.co','.cr','.cu','.cv','.cx','.cy','.cz','.de',
	'.dj','.dk','.dm','.do','.dz','.ec','.ee','.eg','.eh','.er','.es','.et',
	'.fi','.fj','.fk','.fm','.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh',
	'.gi','.gl','.gm','.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy',
	'.hk','.hm','.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io',
	'.iq','.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
	'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li','.lk',
	'.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg','.mh','.mk',
	'.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt','.mu','.mv','.mw',
	'.mx','.my','.mz','.na','.nc','.ne','.nf','.ng','.ni','.nl','.no','.np',
	'.nr','.nu','.nz','.om','.pa','.pe','.pf','.pg','.ph','.pk','.pl','.pm',
	'.pn','.pr','.ps','.pt','.pw','.py','.qa','.re','.ro','.rw','.ru','.sa',
	'.sb','.sc','.sd','.se','.sg','.sh','.si','.sj','.sk','.sl','.sm','.sn',
	'.so','.sr','.st','.sv','.sy','.sz','.tc','.td','.tf','.tg','.th','.tj',
	'.tk','.tm','.tn','.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug',
	'.uk','.um','.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu',
	'.ws','.wf','.ye','.yt','.yu','.za','.zm','.zw'); 
	var mai = mailids;
	var val = true;
	
	var dot = mai.lastIndexOf(".");
	var ext = mai.substring(dot,mai.length);
	//alert(ext);
	var at = mai.indexOf("@");
	
	if(dot > 5 && at >1)
	{
	for(var i=0; i<arr.length; i++)
	{
	if(ext == arr[i])
	{
	val = true;
	break;
	} 
	else
	{
	val = false;
	}
	}
	if(val == false)
	{
	alert("Your EmailID "+mai+" is not correct");
	return false;
	}
	}
	else
	{
	alert("Your EmailID "+mai+" is not correct");
	return false;
}

return true;
}

function checkSelectRecipient()
{
	var toid = document.frmRecipient.optRecipient.options[document.frmRecipient.optRecipient.selectedIndex].value;
	if (toid == 0) return false;
}

function contactMBO(toid)
{
	 //alert(toid);
	document.frmGeneralQuestion.action="sendmail.jsp?toid="+toid;
	document.frmRecipient.action="sendmail.jsp?toid="+toid;
	if (toid==1 || toid==2 || toid==3 || toid==4) document.frmRecipient.submit();	 
	else if (toid==5) document.frmGeneralQuestion.submit();
	else return false;
}
