// Javascript ...
// +----------------------------------------------------------------------+
// | MYO MASSAGE |
// | Common Javascript Functions - scripts/js/default.js |
// +----------------------------------------------------------------------+
// | Copyright (c) REVOLVER 3 |
// +----------------------------------------------------------------------+
// | DESCRIPTION |
// | ----------- |
// | All common Javascript functions used in the project. Included |
// | as an external file in
. |
// | |
// | FUNCTIONS |
// | ----------- |
// | preload_image() |
// | change_image() |
// | open_window() |
// | valide_newsletter_form() |
// | |
// +----------------------------------------------------------------------+
// | Authors: Guillaume Lambert |
// +----------------------------------------------------------------------+
/**************************************************************************
* FUNCTION preload_image(image_name, image_src)
*
* Paramaters:
* var image_name - Name of image
* var image_src - Source of image file
*
* Description:
* Preloads image object for faster rollover action. Make a function on
* head of page like the following and body onLoad it:
*
* var preload_done = false; // images not preloaded
*
* function preload()
* {
* preload_image('image_name', '../_images/image_src.gif');
* ...
* preload_done = true; // all images are preloaded.
* }
*
*************************************************************************/
function preload_image(image_name, image_src)
{
if (document.images)
{
eval(image_name + ' = new Image()');
eval(image_name + '.src = "' + image_src + '"');
}
}
/* ************************************************************************
* FUNCTION change_image(image_name, image_src)
*
* Paramaters:
* var image_name - Name of image
* var image_src - Source of image file
*
* Description:
* Basic rollover (swap-image action) function.
*
*************************************************************************/
function change_image(image_name, image_src)
{
if (document.images)
{
document.images[image_name].src = image_src;
}
}
/**************************************************************************
* FUNCTION open_window(page_url, page_name, window_width, window_height,
* scrollbar_value, is_center)
*
* Paramaters:
* var page_url - Url to the page
* var page_name - Page name (target)
* var window_width - Width of the new window
* var window_height - Height of the new window
* var scrollbar_value - Scrollbar? 'yes', 'no' or 'auto'.
* var is_center - Center new window? 'yes' or 'no'.
*
* Description:
* Opens a pop-up window calculated placed upon the width and height
* the user sends as a paramater. Calculates center position of the window
* if is_center is set to 'yes'. Works in Netscape and Internet Explorer.
*
*************************************************************************/
function open_window(page_url, page_name, window_width, window_height, scrollbar_value, is_center)
{
// Set the position of window - default values
var window_pos_x = 20;
var window_pos_y = 20;
// If centered, calculate center position
if (is_center == 'yes')
{
window_pos_x = (screen.width / 2) - (window_width / 2);
window_pos_y = (screen.height / 2) - (window_height / 2);
}
// Open new window
// NOTE: - new window name must be DIFFERENT than function name or ERROR!
// - don't put space between windowFeatures and commas - equal ERROR in N4.7
popup_window = this.open(page_url, page_name, "toolbar=no,status=no,menubar=no,location=no,scrollbars=" + scrollbar_value + ",resizable=no,width=" + window_width + ",height=" + window_height + ",screenX=" + window_pos_x + ",screenY=" + window_pos_y + ",left=" + window_pos_x + ",top=" + window_pos_y);
popup_window.focus();
}
/**************************************************************************
* FUNCTION valide_newsletter_form()
*
* Paramaters:
* - none -
*
* Description:
* Valide le formulaire pour s'inscrire à la liste de diffusion.
*
* Returns:
* false or true depending on the result.
*
*************************************************************************/
function valide_newsletter_form()
{
// Expression reguliere pour la verification de email
var at = /^(.+)@(.+)\.(.+)$/;
if (document.newsletter.nom.value == "" || document.newsletter.nom.value == "votre nom")
{
alert('Veuillez entrer votre nom');
document.newsletter.nom.focus();
return false;
}
if (!at.test(document.newsletter.email.value) || document.newsletter.email.value == "" || document.newsletter.email.value == "email@domaine.com")
{
alert('Votre courriel semble invalide, veuillez le corriger');
document.newsletter.email.focus();
return false;
}
// If no errors submit!
//document.newsletter.submit();
}
/**************************************************************************
* FUNCTION open_cert_details()
*
* Paramaters:
* - none -
*
* Description:
* Ouvre fenetre avec details SSL - Thawte
*
* Returns:
* - none -
*
*************************************************************************/
function open_cert_details()
{
thewindow = window.open('https://www.thawte.com/cgi/server/certdetails.exe?code=CAINST7','anew',config='height=500,width=516,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
}
// ... End of file.