// clickable <li>s from first <a> within each <li>
function convertRowsToLinks(theID){
	var container, rows, link, i;
	
	container = document.getElementById(theID);
	if (!container) return false;

	rows = container.getElementsByTagName("li");
	if (!rows) return false;
	
	for(i=0;i<rows.length;i++){
		link = rows[i].getElementsByTagName("a");
	  
		rows[i].onclick = new Function("document.location.href='" + link[0].href + "'");
		rows[i].className+=rows[i].className?' linked':'linked';
		rows[i].onmouseover=function() { this.className+=" hover"; }
		rows[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" hover\\b"), ""); }
	}
}

// sIFR configuration
var DinMed = { 
	src: '/wp-content/themes/xplane/swf/DIN-Medium.swf'
	,ratios: [8, 1.42, 9, 1.33, 12, 1.35, 15, 1.3, 19, 1.28, 27, 1.27, 28, 1.25, 32, 1.26, 33, 1.24, 34, 1.25, 48, 1.24, 52, 1.23, 53, 1.24, 73, 1.23, 76, 1.22, 77, 1.23, 81, 1.22, 82, 1.23, 1.22]
    ,wmode: 'transparent'	
	};
	
sIFR.forceTextTransform = true;
sIFR.useStyleCheck = true;
sIFR.activate(DinMed);

var sIFR_root = '.sIFR-root { color: #000000; font-size: 18px; text-transform: uppercase; }';

sIFR.replace(DinMed, {
	selector: '.work #nav-work, .work #nav-local .current_page_item, .work #nav-local .current_page_ancestor'
	,css: [
	  sIFR_root
      ,'a:link { color: #3777BC; }'
      ,'a:hover { color: #3777BC; }'
	]
	,offsetTop: -6 ,tuneHeight: -13
})

sIFR.replace(DinMed, {
	selector: '.work #nav-local li'
	,css: [
	  sIFR_root
      ,'a:link { color: #c5c5c5; }'
      ,'a:hover { color: #3777BC; }'
	]
	,offsetTop: -6 ,tuneHeight: -13
})

sIFR.replace(DinMed, {
	selector: '#nav-work'
	,css: [
	  sIFR_root
      ,'a:link { color: #000000; }'
      ,'a:hover { color: #3777BC; }'
	]
	,offsetTop: -6 ,tuneHeight: -13
})

sIFR.replace(DinMed, {
	selector: '.company #nav-company, .company #nav-local .current_page_item, .company #nav-local .current_page_parent, .company #nav-local .current_page_ancestor'
	,css: [
	  sIFR_root
      ,'a:link { color: #C37134; }'
      ,'a:hover { color: #C37134; }'
	]
	,offsetTop: -6 ,tuneHeight: -13
})

sIFR.replace(DinMed, {
	selector: '.company #nav-local li'
	,css: [
	  sIFR_root
      ,'a:link { color: #c5c5c5; }'
      ,'a:hover { color: #C37134; }'
	]
	,offsetTop: -6 ,tuneHeight: -13
})

sIFR.replace(DinMed, {
	selector: '#nav-company'
	,css: [
	  sIFR_root
      ,'a:link { color: #000000; }'
      ,'a:hover { color: #C37134; }'
	]
	,offsetTop: -6 ,tuneHeight: -13
})

sIFR.replace(DinMed, {
	selector: '.community #nav-community, .community #nav-local .current_page_item, .community #nav-local .current_page_ancestor'
	,css: [
	  sIFR_root
      ,'a:link { color: #8FB73E; }'
      ,'a:hover { color: #8FB73E; }'
	]
	,offsetTop: -6 ,tuneHeight: -13
})

sIFR.replace(DinMed, {
	selector: '.community #nav-local li'
	,css: [
	  sIFR_root
      ,'a:link { color: #c5c5c5; }'
      ,'a:hover { color: #8FB73E; }'
	]
	,offsetTop: -6 ,tuneHeight: -13
})

sIFR.replace(DinMed, {
	selector: '#nav-community'
	,css: [
	  sIFR_root
      ,'a:link { color: #000000; }'
      ,'a:hover { color: #8FB73E; }'
	]
	,offsetTop: -6 ,tuneHeight: -13
})

sIFR.replace(DinMed, {
	selector: '.community #nav-community, .community #nav-local .current_page_item, .community #nav-local .current_page_ancestor'
	,css: [
	  sIFR_root
      ,'a:link { color: #77787B; }'
      ,'a:hover { color: #77787B; }'
	]
	,offsetTop: -6 ,tuneHeight: -13
})


sIFR.replace(DinMed, {
	selector: '.contact #nav-contact, .contact #nav-local .current_page_item, .contact #nav-local .current_page_ancestor'
	,css: [
	  sIFR_root
      ,'a:link { color: #77787B; }'
      ,'a:hover { color: #77787B; }'
	]
	,offsetTop: -6 ,tuneHeight: -13
})

sIFR.replace(DinMed, {
	selector: '.nav li'
	,css: [
	  sIFR_root
      ,'a:link { color: #000000; }'
      ,'a:hover { color: #77787B; }'
	]
	,offsetTop: -6 ,tuneHeight: -13
});

sIFR.replace(DinMed, {
	selector: '.home #latest h5'
	,css: [
	  sIFR_root
	  ,'.sIFR-root { color: #3E5684; font-size: 13px; }'
	]
	,offsetTop: -4 ,tuneHeight: -12
});

sIFR.replace(DinMed, {
	selector: '.home #latest h4'
	,css: [
	  sIFR_root
	  ,'.sIFR-root { font-size: 21px; }'
	]
	,offsetTop: -7 ,tuneHeight: -15
});

sIFR.replace(DinMed, {
	selector: '#latest h4'
	,css: [
	  sIFR_root
	  ,'.sIFR-root { leading: -2; }'
	]
	,offsetTop: -6 ,tuneHeight: -13
});

// initialize scripts
window.addEvent('domready', function() {
	convertRowsToLinks("solutions");
	
	var validator;
	if ($('form-contact-us') != null) {
		validator = new FormValidator.Inline($('form-contact-us'), {
			onFormValidate: function(passed, form, event) {
				if (!passed) {
					//if we DON'T pass validation block the normal submission errors will show
					event.preventDefault();
				} else {
					//validation passed and the form will be submitted now
				}
			}
		});		
	}
});

jQuery(document).ready(function() {
	if( jQuery.cookie('ack_dachis') == null ) {	
		
		var dachisBlur = jQuery('#dachis-blur');
		var documentHeight = jQuery(document).height() - jQuery('#dachis-wide').height();
		dachisBlur.height(documentHeight);
		
		dachisBlur.fadeIn();
		jQuery('a.ok-badge').live('click', function() { 
			jQuery('#dachis-blur').fadeOut(); 
			jQuery.cookie('ack_dachis', 'yes', {expires: 3});
		});
	}	
});
