/*
 * Created on Aug 1, 2007 by nhorvath
 *
 * NXWEB Technologies
 * All Rights Reserved - Unauthorized Use Prohibited
 * For information contact licensing@nxwebtechnologies.com
 * 
 */ 

function loginCustomer () {
	poststr = "frmEmailSpan="+document.getElementById('frmEmailSpan').value+"&frmPasswordSpan="+document.getElementById('frmPasswordSpan').value;

	makePOSTRequest('login.php', poststr, 'loginOutcome', 'followUpLogin()');

	return false;
}

function followUpLogin() {
	if (document.getElementById('successfullLogin')) {
		window.location.href = "customeraccount.php";
	} 
	
	if (document.getElementById('unSuccessfullLogin')) {
    	document.getElementById('unSuccessfullLogin').style.visibility = 'hidden';
		var errorMessage = document.getElementById('unSuccessfullLogin').innerHTML;
		document.getElementById('unSuccessfullLogin').innerHTML = '';
		showError(errorMessage);
	}
}

function customerSignupPreProcess(theFormId) {

  theForm = document.getElementById(theFormId);
  var formFields = new Array();
  
  for(i=0; i<theForm.elements.length; i++){
  	 if (theForm.elements[i].type == "checkbox") {
         formFields[theForm.elements[i].name] = theForm.elements[i].checked;
  	 } else {
         formFields[theForm.elements[i].name] = theForm.elements[i].value;
     }
  }
  
  return formFields;
}

function preProcessSaveCustomerContact() {
  var formFields = new Array();
  
  for(i=0; i<theForm.elements.length; i++){
  	 if (theForm.elements[i].type == "checkbox") {
         formFields[theForm.elements[i].name] = theForm.elements[i].checked;
  	 } else {
         formFields[theForm.elements[i].name] = theForm.elements[i].value;
     }
  }
  
  return formFields;

}


function sendAccountInfo(email) {
    var poststr = "frmEmail=" + encodeURI(email);
	makePOSTRequest('forgotpassword.php?action=sendInstructionsFromSpan', poststr, 'passwordRetrieveResult');

}


function followUpSaveCustomerContact() {

}

function preProcessSaveUserContact() {
  var formFields = new Array();
  
  for(i=0; i<theForm.elements.length; i++){
  	 if (theForm.elements[i].type == "checkbox") {
         formFields[theForm.elements[i].name] = theForm.elements[i].checked;
  	 } else {
         formFields[theForm.elements[i].name] = theForm.elements[i].value;
     }
  }
  
  return formFields;



}

function followUpSaveCustomerUser() {


}

function displayOrderDetails(orderId) {
   poststr = 'orderId='+orderId;
   makePOSTRequest('customeraccount.php?action=displayOrderDetails', poststr, 'orderDetails', 'displayOrderDetailsSpan()');
}

function displayOrderDetailsSpan() {
   document.getElementById('spanOrderDetails').style.visibility = "visible";
   fadeBackgroundShow();

}

function hideOrderDetails() {
	if (!(null === document.getElementById('spanOrderDetails'))) {
       document.getElementById('spanOrderDetails').style.visibility = "hidden";
    }
	
   fadeBackgroundHide();

}


function printSpan (spanId, pageTitle, pageWidth, pageHeight) {
	OpenWindow=window.open("", "newwin", "height="+pageHeight+", width="+pageWidth+",toolbar=no,scrollbars=yes,menubar=no");
	OpenWindow.document.write("<html><head>");
	OpenWindow.document.write("<title>"+pageTitle+"</title>");
	OpenWindow.document.write("<body>");
	OpenWindow.document.write(document.getElementById(spanId).innerHTML);
	OpenWindow.document.write("</body>");
	OpenWindow.document.write("</html>");
	
	// load nxadvocate.css
	var nxwebCssRef = document.createElement("link");
	nxwebCssRef.setAttribute("rel", "stylesheet");
	nxwebCssRef.setAttribute("type", "text/css");
	nxwebCssRef.setAttribute("href", "/nxweb_ecommerce_templates_oh/styles/1/global.css");
	OpenWindow.document.getElementsByTagName("head")[0].appendChild(nxwebCssRef);
	
	OpenWindow.document.close();
	setTimeout('OpenWindow.print()', 2000);
}


