var globalOpen; 
var localHeight=0;
var sc=0;

//if (window.ActiveXObject) window.ie = window[window.XMLHttpRequest ? 'ie7' : 'ie6'] = true;
//Else if (document.childNodes && !document.all && !navigator.taintEnabled) window.khtml = true;

function getScrollHeight() {
 if(jQuery.browser.msie) return Math.max(document.documentElement.offsetHeight, document.documentElement.scrollHeight);
 if(jQuery.browser.safari) return document.body.scrollHeight;
 return document.documentElement.scrollHeight; 
}


function writeFlash() { 
 tmpHeight = getScrollHeight();  
 if (localHeight != tmpHeight) {
  localHeight = tmpHeight;
  setTimeout("writeFlash()", 600);
  return;
 } else {
  var fo = new SWFObject("/images/layout/header_cont.swf", "header_cont", '100%', tmpHeight, "7", "#e5e2d1"); 
  fo.useExpressInstall('javascript/expressinstall.swf'); 
  fo.addParam("wmode", "transparent"); 
  fo.addParam("allowScriptAccess", "sameDomain"); 
  fo.write("flash_header"); 
 }
 jQuery('#flash_header').css('height', getScrollHeight()).css('overflow', 'hidden');
}

function WriteMenu () {
 var foo = new SWFObject("/images/layout/flyover_menu.swf", "flyover_menu", '980', '250', "7", "#ffffff"); 
 foo.addParam("wmode", "transparent"); 
 foo.addParam("allowScriptAccess", "sameDomain"); 
 foo.write("flyover"); 
}

function toggleEffect() { 
 if (!globalOpen) {
  jQuery('#changeMe').animate({
       "height": "show",  "opacity": "show"
    }, "slow", "linear", function(){isOpen()} );
 }
}

function isOpen() { globalOpen = true;}
function isClosed() { globalOpen = false;}

function onLeave(e) {
  if (globalOpen) {
  jQuery('#changeMe').animate({
       "height": "hide",  "opacity": "hide"
    }, "slow", "linear", function(){isClosed()} );  	
  }
}

function isset(varname)  {
  if(typeof( window[ varname ] ) != "undefined") return true;
  else return false;
}

function s() {sc = 1;}

function focus_menu() {
	if(sc==1) WriteMenu();
	sc=0;
}

function focus_item(o) {
	jQuery(o).css("background","#EEE");
	jQuery(o).css("border-top","5px solid #CCC");
}

function blur_item(o) {
 	jQuery(o).css("background","#fff");
	jQuery(o).css("border-top","5px solid #FFF");
}


function show_tooltip(top,left) {
	jQuery('#tooltip').css('top',(top-170)+'px');
	jQuery('#tooltip').css('left',(left-310)+'px');
	//jQuery('#tooltip').toggle();
}


jQuery(document).ready(function() {
									
	jQuery('.anchored').click(function(){
		jQuery.scrollTo( jQuery(this).attr("href"), 800, { easing:'easeOutQuad' });
		return false;
	});
								
	jQuery('.goTop').click(function(){
		jQuery.scrollTo( jQuery("#top"), 800, { easing:'easeOutQuad' });
		return false;
	});
								
  jQuery('#logo').pngFix();
  jQuery('.front-portfolio-item').bind('mouseover', function() {focus_item(this)});	
  jQuery('.front-portfolio-item').bind('mouseout', function() {blur_item(this)});
  jQuery('.front-portfolio-item-right').bind('mouseover', function() {focus_item(this)});	
  jQuery('.front-portfolio-item-right').bind('mouseout', function() {blur_item(this)});  
  jQuery('#horizon').after("<div id='tooltip' style='position:absolute;z-index:200;'><a href='javascript:;' style='background:none;'><img src='images/message.png' border='0'></a></div>");
  
  jQuery('.brandbanner').mouseover(function(e){jQuery('#tooltip').toggle();	});
  jQuery('.brandbanner').mousemove(function(e){show_tooltip(e.pageY,e.pageX); });
  jQuery('.brandbanner').mouseout(function(e){jQuery('#tooltip').toggle();});
  jQuery('#tooltip').click(function(e){	show_tooltip(e.pageY,e.pageX); });
  jQuery('#tooltip').pngFix();
  jQuery('#tooltip').hide();

	if (typeof(weHaveForm) != 'undefined' ) {new FormValidator('ajxForm');}
})