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 runFlashIntro() {

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="760" height="636">');
	document.write('<param name="movie" value="/flash/homepage.swf">');
	document.write('<param name="quality" value="high">');
   document.write('<embed src="/flash/homepage.swf" quality="high" salign="lt" pluginspage="http://www.macromedia.com/go/getflashplayer"');
	document.write(' type="application/x-shockwave-flash" width="760" height="636"></embed></object>');
}

function howItWorkFlash() {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'); 	
	document.write(' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="520"');
	document.write(' height="520" id="demo" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="/flash/demo.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="/flash/demo.swf" quality="high" bgcolor="#ffffff" width="520" height="520" name="demo" align="middle"');
	document.write(' allowScriptAccess="sameDomain" type="application/x-shockwave-flash"');
	document.write(' pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

function checkCouponFormEmail() {
	with(document.forms[0]) {
		
		if(isEmpty(email_1.value))			{ alert("Please fill in the E-Mail address."); return false; }
		
		if(!validateEmail(email_1.value))	{ alert("Please check the E-Mail address."); return false; }
		
		submit();
	}
}

function checkFormEmail() {
	with(document.forms[0]) {
			if(isEmpty(email_1.value)) { alert("Please fill in the E-Mail address."); return; }
			if(!validateEmail(email_1.value)) { alert("Please check the E-Mail address."); return; }
			submit();
	}
}

function checkForm(formName) {
	// for tellafriend.jsp, clearCareCoupon.jsp
	alert("override");
	var msg = "Please fix the following errors\n";
	var err = "";
	if(!formName.your_name.value){err += "- your name\n"}
	if(!formName.friend_name.value){err += "- your friend's name\n"}
	if(!formName.email_0.value){err += "- your Email\n"}else{if(!checkEmail(formName.email_0.value)){err += "- a valid Email\n"} }
	if(!formName.friendEmail.value){err += "- your friend's Email\n"}else{if(!checkEmail(formName.friendEmail.value)){err += "- a valid friend's Email\n"} }
	
	if(err != ""){
		
		alert(msg+err);
		return false;
	
	} else{

		return true;
	}
}

function checkEmail(myForm) {
	alert("checkEmail("+ myForm +") checking");
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm)){
		return (true)
	}
	return (false)
}


function validateEmail( strValue) {
	var objRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
	return objRegExp.test(strValue);
}

function isEmpty( strValue ) {
	if(strValue==""){return true;}
   var strTemp = strValue;
   strTemp = trimAll(strTemp);
   if(strTemp.length > 0){
     return false;
   }  
   return true;
}

function isEmpty( strValue ) {

	if(strValue==""){return true;}
	
	var strTemp = strValue;
	strTemp = trimAll(strTemp);

	if(strTemp.length > 0){
		return false;
	}  

return true;

}

function validateEmail( strValue) {
	
	var objRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
	return objRegExp.test(strValue);

}


//This function is taken from the existing site
function openwin(url,w,h,s,r) {
    var scrl; 
    var resze;
    
    if (s) { scrl="scrollbars=yes,"; w = w+16;} 
    else { scrl="scrollbars=no,"; }
    
    if (r) { resze = "resizable=yes,"; }
    else { resze="resizable=no,"; }
    
    if (!w) w = 350;
    if (!h) h = 270;

    stock = window.open(url,"_blank",scrl+resze+"width="+w+",height="+h+",screenX=200,screenY=50");
    stock.focus();
}

function runQuickTimeSilvesterMovie() {
	document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="350" height="350" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0">');
	document.write('<param name="src" value="/movie/silvester_movie.mov">');
	document.write('<param name="controller" value="true">');
	document.write('<param name="autoplay" value="True">');
	document.write('<param name="bgcolor" value="000000">');
	document.write('<param name="target" value="myself">');
	document.write('<param name="href" value="/movie/silvester_movie.mov">');
	document.write('<param name="pluginspage" value="http://www.apple.com/quicktime/download/indext.html">');
	document.write('<embed width="350" height="350" controller="true"');
	document.write('href="/movie/silvester_movie.mov"'); 
	document.write('src="/movie/silvester_movie.mov"'); 
	document.write('bgcolor="000000" border="0"'); 
	document.write('pluginspage="http://www.apple.com/quicktime/download/indext.html"'); 
	document.write('autoplay="true">');
	document.write('</embed>');
	document.write('</object>');
}

