// JavaScript Document

var prevMenuId;
var prevMenuImage;

function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")


//menus
function setMenu(){
var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

switch (sPage)
  {
	//main menu  	
    case "default.asp": case "": { document.getElementById("home").src="images/menu/menu_ov_01.gif"; break }
    case "about.asp": case "testimonials.asp": case "ourcoreteam.asp": case "news.asp": { document.getElementById("about").src="images/menu/menu_ov_02.gif"; break }
    case "services.asp": { document.getElementById("services").src="images/menu/menu_ov_03.gif"; break }
	case "portfolio.asp": { document.getElementById("portfolio").src="images/menu/menu_ov_04.gif"; break }
	case "gallery.asp": { document.getElementById("portfolio").src="images/menu/menu_ov_04.gif"; break }
	case "contact.asp": { document.getElementById("contact").src="images/menu/menu_ov_05.gif"; break }

    // whatever is passed to switch that is not caught
    // by the above fall under this category.
    //default: { document.getElementById("home").src="images/menu/menu_ov_01.gif"; break }
  }
}

function setAboutMenu(){
var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

switch (sPage)
  {
	//about menu
 	case "testimonials.asp": { document.getElementById("testimonials").src="images/menu/about_ov_01.png"; break }
	case "news.asp": { document.getElementById("news").src="images/menu/about_ov_03.png"; break }
	case "ourcoreteam.asp": { document.getElementById("ourcoreteam").src="images/menu/about_ov_05.png"; break }
	
	
    // whatever is passed to switch that is not caught
    // by the above fall under this category.
    //default: { document.getElementById("home").src="images/menu/menu_ov_01.gif"; break }
  }
}


function setPortfolioMenu(){
var sPath = window.location.href;
var sPath2 = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
var sPage2 = sPath2.substring(sPath2.lastIndexOf('/') + 1);

if (sPage2 == "portfolio.asp") {
	//document.getElementById("portfolioMenuDiv").style.visibility="visible";
	MM_effectBlind('portfolioMenuDiv', 200, '0%', '100%', false);
}

switch (sPage)
  {
	//about menu
 	case "gallery.asp?id=1": { document.getElementById("brochures").src="images/menu/portfolio_ov_01.png"; break }
	case "gallery.asp?id=2": { document.getElementById("leaflets").src="images/menu/portfolio_ov_03.png"; break }
	case "gallery.asp?id=3": { document.getElementById("folders").src="images/menu/portfolio_ov_05.png"; break }
	case "gallery.asp?id=4": { document.getElementById("catalogues").src="images/menu/portfolio_ov_07.png"; break }
	case "gallery.asp?id=5": { document.getElementById("logos").src="images/menu/portfolio_ov_09.png"; break }
	case "gallery.asp?id=6": { document.getElementById("advertising").src="images/menu/portfolio_ov_11.png"; break }
	case "gallery.asp?id=7": { document.getElementById("dm").src="images/menu/portfolio_ov_13.png"; break }
	case "gallery.asp?id=8": { document.getElementById("books").src="images/menu/portfolio_ov_15.png"; break }
	case "gallery.asp?id=9": { document.getElementById("newsletters").src="images/menu/portfolio_ov_17.png"; break }
	case "gallery.asp?id=10": { document.getElementById("stationary").src="images/menu/portfolio_ov_19.png"; break }
	case "gallery.asp?id=11": { document.getElementById("packaging").src="images/menu/portfolio_ov_21.png"; break }
	case "gallery.asp?id=12": { document.getElementById("largeformat").src="images/menu/portfolio_ov_23.png"; break }
	case "gallery.asp?id=13": { document.getElementById("web").src="images/menu/portfolio_ov_25.png"; break; }
	case "gallery.asp?id=14": { document.getElementById("cards").src="images/menu/portfolio_ov_27.png"; break }
	
	
	
    // whatever is passed to switch that is not caught
    // by the above fall under this category.
    //default: { document.getElementById("home").src="images/menu/menu_ov_01.gif"; break }
  }
}


