// JavaScript Document
/**
 * Attaches the todo behaviour to the todo form.
 */
Drupal.themeAutoAttach = function() {
	var todo = new Drupal.themeFunctions();
	showing = false;
	show = Array();
	//puzzler 1 - hide all answers divs
	$('div.answers').each(function () {
		//make array of all answers so we can close the correct one later on
		id = $(this).attr('id');
		show[id] = false;
		$(this).hide();			
	});
	
}

/**
 * JS todo object.
 */
Drupal.themeFunctions = function() {
  
	//show design-support/design-software page
	$('a#show').each(function () {
    $(this).click(function() {
			if (showing == false) {
			  $('#show_hide').slideDown('slow', function(){
			    showing = true;
			  });
			};
		});
  });

	$('a#hide').each(function () {
    $(this).click(function() {
		  if (showing == true) {
			  $('#show_hide').slideUp('slow', function(){
			    showing = false;
			  });
			};
		});
  });
	
	//reuseable show/hide
	$('a.toggle').each(function () {
    $(this).click(function() {
			//name attribute of link holds name of div to show
			id = $(this).attr('name');
			elementName = 'div#'+ id;
			if (show[id] == false) {
			  $(elementName).slideDown('fast', function(){
			    show[id] = true;
			  });
			}
			else {
			  $(elementName).slideUp('fast', function(){
			    show[id] = false;
			  });				
			};
		});
  });
	
	
}

// Global killswitch
if (Drupal.jsEnabled) {
  $(document).ready(Drupal.themeAutoAttach);	
	var popUpWin=0;
}

/**
 * other js theme function 
 */
/**
 * Dreamweaver image preloader script - used by some old site code
 */
 

/**
 * design consultants page 
 */
function switchElementVisibility (elementId) {
  var element = document.getElementById(elementId);
  if (element.style.display == "none") {
    element.style.display = "block";
  } 
  else {
		element.style.display = "none";
  }			
}

function hideAll() {
  document.getElementById('amer').style.display = 'none';
	document.getElementById('euro').style.display = 'none';
	document.getElementById('apac').style.display = 'none';
}

/**
 * design examples page 
 */
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/**
 * pop up window
 */
function popUpWindow(URLStr, left, top, width, height){
  if(popUpWin){
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
} 

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_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; }
}
