// Function to allow one JavaScript file to be included by another.
// Copyright (C) 2006 www.cryer.co.uk
function IncludeJavaScript(jsFile)
{
  document.write('<script type="text/javascript" src="'
    + jsFile + '"></script>'); 
}

IncludeJavaScript('/javascript/gslb.cookie.js');
IncludeJavaScript('/javascript/gslb.object.js');
IncludeJavaScript('/javascript/gslb.positionedbase.js');
IncludeJavaScript('/javascript/gslb.csslength.js');
IncludeJavaScript('/javascript/gslb.positionednode.js');

var _gani_version = 19;				/* IE browser version. DO NOT change */
var _gani_isIE = false;
var _gani_oPositionedNode;


/* values that must be changed to replace the slider image and link						*/

			
var _gani_image_height = 101;								/* image height				*/
var _gani_image_width = 120;								/* image width				*/
var _gani_div_name = 'ganiDivId';							/* image div tag name		*/
var _gani_alt_image_text = 'Java Times Caffe';					/* image alt text			*/
var _gani_image_on_src = "http://www.javatimescaffe.com/javawing_english.png";		/* image in the "on" state  */
var _gani_image_off_src = "http://www.javatimescaffe.com/javawing_english.png";		/* image in the "off" state */
var _gani_image_link = "es/";	/* image "onclick" link     */

var _gani_isExcludedPage = _gani_confirmPageStatus(location.pathname.toLowerCase());


/* end of change section	*/




var _gani_image_on = new Image(_gani_image_height, _gani_image_width); 
var _gani_image_off = new Image(_gani_image_height, _gani_image_width); 

_gani_image_on.src = _gani_image_on_src; 
_gani_image_off.src = _gani_image_off_src; 

if (navigator.appVersion.indexOf("MSIE") != -1)
	_gani_isIE = true;
	
/* If the browser is IE, set the IE version */	
if (_gani_isIE == true)
{
	var temp = navigator.appVersion.split("MSIE");
	_gani_version = parseFloat(temp[1]);
}

function screenPosition(left, top)
{
	this.Left = left;
	this.Top = top;
}	
	
function findPosition(control) 
{
	var curleft = 0;
	var curtop = 0;
	
    if (control.offsetParent) 
    {
        curleft = parseInt(control.offsetLeft);
        curtop = parseInt(control.offsetTop);

        while (control = control.offsetParent) 
        {
            curleft += parseInt(control.offsetLeft);
            curtop += parseInt(control.offsetTop);
        }
    }

	return new screenPosition(curleft,curtop);
}	

function _gani_calculatePosition(movableImage)
{
	var _anchor = 'TopNav';
	var offsetX = 12;
	var offsetY = 275;

	/* For IE vesions less than 7, add 1 pixel to the slider location. */
	if (_gani_version <= 7)
		offsetX = offsetX + 1;
		
	/* create a new controlPosition in case an anchor is not provided */
	var controlPosition = new screenPosition(0,0);
	var anchor = document.getElementById(_anchor);
	
	/* set the left and top coordinates if an anchor is provided */
	if (anchor)
		controlPosition = findPosition(anchor);
	
	/* add the x offset if it is provided */
	if (offsetX)
	{
		if (!isNaN(offsetX))
			controlPosition.Left += parseInt(offsetX);
	}
	
	/* add the y offset if it is provided */
	if (offsetY)
	{
		if (!isNaN(offsetY))
			controlPosition.Top += parseInt(offsetY);
	}

	var clientHeight = 0;
	
	/* adjust the height of the slider if the slider is not visible
	 * in the client window of the browser.
	 */
	if (_gani_isIE == true)
	{
		clientHeight = document.documentElement.clientHeight;

		if (clientHeight == 0)
			clientHeight = document.body.clientHeight;
	}
	else
		clientHeight = self.innerHeight;

	if (clientHeight - _gani_image_height < controlPosition.Top)
		controlPosition.Top = parseInt(clientHeight / 3);

	/* if a movable image was provided, set its coordimates */
	if (movableImage)
	{
		movableImage.style.left = controlPosition.Left + 'px';
		movableImage.style.top = controlPosition.Top + 'px';
	}
}