function IsFlashLoaded(){
	//alert(document.getElementById("myContent"));
	if (document.getElementById("myContent")) {
		//alert("2");
		var mygallery=new fadeSlideShow({
		wrapperid: "myContent", //ID of blank DIV on page to house Slideshow
		dimensions: [900, 400], //width/height of gallery in pixels. Should reflect dimensions of largest image
		imagearray: [
		["images/home/home.jpg"],
		["images/home/home1.jpg"],
		["images/home/home2.jpg"],
		["images/home/home3.jpg"],
		["images/home/home4.jpg"],
		["images/home/home5.jpg"],
		["images/home/home6.jpg"],
		["images/home/home7.jpg"],
		["images/home/home8.jpg"],
		["images/home/home9.jpg"],
		["images/home/home10.jpg"] //<--no trailing comma after very last image element!
		],
		displaymode: {type:'auto', pause:2500, cycles:0, wraparound:false},
		persist: false, //remember last viewed slide and recall within same session?
		fadeduration: 5000, //transition duration (milliseconds)
		descreveal: "always",
		togglerid: ""
		})
		
	} 
}


function positionSite(){
    var Element = document.getElementById("centerBox"); 
	var divh = 600 ; //Element.offsetHeight;
	var divw = 900;
	var TopMargin = '-300px';
	var LeftMargin = '-450px';
	
	
	var viewportwidth;
 	var viewportheight;
 
 	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 //alert(window.innerHeight)
 	if (typeof window.innerWidth != 'undefined')
 	{
      	viewportwidth = window.innerWidth,
      	viewportheight = window.innerHeight
 	}
 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 	else if (typeof document.documentElement != 'undefined'
     	&& typeof document.documentElement.clientWidth !=
     	'undefined' && document.documentElement.clientWidth != 0)
 	{
       	viewportwidth = document.documentElement.clientWidth,
       	viewportheight = document.documentElement.clientHeight
 	}
 
 	// older versions of IE
 
	else
 	{
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 	}

	
	if (viewportheight < divh) {
		Element.style.top = 0;
		Element.style.marginTop = 0;
	} 
	else 
	{
		Element.style.top = '50%';
		Element.style.marginTop = TopMargin //(divh / 2) * -1;
	}
	
	if (viewportwidth < divw) {
		Element.style.left = 5;
		Element.style.marginLeft = 5;
	} 
	else 
	{
		Element.style.left = '50%';
		Element.style.marginLeft = LeftMargin //(divh / 2) * -1;
	}
}




var PrevID = 1;

function ChangeTestimonial(id)
{
	
	if (id == PrevID) { 
		return false;
	}
		
	document.getElementById(PrevID).className = "bodycopy12";
	//MM_effectAppearFade('testimonial'+PrevID, 1000, 100, 0, false)
	MM_effectSlide('testimonial'+PrevID, 1000, '100%', '0%', false);
	document.getElementById(id).className = "bodycopyPink12";
	//MM_effectAppearFade('testimonial'+id, 1000, 0, 100, false)
	MM_effectSlide('testimonial'+id, 1000, '0%', '100%', false);

	PrevID = id;
}


