/** 
 * Toggle the visibility of a field
 * 
 * Note: css must contain the following selectors:
 *
 * .visible {
 *     display: block;
 * }
 * .invisible {
 *     display: none;
 * }
 *
 * Example:
 *
 * <a href="#" onclick="toggleVisibility('fieldId')">toggle</a>
 * <div id="fieldId" class="invisible">hello world</div>
 */
function toggleVisibility(myfieldname) 
{
    var myfield = document.getElementById(myfieldname);
    
    if (myfield.className == "invisible") 
	{
        // myfield.className = "visible"; 
        // NOTE: using class "visible" instead of empty quotes will cause table rows to grow horizontally
        myfield.className = "";
    } 
	else 
	{
        myfield.className = "invisible";
    }
    
    return false;
}

/** 
 * Make a hidden field visible
 * 
 * Example:
 *
 * <a href="#" onclick="makeVisible('fieldId')">show</a>
 * <div id="fieldId" class="invisible">hello world</div>
 */
function makeVisible(myfieldname) 
{
    var myfield = document.getElementById(myfieldname);
    
    if (myfield !== null) 
	{ 
        // NOTE: using class "visible" instead of empty quotes will cause table rows to grow horizontally
        myfield.className = "";
    }

    return false;
} 

/** 
 * Make a field invisible
 * 
 * Example:
 *
 * <a href="#" onclick="makeInvisible('fieldId')">hide</a>
 * <div id="fieldId" class="visible">hello world</div>
 */
function makeInvisible(myfieldname) 
{
    var myfield = document.getElementById(myfieldname);
    
    if (myfield !== null) 
	{ 
        myfield.className = "invisible";
    }
    
    return false;
} 

function deleteTag(tagId) 
{
    var myfield = document.getElementById('delete_tag_id');
    
    if (myfield !== null) 
	{ 
		myfield.value = tagId;
		document.delete_tag_form.submit();
    }
    return false;
} 

function selectTag(tagId) 
{
    var myfield = document.getElementById('search_tag_id');
    
    if (myfield !== null) 
	{ 
		myfield.value = tagId;
		document.search_tag_form.submit();
    }
    return false;
} 



/** 
 * Hide the peek section on page load
 */
//jQuery(
$(document).ready(
function() 
{
	$('#config').hide();
	$('#config').css("height", "300px");

	$('a#slideout').click(function() 
	{
		$('#config').slideToggle("normal");
		return false;
	});
});

//jQuery(
$(document).ready( 
function(){
	//$('.footerbox').corners();
	
	DD_roundies.addRule('.footerbox', '5px', true);
	//DD_roundies.addRule('.footerbox', '5px');
	
	//$('#menu ul li a').corners("4px transparent top");
	//DD_roundies.addRule('#menu ul li a', '5px', true);
	
	/*
	$('#feature_slider').crossSlide({
		  speed: 65,
		  fade: 1
		}, [
		  { src: 'img/wachovia_med.png', dir: 'down'   },
		  { src: 'img/wachovia_med.png', dir: 'up' }
		]);
	*/
});

//jQuery(
$(document).ready(
function() 
{
	$('#submenu').hide();

	//$('#menu ul li a').corners("4px transparent top");
	DD_roundies.addRule('#menu ul li a', '4px 4px 0 0', true);
	
	//$('#header_image').corners("4px bottom");
	//$('#header_image').corners();
	DD_roundies.addRule('#header_image', '0 0 4px 4px', true);

	DD_roundies.addRule('.atmbox dl', '4px 4px 0 0', true);
	
	//$(".atmbox img").dropShadow({left: 4, right: 4, top: 0, bottom: 4, color: black, opacity: 0.8, blur: 4});
	//$(".atmbox img").dropShadow();
	
	
	$("#sections a").hover(
		function () {
			$('#submenu').slideDown("fast");
		}, 
		function () {
			//$('#submenu').slideUp("fast");
		}
	);
	
	$("#submenu").hover(
		function () {
			//$('#submenu').slideDown("fast");
		}, 
		function () {
			$('#submenu').slideUp("fast");
		}
	);
	$("#site_title").hover(
		function () {
			//$('#submenu').slideDown("fast");
		}, 
		function () {
			$('#submenu').slideUp("fast");
		}
	);
});

