var pagePopup = new YAHOO.widget.Panel("page-popup", {
	width:"450px",
	close:true,
	draggable:true,
	visible:false,
	modal:false,
	constraintoviewport:true,
  underlay:"none",
	effect: {
		effect:YAHOO.widget.ContainerEffect.FADE,
		duration:0.2
	}
});

pagePopup.render();
pagePopup.hide();
document.getElementById('page-popup').style.display="block";

function displaypagePopup(title, url) {
	pagePopup.center();
	document.getElementById('page-popup-title').innerHTML=title;
	document.getElementById('page-popup-frame').src=url;
	pagePopup.show();
}


var responsePopup = new YAHOO.widget.Panel("response-popup", {
	width:"450px",
	close:true,
	draggable:true,
	visible:false,
	modal:false,
	constraintoviewport:true,
  underlay:"none",
	effect: {
		effect:YAHOO.widget.ContainerEffect.FADE,
		duration:0.2
	}
});

responsePopup.render();
responsePopup.hide();
document.getElementById('response-popup').style.display="block";

function displayResponsePopup(arg) {
	responsePopup.center();
	document.getElementById('response-title').innerHTML=arg.title;
	document.getElementById('response-message').innerHTML=arg.message;
	if (arg.button) {
	  document.getElementById('response-button').innerHTML=arg.button;
	} else {
	  document.getElementById('response-button').innerHTML='';	  
	}
	responsePopup.show();
}

// CVV POPUP
var cvvPopup = new YAHOO.widget.Panel("cvv-popup", {
	width:"510px",
	close:true,
	draggable:true,
	visible:false,
	modal:false,
	constraintoviewport:true,
    underlay:"none",
	effect: {
		effect:YAHOO.widget.ContainerEffect.FADE,
		duration:0.3
	}
});

cvvPopup.render();
cvvPopup.hide();
document.getElementById('cvv-popup').style.display="block";

function displayCVVPopup() {
	cvvPopup.center();
	cvvPopup.show();
}

// GET-PASSWORD POPUP
var getPasswdPopup = new YAHOO.widget.Panel("get-password-popup", {
	width:"440px",
	close:true,
	draggable:true,
	visible:false,
	modal:false,
	constraintoviewport:true,
  underlay:"none",
	effect: {
		effect:YAHOO.widget.ContainerEffect.FADE,
		duration:0.2
	}
});

getPasswdPopup.render();
getPasswdPopup.hide();
document.getElementById('get-password-popup').style.display="block";

function displayGetPasswdPopup() {
	getPasswdPopup.center();
	getPasswdPopup.show();
}

function requestNewPasswd(form) {
	getPasswdPopup.hide();
	alert(form);
	var email = form.email.value;
    displayResponsePopup({
        title:"Requested New Password",
        message:"You will receive an e-mail to your address, "+email+", with your account name and the newly generated password." });
}


var devLinksPanel = new YAHOO.widget.Panel("devLinksPanel", {
	width:"200px",
	close:true,
	draggable:true,
	visible:false,
	constraintoviewport:true,
	effect: {
		effect:YAHOO.widget.ContainerEffect.FADE,
		duration:0.2
	}
});

devLinksPanel.render();
devLinksPanel.show();
document.getElementById('devLinksPanel').style.display = "block";


function getState() {
  radio_buttons = document.stateForm.state
  for (i=0;i < radio_buttons.length; i++) {
  	if ( radio_buttons[i].checked) {
  		current_state = radio_buttons[i].value;
  	}
  }
  return current_state;
}

function doFlow() {  
  switch ( getState() ) {
    case 'not-registered':
      displayResponsePopup({
        title:"Try Again, or Create Account", 
        message:"Your login or password did not match.  Please try again, or create a new account.", 
        button:"<img src='images/button_try_again.png'/><a href='registration/register-customer.html' target='top-content-frame'><img src='images/button_create_account.png'/></a>" }); break;
        
    case 'not-activated':
      displayResponsePopup({
        title:"Waiting for Confirmation",
        message:"You will receive an e-mail with an activation link after creating an account.  Please click that link to activate your account." }); break;
        
    case 'not-asked-question':
      document.getElementById('top-content-frame').src="registration/register-question.html"; 
      break;
      
    case 'question-submitted':
      displayResponsePopup({
        title:"Question Registered",
        message:"Your question has been forwarded to an expert Advisor.  We will be sending you an email once the Advisor has answered your question.<br/><br/>"}); break;
        
    case 'not-paid':
      document.getElementById('top-content-frame').src="registration/payment.html"; 
      break;
    
    case 'active':
      window.location="../customer/index.html"; 
      break;
      
    case 'archived':
      displayResponsePopup({
        title:"Archived Question", 
        message:"Your question has been archived.  Thank you!" }); break;
  
  }
}