function ChangeTeam(id)
{
switch (id)
  {
	//main menu  	
    case 'Linda': case "": { 
	document.getElementById("coreteamDiv").innerHTML="<span class='bodycopyPink'>Linda Lowery, Creative Director</span><br /><br />Linda has over 15 years experience working for design consultants and marketing agencies. She achieved Creative Director level for an agency specialising in the retail and leisure industry, developing marketing programmes for shopping centres throughout the UK. She has prepared campaigns for a number of major companies and is used to producing marketing materials within corporate creative guidelines.<br /><br />Over the years Linda has worked for clients in both the business-to-business and business-to-consumer sectors. She has prepared creative materials for numerous companies in a wide range of industries from small businesses through to major brands.<br /><br />Linda founded Rapture at the end of 2005 aiming to provide a quality design service and excellent client support at a competitive price."; 
	
	//document.getElementById("coreteamDiv").innerHTML="<span class='bodycopyPink'>Linda Lowery, Creative Director</span><br /><br />Linda has over 15 years experience working for design consultants and marketing agencies, up to Creative Director level. She has prepared campaigns for a number of major companies and is used to working within corporate creative guidelines.<br /><br />Over the years Linda has worked for clients in both the business to business and business to consumer sectors, working with small businesses through to major brands. She specialised in the retail and leisure industry for over 5 years, working on campaigns for shopping centres.<br /><br />Linda founded Rapture Design at the end of 2005, aiming to offer a quality design service at a competitive price."; 
	
	document.getElementById("Linda").className = "bodycopyPink";
	document.getElementById("Martin").className = "bodycopy";
	document.getElementById("Sarnie").className = "bodycopy";
	document.getElementById("TeamID").value="Linda";
	break; 
	}
		
    case 'Martin': { 
	document.getElementById("coreteamDiv").innerHTML="<span class='bodycopyPink'>Martin Lowery, Technical Director</span><br /><br />Martin has over 15 years experience in web development and plays a key role within the Rapture team.<br /><br />With his logical mind and tenacity in problem solving he complements the wackiness of the creative team. He is also responsible for the IT solutions of the business, keeping us up to date and operating efficiently at all times. "; 
	document.getElementById("Linda").className = "bodycopy";
	document.getElementById("Martin").className = "bodycopyPink";
	document.getElementById("Sarnie").className = "bodycopy";
	document.getElementById("TeamID").value="Martin";
	break;
	}
    
	case 'Sarnie': { 
	document.getElementById("coreteamDiv").innerHTML="<span class='bodycopyPink'>Sarnie Martin, Creative Designer</span><br /><br />Sarnie has over 20 years experience working within multi-disciplined agencies, designing for major brands including Douwe Egberts, Sara Lee, Sony and Imation.<br /><br />With her keen eye for detail and creative flair she can turn her hand to pretty much any creative challenge thrown at her."; 
	document.getElementById("Linda").className = "bodycopy";
	document.getElementById("Martin").className = "bodycopy";
	document.getElementById("Sarnie").className = "bodycopyPink";
	document.getElementById("TeamID").value="Sarnie";
	break;
	}

  }

}


function ChangeTeamName(id)
{
switch (id)
  {
	//main menu  	
    case 'Linda': case "": { 
	document.getElementById("Linda").className = "bodycopyPink";
	if (document.getElementById("TeamID").value != "Martin") {document.getElementById("Martin").className = "bodycopy" };
	if (document.getElementById("TeamID").value != "Sarnie") {document.getElementById("Sarnie").className = "bodycopy" };
	break; 
	}
		
    case 'Martin': { 
	if (document.getElementById("TeamID").value != "Linda") {document.getElementById("Linda").className = "bodycopy" };
	document.getElementById("Martin").className = "bodycopyPink";
	if (document.getElementById("TeamID").value != "Sarnie") {document.getElementById("Sarnie").className = "bodycopy" };
	break;
	}
    
	case 'Sarnie': { 
	if (document.getElementById("TeamID").value != "Linda") {document.getElementById("Linda").className = "bodycopy" };
	if (document.getElementById("TeamID").value != "Martin") {document.getElementById("Martin").className = "bodycopy" };
	document.getElementById("Sarnie").className = "bodycopyPink";
	break;
	}
	
	case '': { 
	if (document.getElementById("TeamID").value != "Linda") {document.getElementById("Linda").className = "bodycopy" };
	if (document.getElementById("TeamID").value != "Martin") {document.getElementById("Martin").className = "bodycopy" };
	if (document.getElementById("TeamID").value != "Sarnie") {document.getElementById("Sarnie").className = "bodycopy" };
	break;
	}

  }

}



var TimeToFade = 1000.0;

function fade(eid)
{
  var element = document.getElementById(eid);
  if(element == null)
    return;
   
  if(element.FadeState == null)
  {
    if(element.style.opacity == null 
        || element.style.opacity == '' 
        || element.style.opacity == '1')
    {
      element.FadeState = 2;
    }
    else
    {
      element.FadeState = -2;
    }
  }
    
  if(element.FadeState == 1 || element.FadeState == -1)
  {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
  }
  else
  {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
  }  
}
