//jQuery(
$(document).ready(
function() 
{
	$("#site_title").click(
		function () {
			window.location = "/"; 
		}
	);
});
//jQuery(
$(document).ready(
function() 
{

	$("#subnav_fi_partnerships").hide();
	$("#subnav_retail_partnerships").hide();
	$("#subnav_about_us").hide();
	$("#subnav_contact_us").hide();
	
	$("#menu a").hover(
		function () {
			if ($(this).html() == 'FI Partnerships')
			{
				//$(this).click(function() { return false; });
				
				$("#subnav_fi_partnerships").show();
				$("#subnav_retail_partnerships").hide();
				$("#subnav_about_us").hide();
				$("#subnav_contact_us").hide();
				$("#subnav_atm_catalog").hide();
			}
			if ($(this).html() == 'Retail Partnerships')
			{
				//$(this).click(function() { return false; });
				
				$("#subnav_fi_partnerships").hide();
				$("#subnav_retail_partnerships").show();
				$("#subnav_about_us").hide();
				$("#subnav_contact_us").hide();
				$("#subnav_atm_catalog").hide();
			}
			if ($(this).html() == 'ATM Catalog')
			{
				//$(this).click(function() { return false; });
				
				$("#subnav_fi_partnerships").hide();
				$("#subnav_retail_partnerships").hide();
				$("#subnav_about_us").hide();
				$("#subnav_contact_us").hide();
				$("#subnav_atm_catalog").show();
			}
			if ($(this).html() == 'About Us')
			{
				$("#subnav_fi_partnerships").hide();
				$("#subnav_retail_partnerships").hide();
				$("#subnav_about_us").show();
				$("#subnav_contact_us").hide();
				$("#subnav_atm_catalog").hide();
				
				//$('#submenu').slideUp("fast");
			}
			if ($(this).html() == 'Contact Us')
			{
				//$(this).click(function() { return false; });
				
				$("#subnav_fi_partnerships").hide();
				$("#subnav_retail_partnerships").hide();
				$("#subnav_about_us").hide();
				$("#subnav_contact_us").show();
				$("#subnav_atm_catalog").hide();
				
				$('#submenu').slideUp("fast");
			}
			
		}, 
		function () {
			//$('#submenu').slideUp("fast");
		}
	);
	

});

$(document).ready(
function() 
{
	$("#searchbutton").click(
		function () {
			var searchQuery = $("#search").val();
			window.location = "/search?s=" + searchQuery; 
		}
	);
});

$(document).ready(
function() 
{
	$("#search").keyup(function(e) {
		if (e.keyCode == 13) 
		{
			var searchQuery = $("#search").val();
			window.location = "/search?s=" + searchQuery; 
		}
	}); 
});

$(document).ready(
function() 
{
	// Set contact form default values:
	//$("#Name").DefaultValue("*Name:");
	$("#Name").DefaultValue("Name:");
	$("#Title").DefaultValue("Title:");
	//$("#Phone").DefaultValue("*Work Phone:");
	$("#Phone").DefaultValue("Work Phone:");
	$("#Address").DefaultValue("Address:");
	$("#City").DefaultValue("City:");
	$("#Zip").DefaultValue("Zip:");
	//$("#Email").DefaultValue("*E-mail:");
	$("#Email").DefaultValue("E-mail:");
	$("#comments").DefaultValue("Comments:");

	$("#search").DefaultValue("Search");
});

/*
$(document).ready(function(){
	$("#contact-form").validate({
		rules: {
			Name: "required",
			Phone: "required",
			Email: "required"
		}
	});
});
*/

function gohome()
{
	window.location="/";
}

// Adjust for iPhones
$(document).ready(
function()
{
	if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) 
	{ 
		showAlternativeIntro();
	}
	//showAlternativeIntro();
});

$(document).ready(
function()
{
	$("#freeatm").click(
		function()
		{
			window.location = "/free_atm_program";	
		}
	);
	$("#blowout").click(
		function()
		{
			window.location = "/retail_atm_catalog";	
		}
	);
});

function loadCaseStudy_botc()
{
	window.location = "/ATM_USA_BOTC_case_study.pdf";
}
function loadCaseStudy_ss()
{
	window.location = "/ATM_USA_Simply_Service_case_study.pdf";
}
function loadCaseStudy_cf()
{
	window.location = "/ATM_USA_Crystal_Flash_case_study.pdf";
}
function loadCaseStudy_dillards()
{
	window.location = "/ATM_USA_Dillards_case_study.pdf";
}


function showAlternativeIntro()
{
	$("#menu").show();
	$("#submenu").show();
	$("object").hide();
	$("#header").css("height", "112px");
	$("#searchbox").css("margin-top", "-28px");
	$("#feature_content").css("height", "190px");
	$("#feature_content").css("width", "900px");
	$("#feature_content").css("background", "url(/img/inside_banner.png) no-repeat 10px 0px");
	$("#threepanel").css("margin-top", "200px");
}


