jQuery.require= (function(){
	var jspath = $('script[src]:last').attr('src');
	var dirpath = /.+\//.exec(jspath)[0];
	var bundlerpath = 'bundle.js.php';
	var loadJS = function(filename,addExt){
		if(!/\js$/.test(filename) && addExt){filename += '.js'}
		if(/^http/.test(filename)){dirpath = ''}
		document.write('<script type="text/javascript" src="' + dirpath + filename + '"><\/script>');
	}

	return function(jsfiles,bundle,debug){
		if(bundle){
			var pathPreFix = bundlerpath + '?files=';
			if(debug){
				var pathPostFix = '&debug=true';
			}
			loadJS(pathPreFix + jsfiles.join(',') + pathPostFix);
		}else if(jsfiles.join){
			for(var i=0,l=jsfiles.length;i<l;i++){
				loadJS(jsfiles[i],1);
			}
		}else{
			loadJS(jsfiles,1);;
		}
	}
})();

//$.require('https://getfirebug.com/firebug-lite.js');
//$.require('ie-css3');

var els = "header,footer,nav,section,hgroup,figure,figcaption,article,time".split(',');
for (var i=0; i < els.length; i++) {
	document.createElement(els[i]);
}


$.require([
	//'modernizr.min',
	'iepp',
	'jquery.cookie',
	//'ie-css3',
	'jquery.browser.addEnvClass',
	'jquery.effects.core',
	//'jquery.backgroudPosition',
	'jquery.fixIePng',
	'jquery.scrollTo',
	'jquery.localScroll',
	'libs',
	'jquery.rollover',
	'jquery.notify',
	'jquery.initInput',
	//'jquery.tinyTips',
	'jquery.masonry.min'
	//'init'
]);


//$.require('bundle.min');

$(function(){

	//detect IE or return its version.
	var isIE = function(ver){
		if($.browser.msie){
			if(ver && $.browser.version == ver){
				return true;
			}else if(ver){
				return false;
			}else{
				return $.browser.version;
			}
		}else{
			return false;
		}
	}

	//textResizer
	$('#textResizer').textResizer($.cookie('textSize'));
	
	//image rollover
	$('.rollover').rollover('_on');

	//socialPost
	//$('.socialLinks').socialPost()
	$('#siteBody .socialLinks').socialShare({mixiKey:'0764ab627fb2fb6b1458b6a6bf15a8f524e86811'})
	
	//fix rounded corner
	if($.browser.msie){
		$('.rounded .navButtonGroup')
			.fixRoundedCorner()
			.find('.tl,.tr,.bl,.br')
				.fixIePng();
	}
	
	//internal page scroll
	$('#siteBody, #siteFooter').localScroll({hash:true,easing:'easeOutExpo'});
	
	//equalize hights
	//if(!isIE() || isIE() > 7){
	//	//$('.siteFooter .footerNav').equalHeights();
	//}
	
	/**
	 * component helper
	 */
	
	//contentNavSnippet
	$('.contentNavSnippet')
		.bind('mouseenter mouseleave',function(){
			$(this).toggleClass('hover');
		});

	$('.contentNavSnippet_wide')
		.bind('mouseenter mouseleave',function(){
			$(this).toggleClass('contentNavSnippet_wide.hover');
		});
	
	$('.contentNavSnippet_short')
		.bind('mouseenter mouseleave',function(){
			$(this).toggleClass('contentNavSnippet_short.hover');
		});
	
	if(isIE()){
		try {
			document.execCommand('BackgroundImageCache',false,true);
		} catch(err){}
		$(window).bind("unload", function(){
			$('*').add(document).unbind();
		});
	}
	
	if(isIE() < 7){
		//$(window).load(function(){
			$('#siteBody .alpha:not(.fixedBgPng)').fixIePng();
			//CONFLICT with PIE!!
			//$('#siteBody').fixIeFormClass();
		//})
	}
})

$(window).load(function(){
	//masonry
	var masonrize = function(colwidth){
		$('.masonry').masonry({columnWidth:colwidth});
		$('body').bind('textResize',function(){$('.masonry').masonry({columnWidth:colwidth})})
	}
	masonrize(221);
})

/*openWindow*/
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
