// 0

function payScreenPopup(cartID, prodID, custID)
{
 
 if (confirm('You will now be redirected to the vendors purchase page, This ensures you get the best possible prices. please disable any popup blockers, continue?'))
 {


  // Display a new browser for the user
  var w   = screen.availWidth / 2 - 450;
  var h   = screen.availHeight / 2 - 320;
  var t   = "trackPayment";
  var win = window.open('init.php?trackingProcess='+t+'&cartID='+cartID+'&prodID='+prodID+'&custID='+custID, 'payPopupMain', 'width=900,height=650,left='+w+',top='+h+',scrollbars=1');
 
 } else {
 
  // Send them back to the payment.php page
  window.location('payment.php');
 
 }
 
}

// 1

function checkSearchEmpty()
{

  if(document.searchForm.k.value == "")
  {
  alert("You never entered a product to search for!");
  return false;    
  }
  
  if(document.searchForm.searchCatValue.value == "null")
  {
  alert("You never selected a category to search!");
  return false;    
  }
  
  return true;
}

// 2

function checkLoginEmpty()
{

  if(document.formLogin.txtEmail.value == "")
  {
  alert("You never entered your e-mail address.");
  return false;    
  }
  
  if(document.formLogin.txtPass.value == "")
  {
  alert("You never entered your password.");
  return false;    
  }
  
  // checks if the e-mail address is valid
  var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
  var matchArray = document.formLogin.txtEmail.value.match(emailPat);
  if (matchArray == null) 
  {
    alert("Your email address seems incorrect. Please try again (check the '@' and '.'s in the e-mail address)");
    return false;
  }
  
  return true;
}

// 3

function productCodePopup()
{
  window.open("code.php", "Map", "status = 1, height = 400, width = 600, resizable = 0")
}

// 4

function cartCheck()
{
  //if (document.fcsShoppingCart.updateShipping.value == 0)
  //{
  //alert('You need update the shipping before you can proceed to checkout.')
  //return false;
  //}
  
  //return true;
  
}

// 5

function updateShippingCheck()
{  
  // location.href = "cart.php?do=update";
  document.fcsShoppingCart.submit(); 
}

// 6

function updateCartCheck()
{
  document.fcsShoppingCart.submit();
}

// 7

function popitup(url) 
{
	newwindow = window.open(url,"payPopup","height=3000 width=950, scrollbars=1, status=1, resize=0, location=0");
	if (window.focus) 
	{
	
	 newwindow.focus()
	 
	}
	return false;
}

// 8

function onloadShowInstructions()
{

  // Once the onload is complete show the page and instructions
  //document.getElementById('iframePay').style.visibility = 'visible';
  //document.getElementById('hideUntillLoaded').style.visibility = 'visible';

}

// 9

function checkCategoryAddNew()
{

  if (formAddCategory.txtCategoryName.value == "")
  {
    alert('You haven\'t entered a name for the new category.');
    return false;
  }

    return true;
}

// 10

function checkSignupEmpty()
{

  // Check empty fields first
  if (formSignup.txtEmail.value == "")
  {
    alert('You never entered your e-mail address.');
    return false;
  }
  
  if (formSignup.txtPass1.value == "")
  {
    alert('You never entered your password.');
    return false;
  }
  
  if (formSignup.txtPass2.value == "")
  {
    alert('You never confirmed your password.');
    return false;
  }
  
  if (formSignup.txtPass2.value == "")
  {
    alert('You never confirmed your password.');
    return false;
  }
  
  if (formSignup.txtFirstName.value == "")
  {
    alert('You never entered your first name.');
    return false;
  }
  
  if (formSignup.txtLastName.value == "")
  {
    alert('You never entered your last name.');
    return false;
  }
  
  if (formSignup.txtTelephone.value == "")
  {
    alert('You never entered your Telephone number.');
    return false;
  }
  
  if (formSignup.txtAddress.value == "")
  {
    alert('You never entered your Address.');
    return false;
  }
  
  if (formSignup.txtSuburbCity.value == "")
  {
    alert('You never entered your Suburb or City.');
    return false;
  }
  
  if (formSignup.txtCountry.value == "NULL")
  {
    alert('You never selected a Country.');
    return false;
  }
  
  if (formSignup.txtStateProvince.value == "")
  {
    alert('You never entered a State or Province.');
    return false;
  }
  
  if (formSignup.txtZipPostCode.value == "")
  {
    alert('You never entered a Zip or Post Code.');
    return false;
  }
  
  // Do passwords match
  if (formSignup.txtPass1.value != formSignup.txtPass2.value)
  {
    alert('The passwords you entered don\'t seem to match!');
    return false;
  }
  
  // checks if the e-mail address is valid
  var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
  var matchArray = formSignup.txtEmail.value.match(emailPat);
  if (matchArray == null) 
  {
    alert("Your email address seems incorrect. Please try again (check the '@' and '.'s in the e-mail address)");
    return false;
  }

    return true;
}