function _gani_initVertEffect(movableImage)
{
	if (_gani_isExcludedPage == false)
	{
		var movableImage = document.getElementById(movableImage);
		_gani_calculatePosition(movableImage);
	
		if (movableImage)
			_gani_oPositionedNode = new gslb.PositionedNode(movableImage);

		movableImage.style.display = 'block';
	}
}

if (_gani_isExcludedPage == false)
{
	if (_gani_version < 7)
	{
		document.write('<a href="' + _gani_image_link + '">');
		document.write('<div id="' + _gani_div_name + '" style="position: absolute; height: ' + _gani_image_height + 'px; width: ' + _gani_image_width + 'px; ');
		document.write('left: 0px; top: 0px; z-index: 98; cursor: hand; display: none;" onmouseover="document.getElementById(\'gani_div_child_2\').style.display = \'block\';document.getElementById(\'gani_div_child_1\').style.display = \'none\'"  onmouseout="document.getElementById(\'gani_div_child_1\').style.display = \'block\';">');
		document.write('<div id="gani_div_child_2" style="position:absolute; left:0px; top:0px; z-index: 98; height: ' + _gani_image_height + 'px; width: ' + _gani_image_width + 'px; ');
		document.write('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader');
		document.write('(src=\'' + _gani_image_on_src + '\',sizingMethod=\'scale\');">');
		document.write('</div>');
		document.write('<div id="gani_div_child_1" style="position:absolute; left:0px; top:0px; z-index: 98; height: ' + _gani_image_height + 'px; width: ' + _gani_image_width + 'px; ');
		document.write('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader');
		document.write('(src=\'' + _gani_image_off_src + '\',sizingMethod=\'scale\');">');
		document.write('</div>');
		document.write('</div></a>');
	}
	else
	{
		document.write('<div id="' + _gani_div_name + '" style="position: absolute; left: 0px; top: 0px; z-index: 98; display: none;">');
		document.write('  <a href="' + _gani_image_link + '" onclick="this.blur();">');
		document.write('    <img onmouseover="this.src = \'' + _gani_image_on_src + '\';"');
		document.write('	   onmouseout="this.src = \'' + _gani_image_off_src + '\';"');
		document.write('	   border="0"');
		document.write('	   alt="' + _gani_alt_image_text + '"');
		document.write('	   src="' + _gani_image_off_src + '" />');
		document.write('  </a>');
		document.write('</div>');
	}
}

function _gani_onresize()
{
	if (_gani_isExcludedPage == false)
		_gani_calculatePosition(document.getElementById(_gani_div_name));
}

/*
 * Determine if the current page is excluded and the slider image 
 * should not be shown on that page.
 *
 * Returns true if the page should be excluded.
 */
 
function _gani_confirmPageStatus(path)
{
	/* to disable this functionality uncomment the following line of code */
	/* return true; */

	/* pages that will be excluded */
	var pages = new Array(12);
	pages[0] = '/customer/basket.asp';
	pages[1] = '/customer/billing.asp';
	pages[2] = '/customer/shipaddr.asp';
	pages[3] = '/customer/pickship.asp';
	pages[4] = '/customer/crdtcard.asp';
	pages[5] = '/customer/confirm.asp';
	pages[6] = '/customer/orderdetail.asp'; 
	pages[7] = '/customer/orderhis.asp';
	pages[8] = '/card/buyacard_style.asp'; 
	pages[9] = '/card/buyacard_details.asp';
	pages[10] = '/customer/gift_msg.asp';
	pages[11] = '/retail/find/locatorresults.aspx';

	/* paths that will be excluded */
	var paths = new Array(1);
	paths[0] = '/mycard/';
	
	var x = 0;
	
	for (x = 0; x < paths.length; x++) 
	{
		if (path.indexOf(paths[x].toLowerCase(), 0) > -1)
			return true;
	}

	for (x = 0; x < pages.length; x++) 
	{
		if (path.indexOf(pages[x].toLowerCase(), 0) > -1)
			return true;
	}
	
	return false;
}