function ChangeTestimonialold(id)
{
switch (id)
  {
	//main menu  	
    case 1: case "": { document.getElementById("testimonialtext").innerHTML="We found Linda friendly and professional<br />with a great ability to interpret our<br />requirements... a fantastic find!<br /><span class='bodycopyPink'>Seriously Good Food</span>"; break }
		
    case 2: { document.getElementById("testimonialtext").innerHTML="testing 2"; break }
    case 3: { document.getElementById("testimonialtext").innerHTML="testing 3"; break }
	case 4: { document.getElementById("testimonialtext").innerHTML="testing 4"; break }
	case 5: { document.getElementById("testimonialtext").innerHTML="testing 5"; break }

    // whatever is passed to switch that is not caught
    // by the above fall under this category.
    //default: { document.getElementById("home").src="images/menu/menu_ov_01.gif"; break }
  }

}

hex=255 // Initial color value.

function fadetext(id){ 
if(hex>0) { //If color is not black yet
hex-=11; // increase color darkness
document.getElementById(id).style.color="rgb("+hex+","+hex+","+hex+")";
setTimeout("fadetext()",20); 
}
else
hex=255 //reset hex value
}










function toggleSubMenu(menuID) 
{
	
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

	if (menuID == '') {
		//alert(document.getElementById('aboutMenuDiv').style.height);
		if (document.getElementById('aboutMenuDiv').style.height == '27px') {
			MM_effectBlind('aboutMenuDiv', 200, '100%', '0%', false);
			
			//show portfolio menu if on portfolio
			if (sPage == "portfolio.asp") {
				MM_effectBlind('portfolioMenuDiv', 200, '0%', '100%', false);
			}
		}
		
		if (document.getElementById('portfolioMenuDiv').style.height == '27px' && sPage != "portfolio.asp") {
			MM_effectBlind('portfolioMenuDiv', 200, '100%', '0%', false);
		}
	}
	
	if (menuID == 'about') {
		if (document.getElementById('aboutMenuDiv').style.height == '' || document.getElementById('aboutMenuDiv').style.height == '0px') {
			
			//hide portfolio menu if visible
			if (document.getElementById('portfolioMenuDiv').style.height == '27px') {
				MM_effectBlind('portfolioMenuDiv', 200, '100%', '0%', false);
			}
			
			MM_effectBlind('aboutMenuDiv', 200, '0%', '100%', false);
			//alert(document.getElementById('aboutMenuDiv').style.height);
		}
	}
	
	if (menuID == 'portfolio') {
		if (document.getElementById('portfolioMenuDiv').style.height == '' || document.getElementById('portfolioMenuDiv').style.height == '0px') {
			MM_effectBlind('portfolioMenuDiv', 200, '0%', '100%', false);
			//alert(document.getElementById('aboutMenuDiv').style.height);
		}
	}
}


function showSubMenu(menuID) 
{
	if (menuID == 'about') {
		document.getElementById('aboutMenuDiv').style.visibility = 'visible';
	}
}










function changeImage(imageID,image) 
{
	document.getElementById(imageID).src = 'images/gallery/' + image;
}

function changeImage2(imageID,imageID2,menuID,image,image2,menuImage) 
{
	document.getElementById(imageID).src = 'images/' + image;
	document.getElementById(imageID2).src = 'images/' + image2;
	document.getElementById(menuID).src = 'images/menus/' + menuImage;
}

function changeImageScroller(imageID,menuID,image,menuImage) 
{
	//alert(document.getElementById(menuID).src.substring(document.getElementById(menuID).src.lastIndexOf('\/')+1));
	if (prevMenuId != null) {
		document.getElementById(prevMenuId).src = 'images/menus/' + prevMenuImage;
	}
	
	prevMenuId = menuID;
	prevMenuImage = document.getElementById(menuID).src.substring(document.getElementById(menuID).src.lastIndexOf('\/')+1)
	
	document.getElementById(imageID).src = 'images/' + image;
	document.getElementById(menuID).src = 'images/menus/' + menuImage;
	
	
}

function changeMenuBack(menuID,menuImage) 
{
	document.getElementById(menuID).src = 'images/menus/' + menuImage;
}

function changeMenuBackScroller() 
{
	document.getElementById(prevMenuId).src = 'images/menus/' + prevMenuImage;
}





function MM_effectAppearFade(targetElement, duration, from, to, toggle)
{
	Spry.Effect.DoFade(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}

function MM_effectBlind(targetElement, duration, from, to, toggle)
{
	Spry.Effect.DoBlind(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}

function MM_effectSlide(targetElement, duration, from, to, toggle)
{
	Spry.Effect.DoSlide(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
