/* --------------------------------------------------
Onload
-------------------------------------------------- */
function addEvent(elm,listener,fn){
	try{
		elm.addEventListener(listener,fn,false);
	}catch(e){
		elm.attachEvent("on"+listener,fn);
	}
}


/* --------------------------------------------------
Rollover
-------------------------------------------------- */
function initRollovers(){
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'over') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

addEvent(window,"load",initRollovers);


	
/* --------------------------------------------------
Rollover2
-------------------------------------------------- */
$(document).ready(function(){
	$(".home .naviov").hover(function(){
		$(this).css({opacity: 0.6});
 },
 function(){
		$(this).css({opacity: 1.0});
	});
});

$(document).ready(function(){
	$(".home #gNavWorks").hover(function(){
		$(".home #gNavWorks .txt").css({opacity:0.6});
 },
 function(){
		$(".home #gNavWorks .txt").css({opacity:1.0});
	});
});


/*second*/
$(document).ready(function(){
	$("#pageHdr .naviov").css({opacity: 0.55});
	$("#pageHdr .naviov").hover(function(){
		$(this).css({opacity: 1});
 },
 function(){
		$(this).css({opacity: 0.55});
	});
});

$(document).ready(function(){
	$("#pageHdr #gNavWorks .txt").css({opacity: 0.55});
	$("#pageHdr #gNavWorks").hover(function(){
		$("#pageHdr #gNavWorks .txt").css({opacity:1});
 },
 function(){
		$("#pageHdr #gNavWorks .txt").css({opacity:0.55});
	});
});


/* --------------------------------------------------
PNG
-------------------------------------------------- */
if(typeof document.documentElement.style.maxHeight != "undefined"){
	}else{
/*for IE6*/
	DD_belatedPNG.fix('.png');
}


/* --------------------------------------------------
Page Top
-------------------------------------------------- */
$(document).ready(function(){
	$('.pagetop').hide();
	$(window).scroll(function () {
		var ScrTop = $(document).scrollTop();
		if (ScrTop > 200){
			$('.pagetop').fadeIn("fast");
		}
		if (ScrTop < 200){
			$('.pagetop').fadeOut("fast");
		}
	});
	$('.pagetop a').click(function(){
		$('html,body').animate({scrollTop:0},500);
		return false;
	});
});




/* --------------------------------------------------
Popup
-------------------------------------------------- */
addEvent(window,"load",function(){
	var node_a = document.getElementsByTagName('a');
		for (var i in node_a) {
			if(node_a[i].className == 'popup'){
				node_a[i].onclick = function() {
					return winOpen(this.href, this.rel)
				};
			}
		}
});

function winOpen(url, rel) {
	var split = rel.split(',') ;
	window.open(
	url,'popup',
	'width='+ split[0] +',height='+ split[1] +',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');

	return false;
};