// 11

function checkContactFormEmpty()
{

  // Check all fields are filled in
  if (formContact.txtContactEmail.value == "")
  {
    alert('You haven\'t entered your e-mail address.');
    return false;
  }
  
  if (formContact.txtContactMessage.value == "")
  {
    alert('You haven\'t entered a message to us.');
    return false;
  }
  
  // checks if the e-mail address is valid
  var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
  var matchArray = formContact.txtContactEmail.value.match(emailPat);
  if (matchArray == null) 
  {
    alert("Your email address seems incorrect. Please try again (check the '@' and '.'s in the e-mail address)");
    return false;
  }


    return true;
}

// 12

function checkPasswordRecoveryEmpty()
{

  if (formPasswordRecovery.txtEmail.value == "")
  {
    alert('You haven\'t entered your e-mail address.');
    return false;
  }
  
  // checks if the e-mail address is valid
  var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
  var matchArray = formPasswordRecovery.txtEmail.value.match(emailPat);
  if (matchArray == null) 
  {
    alert("Your email address seems incorrect. Please try again (check the '@' and '.'s in the e-mail address)");
    return false;
  }


    return true;
}

// 13

function performSiteCleanUp()
{

 if (confirm('Cleaning and optimizing of the site will now be performed. continue?'))
 {
   
   return true;
   
 } else {
 
   return false;
 
 }

}

// 13

function readMore(pID)
{
  // we will feed the variables in
  var prodID = pID;
  
  alert('You will now be redirected to the vendors website, please disable any popup blockers. You can also purchase directly from them also.');

  // Display a new browser for the user
  var w   = screen.availWidth / 2 - 450;
  var h   = screen.availHeight / 2 - 320;
  var t = "trackReadMore";
  var win = window.open('init.php?trackingProcess='+t+'&prodID='+prodID, 'payPopupMain', 'width=900,height=650,left='+w+',top='+h+',scrollbars=1');
 
}

// 14

function popUpPreview()
{
  // Display a new browser for the user
  var w   = screen.availWidth / 2 - 450;
  var h   = screen.availHeight / 2 - 320;
  var win = window.open('preview.php', 'payPopupMain', 'width=900,height=650,left='+w+',top='+h+',scrollbars=1');
}


// 14

function validateFormAddCompany()
{
  // Validate the empty fields
  if (formAddCompany.txtCompany.value == "")
  {
   alert('You need to add a comapny name! you left it blank!');
   return false;
  }
   return true;
}


// 15

function validateFormAddVendor()
{
  // Validate the empty fields
  if (formAddVendor.txtVendor.value == "")
  {
   alert('You need to add a vendors name! you left it blank!');
   return false;
  }
  
  if (formAddVendor.txtVendorShortCode.value == "")
  {
   alert('You need to add a vendor short code i.e CB for clickbank.');
   return false;
  }
   return true;
}


// 16

function checkProductAddNew()
{
  // Validate the empty fields
  if (formAddProduct.txtProductName.value == "")
  {
   alert('You need to add a product name! you left it blank!');
   return false;
  }
  
  //if (formAddProduct.txtAffiliateURL.value == "")
  //{
  // alert('You need to enter an affiliate URL!');
  // return false;
  //}
  
   return true;
}

// 16

function amazonSecureServer()
{

  alert("Ready to transfer to the secure payments server and see your savings?");

}