﻿//***********************************************
//* GVI Common functions
//***********************************************/
// home page redirection (drop-down)
function redirectDropDown(ddl) 
{
    var index = ddl.selectedIndex;
    if (index == -1)
        return;
    var redirect =  ddl.options[index].value;
    if (redirect == "")
        return;
    location.href = redirect; 
}

function redirectURL(url) 
{
    if (url == "")
        return;
    location.href = url; 
}


function clearText(thefield) 
{ 
    if (thefield.defaultValue==thefield.value) 
        thefield.value = "";
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

//***********************************************
//* Highlight Table Cells Script- By Menexis.com
//***********************************************/
//Specify highlight behavior. "TD" to highlight table cells, "TR" to highlight the entire row:
//var highlightbehavior="TR"
var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor,highlightbehavior)
{
    source=ie? event.srcElement : e.target
    if (source.tagName=="TABLE")
    return
    while(source.tagName!=highlightbehavior && source.tagName!="HTML")
        source=ns6? source.parentNode : source.parentElement;
    if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
        source.style.backgroundColor=highlightcolor;
}

function contains_ns6(master, slave) 
{ //check if slave is contained by master
    while (slave.parentNode)
    if ((slave = slave.parentNode) == master)
    return true;
    return false;
}

function changeback(e,originalcolor)
{
    if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
    return
    else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
    return
    
    if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
    source.style.backgroundColor=originalcolor
}

//***********************************************
//  Flash Player Version Detection - Rev 1.5
//  Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
//***********************************************/

// Detect Client Browser type
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

