// JavaScript Document
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Roll over and style sheet
window.addEvent('domready', function() {
																		 
	var aPreLoad = new Array();
	var aPreLoadi = 0;
	
	$$('img.roll').each(function(el){
		aPreLoad[aPreLoadi] = new Image();
		aPreLoad[aPreLoadi].src = el.src.replace(el.src.replace('_off_', '_on_'));
		aPreLoadi++;
	
		el.addEvent('mouseover',function(){
			this.setAttribute('src',this.src.replace('_off_', '_on_'));
		});
	
		el.addEvent('mouseout',function(){
			this.setAttribute('src',this.src.replace('_on_','_off_'));
		});
	});
});

// Right side banners animation
window.addEvent("domready", function() {
	var list = $$('#idList li');
	list.each(function(element) {
		var fx = new Fx.Tween(element, {duration:100, wait:false});

		element.addEvent('mouseenter', function(){
			fx.start('margin-left',0);
		});
	 
		element.addEvent('mouseleave', function(){
			fx.start('margin-left', -5);
		});
	 
	});
});

if(typeof(noShadowbox) == "undefined") {
	// Shadowbox
	Shadowbox.loadSkin('classic', '../_styles/skin'); 
	Shadowbox.loadLanguage('en', '../_java/shadowbox/lang'); 
	Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'swf'], '../_java/shadowbox/player'); 
	window.addEvent("domready", function() {
			Shadowbox.init();
	});
}

function changeLanguage()
{
	window.location = '../changeLanguage.php?referer='+window.location.href;
	return false;
}

// switch stylesheet
function getAllSheets() {
	if( !window.ScriptEngine && navigator.__ice_version ) { return document.styleSheets; }
	if( document.getElementsByTagName ) { var Lt = document.getElementsByTagName('link'), St = document.getElementsByTagName('style');
	} else if( document.styleSheets && document.all ) { var Lt = document.all.tags('LINK'), St = document.all.tags('STYLE');
	} else { return []; } for( var x = 0, os = []; Lt[x]; x++ ) {
		var rel = Lt[x].rel ? Lt[x].rel : Lt[x].getAttribute ? Lt[x].getAttribute('rel') : '';
		if( typeof( rel ) == 'string' && rel.toLowerCase().indexOf('style') + 1 ) { os[os.length] = Lt[x]; }
	} for( var x = 0; St[x]; x++ ) { os[os.length] = St[x]; } return os;
}
function changeStyle() {
	window.userHasChosen = window.MWJss;
	for( var x = 0, ss = getAllSheets(); ss[x]; x++ ) {
		if( ss[x].title ) { ss[x].disabled = true; }
		for( var y = 0; y < arguments.length; y++ ) { 
			if( ss[x].title == arguments[y] ) { 
				ss[x].disabled = false; 
			} 
		}
	}
	rememberStyle('styleTestStore');
	
	var s = arguments[0];
	
	var ul = $('sizeChange');
	if (s == 'big') {
		ul.getElement('.small a').removeClass('current');
		ul.getElement('.normal a').removeClass('current');
		ul.getElement('.big a').addClass('current');
	} else if (s == 'normal') {
		ul.getElement('.small a').removeClass('current');
		ul.getElement('.normal a').addClass('current');
		ul.getElement('.big a').removeClass('current');
	} else {
		ul.getElement('.small a').addClass('current');
		ul.getElement('.normal a').removeClass('current');
		ul.getElement('.big a').removeClass('current');
	}
}
function rememberStyle( cookieName, cookieLife ) {
	for( var viewUsed = false, ss = getAllSheets(), x = 0; window.MWJss && MWJss[x] && ss[x]; x++ ) { if( ss[x].disabled != MWJss[x] ) { viewUsed = true; break; } }
	if( !window.userHasChosen && !viewUsed ) { return; }
	for( var x = 0, outLine = '', doneYet = []; ss[x]; x++ ) {
		if( ss[x].title && ss[x].disabled == false && !doneYet[ss[x].title] ) { doneYet[ss[x].title] = true; outLine += ( outLine ? ' MWJ ' : '' ) + escape( ss[x].title ); } }
	if( ss.length ) { document.cookie = escape( cookieName ) + '=' + escape( outLine ) + ( cookieLife ? ';expires=' + new Date( ( new Date() ).getTime() + ( cookieLife * 86400000 ) ).toGMTString() : '' ) + ';path=/'; }
}
function useStyleAgain( cookieName ) {
	var found = 0;
	for( var x = 0; x < document.cookie.split( "; " ).length; x++ ) {
		var oneCookie = document.cookie.split( "; " )[x].split( "=" );
		if( oneCookie[0] == escape( cookieName ) ) {
			found = 1;
			var styleStrings = unescape( oneCookie[1] ).split( " MWJ " );
			for( var y = 0, funcStr = ''; styleStrings[y]; y++ ) { funcStr += ( y ? ',' : '' ) + 'unescape( styleStrings[' + y + '] )'; }
			eval( 'changeStyle(' + funcStr + ');' ); break;
		}
	}
	if (found == 0) {
		var styleStrings = 'normal';
		//for( var y = 0, funcStr = ''; styleStrings[y]; y++ ) { funcStr += ( y ? ',' : '' ) + 'unescape( styleStrings[' + y + '] )'; }
		//alert(funcStr);
		eval( 'changeStyle("normal");' ); 
	}
	window.MWJss = [];
	for( var ss = getAllSheets(), x = 0; ss[x]; x++ ) { MWJss[x] = ss[x].disabled; }
}
