/*
*	edreamz 2008
* 	jjohnson
*/
var timeout = 100;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{ 
	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').css('visibility', 'visible');
	$(this).children("a").addClass("selected");
}

function jsddm_close()
{ if(ddmenuitem){
	ddmenuitem.css('visibility', 'hidden');
	}
}

function jsddm_timer()
{ 
	closetimer = window.setTimeout(jsddm_close, timeout);
	
	$(this).children("a").removeClass("selected");
}

function jsddm_canceltimer()
{ if(closetimer)
 { window.clearTimeout(closetimer);
 closetimer = null;}}
 

$(document).ready(function() {
	
	//for ipad
	$('a').live('touchend', function(e) {
		var el = $(this);
		var link = el.attr('href');
		window.location = link;
	});
	
	initPopupLinks();
	
	
	 $('label.in-field').inFieldLabels();
	 
	 // Anything Slider
	 $('#anythingSlider').anythingSlider({
		easing: "easeInOutExpo",                // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not
        startStopped: false,            // If autoPlay is on, this can force it to start stopped
        delay: 5000,                    // How long between slide transitions in AutoPlay mode
        animationTime: 900,             // How long the slide transition takes
        hashTags: false,                 // Should links change the hashtag in the URL?
        buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
        pauseOnHover: false,             // If true, and autoPlay is enabled, the show will pause on hover
        startText: "Start",             // Start text
        stopText: "Stop",               // Stop text
        navigationFormatter: null       // Details at the top of the file on this use (advanced use)

	 });
});

function onProcessChange(tab){
	$('.tab').hide(); 
	$('#'+tab).show(); 
	$('#process_image').attr('src','/images/process/process_'+tab+'.gif'); 
	return false;
}

var popupLinkConfig = new Array;
// popupLinkConfig["classname"] = new Array ( "targetname","width=550,height=350,scrollbars=yes,resizable=yes,status=yes,toolbar=yes,location=yes,menubar=yes");

popupLinkConfig["gMapWindow"] = new Array ( "", "width=640,height=480,resizable=yes,scrollbars=no");	
	
	function initPopupLinks(){		{
			  if (!document.getElementsByTagName) return true;
			  var pageLinks = document.getElementsByTagName("a");
			  for (var i = 0; i < pageLinks.length; i++) 
			  {
				if (((pageLinks[i].className != null) && 
					 (pageLinks[i].className != "")) ||
					((pageLinks[i].parentNode.className != null) && 
					 (pageLinks[i].parentNode.className != "")))
				{
				  var linkClass = " " + pageLinks[i].className + " ";
				  if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
				  {
					linkClass = " " + pageLinks[i].parentNode.className + " ";
				  }
				  for (var theKey in popupLinkConfig) 
				  {
					if (linkClass.indexOf(" " + theKey + " ") > -1)
					{
					  if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
					  {
						pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
					  }
					  pageLinks[i].settings = popupLinkConfig[theKey][1];
					  pageLinks[i].onclick = popUp;
					}
				  }
				}
			  }
			  return true;
			}
			
	function popUp(){
		newWin = window.open(this.href, this.target, this.settings);
		newWin.focus();
		return false;
	}
	}
	
//Fix for IE6 CSS Flicker Bug
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

function RUSure(href,object_name,object_type){
		var message = "Are you sure you want to Delete " + object_name + " from " + object_type + "?";
		var yon = window.confirm(message);
		if (yon == 1){
			window.location.href = href;
		}
	}
