$(function(){

$("img.alp").hover(function(){ 
		$(this).fadeTo(100,0.5); 
	},function() {
		$(this).fadeTo(100,1); 
	});


//smooth scroll
$('a[href*=#]').click(function() {
	var duration=1200;
	var easing='easeOutExpo';
	var newHash=this.hash;
	var target=$(this.hash).offset().top;
	var oldLocation=window.location.href.replace(window.location.hash, '');
	var newLocation=this;
	if(oldLocation+newHash==newLocation){
		$('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function() {
			window.location.href=newLocation;
		});
		return false;
	}
});

//rollover
var postfix = '_ov';
$('img.rollover').not('[src*="'+ postfix +'."]').each(function() {
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.'))
		           + postfix
		           + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_on);
		img.hover(function() {
			img.attr('src', src_on);
		}, function() {
			img.attr('src', src);
		});
	});

var index = new Index();
index.init();

});  //End of doccument ready ////////////



/*----------------------------------------------------
	Index
----------------------------------------------------*/

function Index(){
	var owner = this;
	this.intro = $('#intro');
	this.introImg = $('#intro img.itr');
}

Index.prototype.init = function(){
	var owner = this;
	$(window).bind({
		resize : function(){
			owner._onResize();
		},
		scroll : function(){
			if(utils.getIsAMob()){
				
			}
		}
	});
	
	
	this._onResize();
}


Index.prototype._onResize = function(){
	var owner = this;
	var sw = $(window).width();
	var sh = $(window).height();
	
	if( sw/1280 > sh/854) {
			var scl = sw/1280;
			} else {
				var scl = sh/854;
				}
	
	
	var iw = Math.floor(1280*scl);
	var ih = Math.floor(854*scl);
	var il = Math.floor((sw - iw)*0.5);
	var it = Math.floor((sh - ih)*0.5);
	
	this.introImg.css({
		width : iw +'px',
		left : il +'px',
		top : it +'px'
	});
	
}





// POPUP

var MacIe = navigator.userAgent.indexOf( "Mac" ) > -1 &&  navigator.userAgent.indexOf( "MSIE" ) > -1;
var JsWin;

function popwin( JsUrl, JsWinName, JSWidth, JSHeight ){
	JSWidth = parseInt( JSWidth );
	JSHeight = parseInt( JSHeight );
	if( !MacIe ){ JSWidth = JSWidth + 16; }
	if( MacIe ){ JSWidth = JSWidth - 1 ; }
	JsProperty = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + JSWidth + ",height=" + JSHeight;
	JsWin = window.open( JsUrl, JsWinName, JsProperty );
	if( MacIe ){ return; }
	JsWin.focus();
}

function popwin2( JsUrl, JsWinName, JSWidth, JSHeight ){
	JSWidth = parseInt( JSWidth );
	JSHeight = parseInt( JSHeight );
	JsProperty = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=" + JSWidth + ",height=" + JSHeight;
	JsWin = window.open( JsUrl, JsWinName, JsProperty );
	if( MacIe ){ return; }
	JsWin.focus();
}

