// Pre-load rollover images

var preloaded = new Array();
function preload_images() 
{
   for (var i = 0; i < arguments.length; i++)
    {
        preloaded[i] = document.createElement('img');
        preloaded[i].setAttribute('src',arguments[i]);
    };
};

function preload_primarynav()
{
	preload_images
	(
	'/res/images/nav/whatisqlikview_ql_over.gif',
	'/res/images/nav/yourmarket_ql_over.gif',
	'/res/images/nav/whoweare_ql_over.gif'		
	);		
};

function showSecNav(primaryNavOption)
{
    var secNav;
    secNav = document.getElementById(primaryNavOption);
    secNav.style.display = "block";
    showSecNavDiv();
}

function hideAllSecNav()
{
	var menus = document.getElementsByTagName('ul');
	for(var i=0; i < menus.length; i++)
	{
		var thisMenu = menus[i];
		if(thisMenu.className == 'hidden')
		{
			hideSecNav(thisMenu.id);
		}
	}
	hideSecNavDiv();
}

function showSecNavDiv()
{
    var secNavDiv;
    secNavDiv = document.getElementById('secondaryNav');
    secNavDiv.style.display = "block";
}

function hideSecNavDiv()
{    
    var secNavDiv;
    secNavDiv = document.getElementById('secondaryNav');
    secNavDiv.style.display = "none";
}

function hideSecNav(menuId)
{
    var menuToHide;
    menuToHide = document.getElementById(menuId);
    menuToHide.style.display = "none";
}

function highlightPriNav(li)
{
    li.style.backgroundColor = "#eeeeee";
}

function unhighlightAllPriNav(except)
{
	var menus = document.getElementsByTagName('li');
	for(var i=0; i < menus.length; i++)
	{
		var thisMenu = menus[i];
		if((thisMenu.className == 'prinav') || (thisMenu.className == 'prinavselected'))
		{
			thisMenu.style.backgroundColor = "";
		}
		if(thisMenu.id == except)
		{
		    thisMenu.style.backgroundColor = "#eeeeee";
		}
	}    
}

function SelectPicture()
{	
	var url = "/res/cms/cmsImages.aspx";
	// display popup window allowing user to select from an image list, or upload their own
	flist = "dialogHeight:520px;dialogWidth:800px;resizable:yes;";

	var myObject = new Object();
	myObject.cancel = true;
	myObject.imagePath = "";
	myObject.testString = "Hello";

	var dialog = window.showModalDialog(url, myObject, flist);

	if (myObject.cancel) return;
	document.getElementById("txtPicture").value = myObject.imagePath;			
}

// Navigate to the selected course

function selectCourse()
{
    var courseList = document.getElementById('course');
    location.href = courseList.options[courseList.selectedIndex].value;
}

// --------------------------------------------
// Send Email
// --------------------------------------------

function SendEmail()
{
	var name,email,subject,message;	
	name = document.getElementById('txtName').value;
	email = document.getElementById('txtEmail').value;
	subject = document.getElementById('txtSubject').value;
	message = document.getElementById('txtMessage').value;	
	_default.SendEmail(name,email,subject,message,SendEmail_callback);
}

function SendEmail_callback(res)
{
	//Show confirmation and hide the email form
	var hiddenDiv;
	var emailFormDiv;
	hiddenDiv = document.getElementById('emailConfirmation');
	emailFormDiv = document.getElementById('emailForm');
	emailFormDiv.style.display='none';
	hiddenDiv.style.display = 'block';
}

// --------------------------------------------
// Popup code
// --------------------------------------------

var newwindow;
function popupwindow(url)
{
	newwindow=window.open(url,'name','location=0,status=0,scrollbars=0,width=435,height=480');
	if (window.focus) {newwindow.focus()}
}

// --------------------------------------------
// Popup code - normal window
// --------------------------------------------

var newwindow;
function popupnormalwindow(url)
{
	newwindow=window.open(url,'name','width=1050,height=450,toolbar=1,location=1,menubar=1,resizable=1,status=1');
	if (window.focus) {newwindow.focus()}
}

// --------------------------------------------
// Popup code - I Love QlikView window
// --------------------------------------------

var newwindow;
function popupiloveqlikviewwindow(url)
{
	newwindow=window.open(url,'name','toolbar=1,width=1024,height=768,scrollbars=1,location=1,menubar=1,resizable=1,status=1');
	if (window.focus) {newwindow.focus()}
}

// --------------------------------------------
// Popup Download Request code
// --------------------------------------------

var newwindow;
function popupdownloadwindow(url)
{
	newwindow=window.open(url,'name','width=290,height=440,scrollbars=1,status=1,toolbar=1,location=1,menubar=1,resizable=1');
	if (window.focus) {newwindow.focus()}
}

// --------------------------------------------
// Download File Stuff
// --------------------------------------------

function downloadFile()
{			
	// Validate form

	if 
	(
		(document.getElementById('txtName').value == '') ||
		(document.getElementById('txtEmail').value == '') ||
		(document.getElementById('txtCompanyName').value == '') ||
		(document.getElementById('txtContactTelephone').value == '') 
	)
	
	{
		alert('Please supply all details. Thank you.');
		return false;
	}
	// Do some DIV hiding/showing malarky

	document.getElementById('processingrequest').style.display = 'block';
	//document.getElementById('downloadrequest').style.display = 'none';
	document.getElementById('popupcontent').style.display = 'none';
	
	var whichOne;
	var query = window.location.search.substring(1);
	var splitout = query.split('=');
	whichOne = splitout[1];		
	jellyfish.ajaxFunctions.downloadFile(whichOne,document.getElementById('txtName').value,document.getElementById('txtEmail').value,document.getElementById('txtCompanyName').value,document.getElementById('txtContactTelephone').value,downloadRequest_callback);
}

function downloadRequest_callback(res)
{			
	document.location = res.value;
	top.resizeTo(900,740);
}	

var videowindow;
function openVideoPopup()
{
	newwindow=window.open('/informance_video.aspx','name','width=370,height=420,scrollbars=0,status=0,toolbar=0,location=1,menubar=0,resizable=0');
	if (window.focus) {newwindow.focus()}
}

function openPictureWindow_Fever(imageName,imageWidth,imageHeight,alt,posLeft,posTop) {
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onClick="self.close()">');
	newWindow.document.write('<img src='+imageName+' width='+imageWidth+' height='+imageHeight+' alt='+alt+'>');
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}