// determine ActiveX version
function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
	try 
	{
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;			
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// ** DETECT FLASH VERSION 
// If called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
{
	versionStr = GetSwfVer();

	if (versionStr == -1 ) 
	{ 
		return false;
	} 
	else if (versionStr != 0) 
	{
		if(isIE && isWin && !isOpera) 
		{
			tempArray         = versionStr.split(" ");
			tempString        = tempArray[1];
			versionArray      = tempString .split(",");				
		} 
		else 
		{
			versionArray      = versionStr.split(".");
		}
		versionMajor      = parseInt(versionArray[0]); 
		versionMinor      = parseInt(versionArray[1]);
		versionRevision   = parseInt(versionArray[2]);
		// alert(versionMajor +"|"+ versionMinor + "|" + versionRevision);

		// Check Major version [10803]
		if (versionMajor < reqMajorVer) return false; 
		if (versionMajor > reqMajorVer) return true;

		// versionMajor == reqMajorVer so check the minor version [10803]
		if (versionMinor < reqMinorVer) return false;
		if (versionMinor > reqMinorVer) return true;

		// versionMinor == reqMinorVer so check the revision [10803]
		if (versionRevision < reqRevision) return false;
		if (versionRevision >= reqRevision) return true;

		}

	// still processing, no condition met, assume flash not valid
	return false;
}

// Google analytics code - JG 26/09/2011
//jQuery(document).ready(function() {
	var _gaq = _gaq || [];

	if (window.location.href.match("travel.globus.com.au") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-3']);
	}
	else if (window.location.href.match("globus.com.au") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-1']);
	}
	else if (window.location.href.match("globustours.co.nz") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-2']);
	}
	else if (window.location.href.match("globustours.co.za") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-14']);
	}
	else if (window.location.href.match("travel.avalonwaterways.com.au") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-6']);
	}
	else if (window.location.href.match("avalonwaterways.com.au") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-4']);
	}
	else if (window.location.href.match("avalonwaterways.co.nz") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-5']);
	}
	else if (window.location.href.match("avalonwaterways.co.za") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-21']);
	}
	else if (window.location.href.match("travel.cosmostours.com.au") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-12']);
	}
	else if (window.location.href.match("cosmostours.com.au") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-10']);
	}
	else if (window.location.href.match("cosmostours.co.nz") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-11']);
	}
	else if (window.location.href.match("cosmostours.co.za") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-16']);
	}
	else if (window.location.href.match("travel.monogramstravel.com.au") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-19']);
	}
	else if (window.location.href.match("monogramstravel.com.au") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-17']);
	}
	else if (window.location.href.match("monogramstravel.co.nz") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-18']);
	}
	else if (window.location.href.match("monogramstravel.co.za") != null) {
		_gaq.push(['_setAccount', 'UA-1777967-20']);
	}

	_gaq.push(['_setDomainName', 'none']);
	_gaq.push(['_setAllowLinker', true]);
	_gaq.push(['_trackPageview']);

	(
		function() {
			var ga = document.createElement('script');
			ga.type = 'text/javascript';
			ga.async = true;
			ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
			var s = document.getElementsByTagName('script')[0];
			s.parentNode.insertBefore(ga, s);
		}
	)
	();
//});


// Google analytics code - Will Golesorkhi - 1/07
//function __utmLinker2(l,h) {
// if (!_ulink) return;
// var p,k,a="-",b="-",c="-",z="-",v="-";
// var dc=_ubd.cookie;
// if (!l || l=="") return;
// var iq = l.indexOf("?"); 
// var ih = l.indexOf("#"); 
// if (dc) {
//  a=_uES(_uGC(dc,"__utma="+_udh,";"));
//  b=_uES(_uGC(dc,"__utmb="+_udh,";"));
//  c=_uES(_uGC(dc,"__utmc="+_udh,";"));
//  z=_uES(_uGC(dc,"__utmz="+_udh,";"));
//  v=_uES(_uGC(dc,"__utmv="+_udh,";"));
//  k=(_uHash(a+b+c+z+v)*1)+(_udh*1);
//  p="__utma="+a+"&__utmb="+b+"&__utmc="+c+"&__utmz="+z+"&__utmv="+v+"&__utmk="+k;
//  return p;
// } 
// if (p) {
//  if (h && ih>-1) return;
//  if (h) { _udl.href=l+"#"+p; }  
//  else {
//   if (iq==-1 && ih==-1) _udl.href=l+"?"+p;
//   else if (ih==-1) _udl.href=l+"&"+p;
//   else if (iq==-1) _udl.href=l.substring(0,ih-1)+"?"+p+l.substring(ih);
//   else _udl.href=l.substring(0,ih-1)+"&"+p+l.substring(ih);
//  } 
// } else { _udl.href=l; } 
//}

// Air pricing - Will Golesorkhi - 2/07
var newwindow;
function pop_taxes_window(url)
{
      newwindow=window.open(url,'name','height=320px,width=780px');
      if (window.focus) {newwindow.focus()}
}

// Slideshow - Golesorkhi - 4/08
function OpenPhotoSlideShow(url, winWidth, winHeight)
{
	winName = "_newSlideShow"
	winParams = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' + winWidth + ',height=' + winHeight;
	newwin = window.open(url, winName, winParams);
	newwin.focus();
}

// Show or hide a div 
function showOrHideDiv(theDivName, unfoundMessage)
{
    var theDiv = document.getElementById(theDivName);
    if (theDiv == null) 
    { 
        if (unfoundMessage != "") alert(unfoundMessage); 
        return;
    }
    
    if (theDiv.style.display == "inline")
    {
        theDiv.style.display = "none";
        theDiv.style.visibility = "hidden";
    }
    else
    {
        theDiv.style.display = "inline";
        theDiv.style.visibility = "visible";
    }
}

// function to help with show a flash video in a div.
// depends on the inclusion of the script file /flash/swfobject.js
function showVideoInDiv(videoUrl, videoDivID, videoBgImage) {
    var so = new SWFObject('/jwplayer/player.swf', 'mpl', '334', '250', '9');
    so.addParam('allowscriptaccess', 'always');
    so.addParam('wmode', 'opaque');
    so.addVariable('file', encodeURI(videoUrl));
    if (videoBgImage.length > 0) {
        so.addVariable('image', encodeURI(videoBgImage));
    }
    so.addVariable('type', 'video');
    so.addVariable('controlbar', 'bottom');   
    so.addVariable('screencolor', '000000');
    so.addVariable('stretching', 'fill');
    so.addVariable('autostart', 'false');  
    //so.addVariable('repeat', 'always');
    so.write(videoDivID);
}

