var frameNum;
var vari = "Please answer the questions to find out which PEPCID is right for you.";
var s1
var s2
var s3
var s4
var frameNum

function getResult()
{
	s1 = document.getElementById('selector1').value;
	s2 = document.getElementById('selector2').value;
	s3 = document.getElementById('selector3').value;
	s4 = document.getElementById('selector4').value;
	
	for(i=0;i<=3; i++) 
		{
			if   ((document.getElementById('selector' + [i + 1]).value) == "")
				 {
					alert('oops... you forgot to select your answer for #' + [i +1]);
					//alert('selector' + [i + 1]);
					document.getElementById('selector' + [i + 1]).focus();
					break;
				 }
			if ([i] == 3) {
				vari = "ready"
				getFrameNow();
				NextFrameFlashMovie();
			}
		}
	
}
function getFrameNow(){
	//alert(s1+s2+s3+s4);
	var getTotal = s1+s2+s3+s4;
	//alert(getTotal);
	/* if all answers are false */
	if (getTotal == 0000){alert('Please answer the questions to find out which PEPCID is right for you.');frameNum= 0}
	/* if original strength */
	else if ((getTotal == 0001)||(getTotal == 1001)||(getTotal == 1101)){frameNum= 1}
	/* if complete */
	else if ((getTotal == 0100)||(getTotal == 0101)||(getTotal == 1111)){frameNum= 3}
	/* otherwise max strength */
	else {frameNum=5}
	
	
	/*
		start frame = frameNum 0
		original = frameNum 1
		complete = frameNum 3
		max strength = frameNum 5
	*/
}
	
/* **************************** */
function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
    return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function RewindFlashMovie()
{
	var flashMovie=getFlashMovieObject("myFlashMovie");
	flashMovie.Rewind();
}

function NextFrameFlashMovie()
    {
         var flashMovie=getFlashMovieObject('myFlashMovie');
         if (vari == 'ready'){
         flashMovie.GotoFrame(frameNum); 
        }
         //else {alert(vari);} 
    }

function FinishFrame()
	{
	frameNum=frameNum + 1;
	NextFrameFlashMovie();
	//NextFrameFlashMovie()
	}

function writeFlash(){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'); 
	document.write('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
	document.write('width="425" height="400" id="myFlashMovie" align="top">');
	document.write('<param name="movie" value="/images/pepcid/swf/product_selector.swf" /><param name="quality" value="high" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="/images/pepcid/swf/product_selector.swf" quality="high" bgcolor="#ffffff" width="425" height="400"'); 
	document.write('name="myFlashMovie" swliveconnect="true"  align="top" allowScriptAccess="sameDomain"'); 
	document.write('type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>')
}