 
// NXG 2011

var currentPosition;
var currentRemaining;
var currentVolume;
var currentItem;
var currentState;
var currentLoad;
var currentXsize;
var currentYsize;

function sendEvent(typ,prm) { thisMovie("playerID").sendEvent(typ,prm); };

function getUpdate(typ,pr1,pr2,swf,pid) { 

	if(typ == "time") { currentPosition = pr1; pr2 == undefined ? null: currentRemaining = Math.round(pr2); }
	else if(typ == "volume") { currentVolume = pr1; } 
	else if(typ == "item") { currentItem = pr1; setTimeout("getItemData(currentItem)",100);}
	else if(typ == "state") { currentState = pr1; }
	else if(typ == "load") { currentLoad = pr1; }
	else if(typ == "size") { currentXsize = "X=" + pr1; pr2 == undefined ? null: currentYsize = "Y=" + Math.round(pr2); } 
	var tmp = document.getElementById("pid"); if ((tmp)&&(swf != "null")) { tmp.innerHTML = "(received from the player with the id: <i><b>"+swf+"</b></i>)"; } 
	var tmp = document.getElementById("time"); if (tmp) { tmp.innerHTML = "<b>Time:</b> " + currentPosition + "&nbsp;&nbsp;<b>Remaining:</b> " + currentRemaining; } 
	var tmp = document.getElementById("volume"); if (tmp) { tmp.innerHTML = "<b>Volume:</b> " + currentVolume; } 
	var tmp = document.getElementById("item"); if (tmp) { tmp.innerHTML = "<b>Item:</b> " + currentItem; } 
	var tmp = document.getElementById("state"); if (tmp) { tmp.innerHTML = "<b>State:</b> " + currentState + "&nbsp;&nbsp; (0:ready/paused, 1:loading, 2:playing, 3:finished)"; } 
	var tmp = document.getElementById("load"); if (tmp) { tmp.innerHTML = "<b>Load:</b> " + currentLoad; }
	var tmp = document.getElementById("size"); if (tmp) { tmp.innerHTML = "<b>Size:</b> " + currentXsize + ", " + currentYsize; } 

if(pid != "null") {
if((typ == "state")&&(pr1 != undefined)) { 
currentState = pr1; 
if(currentState=="3") { document.location.href="javascript:parent.Flashclose.closing()"; }
}
}
};

function getItemData(idx) {
	var obj = thisMovie("playerID").itemData(idx);

	var tmp = document.getElementById("file"); if (tmp) { tmp.innerHTML = "<b>File:</b> " + obj["file"]; } 
	var tmp = document.getElementById("title"); if (tmp) { tmp.innerHTML = "Now playing: " +  obj["title"]; } 
	var tmp = document.getElementById("link"); if (tmp) { tmp.innerHTML = "<b>Link:</b> " + obj["link"]; } 
	var tmp = document.getElementById("type"); if (tmp) { tmp.innerHTML = "<b>Type:</b> " + obj["type"]; } 
	var tmp = document.getElementById("id"); if (tmp) { tmp.innerHTML = "<b>Id:</b> " + obj["id"]; } 
	var tmp = document.getElementById("image"); if (tmp) { tmp.innerHTML = "<b>Image:</b> " + obj["image"]; } 
	var tmp = document.getElementById("author"); if (tmp) { tmp.innerHTML = "<b>Author:</b> " + obj["author"]; } 
	var tmp = document.getElementById("captions"); if (tmp) { tmp.innerHTML = "<b>Captions:</b> " + obj["captions"]; } 
	var tmp = document.getElementById("audio"); if (tmp) { tmp.innerHTML = "<b>Audio:</b> " + obj["audio"]; } 
	var tmp = document.getElementById("start"); if (tmp) { tmp.innerHTML = "<b>Start:</b> " + obj["start"]; }  
	var tmp = document.getElementById("category"); if (tmp) { tmp.innerHTML = "<b>Category:</b> " + obj["category"]; } 
	var tmp = document.getElementById("description"); if (tmp) { tmp.innerHTML = "<b>Description:</b> " + obj["description"]; } 
	var tmp = document.getElementById("latitude"); if (tmp) { tmp.innerHTML = "<b>Latitude:</b> " + obj["latitude"]; } 
	var tmp = document.getElementById("longitude"); if (tmp) { tmp.innerHTML = "<b>Longitude:</b> " + obj["longitude"]; } 
	var tmp = document.getElementById("city"); if (tmp) { tmp.innerHTML = "<b>City:</b> " + obj["city"]; } 
	var tmp = document.getElementById("date"); if (tmp) { tmp.innerHTML = "<b>Date:</b> " + obj["date"]; }  
};

function loadFile(obj) { thisMovie("playerID").loadFile(obj); };
function addItem(obj,idx) { thisMovie("playerID").addItem(obj,idx); };
function removeItem(idx) { thisMovie("playerID").removeItem(idx); };
function getLength(swf) { return(thisMovie(swf).getLength()); };

function thisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
	return window[movieName];
	} else {
	return document[movieName];
	}
};


function createPlayer(theFile) {
	var s10 = new SWFObject("../js/front_player.swf","playerID","905","20","8", "#050505");
//s10.addParam("allowfullscreen","true");
	s10.addParam("allowscriptaccess","always");
	s10.addVariable("overstretch", "true");
	s10.addParam("wmode", "transparent");
	s10.addVariable("file","../previews/noxgenus_-_moogerfooger.mp3");
	s10.addVariable("title"," ");
	s10.addVariable("linktarget","_self");
	s10.addVariable("backcolor","0x000000");
//	s10.addVariable("controlbar","none");
	s10.addVariable("frontcolor","0x666666");
	s10.addVariable("lightcolor","0xcccccc");
	s10.addVariable("autostart","false");
	s10.addVariable("enablejs","true");
	s10.addVariable("showeq","true");
	s10.addVariable("javascriptid","playerID");
	s10.write("frontplayer");
};

var Flashclose = {
	
	closing: function(){
	closebuttonaudio = document.getElementsByClassName('closeaudio');

	var xz = new Chain();
	var one = function(){
	var slider1 = new Fx.Elements($$("div.slidermovement"));
	slider1.start({
		"0": {
		"height": 3
		},
		"1": {
		"height": 0
		}
	});
	}
	var two = function(){
	closebuttonaudio.setStyle("display", "none");
	}
	xz.chain(one);
	xz.chain(two);
	xz.callChain();
	xz.callChain.delay(800, xz);
	}
	}


	
window.onload=function(){


var path = 'http://www.noxgenus.com/textpattern/';
var style_2, style_base;
 
/* Style 2 */
$('s2').addEvent('click', function(e) {
	e = new Event(e).stop();
 
	if (style_2) style_2.remove();
	new Asset.css(path + 'css.php?n=white', {id: 'style2'});
	style_2 = $('style2');
 
	$('log').setHTML('Inverted<\/span>');
});
 $('s_base').addEvent('click', function(e) {
	e = new Event(e).stop();
 
	if (style_base) style_base.remove();
	new Asset.css(path + 'css.php?n=ajax', {id: 'style_base'});
	style_base = $('style_base');
 
	$('log').setHTML('Standard Black<\/span>');
});


createPlayer()

	shadowblock = document.getElementsByClassName('shadow');
	shadowblock.each(function(el){
	el.style.opacity = '0';
	});

var busy = false, timer, loadedImages = [], shadow = $('shadow'), progress = $('progress'), bar = $E('#progress .bar'); 

var images = [ '../images/252t.jpg','../images/251t.jpg','../images/34t.jpg','../images/bgdot.png','../images/259.jpg','../images/110.jpg','../images/12.jpg','../images/117.jpg','../images/193.jpg','../images/269.jpg','../images/240t.jpg','../images/delicious.png','../images/191t.jpg','../images/231t.jpg','../images/116.jpg','../images/prev_hover.png','../images/257.jpg','../images/264.jpg','../images/193t.jpg','../images/253t.jpg','../images/47t.jpg','../images/12t.jpg','../images/247t.jpg','../images/263.jpg','../images/190.jpg','../images/111t.jpg','../images/34.jpg','../images/nxglogosml.png','../images/prev.png','../images/241t.jpg','../images/248t.jpg','../images/230.jpg','../images/263t.jpg','../images/dat.gif','../images/31t.jpg','../images/191.jpg','../images/192t.jpg','../images/268t.jpg','../images/11t.jpg','../images/113t.jpg','../images/240.jpg','../images/243t.jpg','../images/logo.png','../images/262t.jpg','../images/115t.jpg','../images/magnolia.png','../images/play.png','../images/258t.jpg','../images/189t.jpg','../images/246.jpg','../images/253.jpg','../images/logo_invert.png','../images/176t.jpg','../images/265t.jpg','../images/47.jpg','../images/266t.jpg','../images/192.jpg','../images/235.jpg','../images/189.jpg','../images/234.jpg','../images/bgdot_invert.png','../images/243.jpg','../images/190t.jpg','../images/next.png','../images/230t.jpg','../images/188.jpg','../images/257t.jpg','../images/234t.jpg','../images/188t.jpg','../images/114t.jpg','../images/239.jpg','../images/242.jpg','../images/187.jpg','../images/261t.jpg','../images/233t.jpg','../images/30.jpg','../images/google.png','../images/115.jpg','../images/download.gif','../images/231.jpg','../images/next_hover.png','../images/112.jpg','../images/loadingimage.gif','../images/stumbleupon.png','../images/244.jpg','../images/x.gif','../images/loader.gif','../images/112t.jpg','../images/30t.jpg','../images/260t.jpg','../images/268.jpg','../images/260.jpg','../images/247.jpg','../images/play.gif','../images/108.jpg','../images/235t.jpg','../images/242t.jpg','../images/newsvine.png','../images/251.jpg','../images/cube.gif','../images/114.jpg','../images/116t.jpg','../images/233.jpg','../images/117t.jpg','../images/262.jpg','../images/windowslive.png','../images/113.jpg','../images/play_invert.gif','../images/177t.jpg','../images/258.jpg','../images/246t.jpg','../images/264t.jpg','../images/266.jpg','../images/111.jpg','../images/244t.jpg','../images/108t.jpg','../images/265.jpg','../images/close_hover.png','../images/259t.jpg','../images/11.jpg','../images/252.jpg','../images/176.jpg','../images/229.jpg','../images/twitter.png','../images/close.png','../images/229t.jpg','../images/177.jpg','../images/31.jpg','../images/248.jpg','../images/269t.jpg','../images/110t.jpg','../images/241.jpg','../images/187t.jpg','../images/261.jpg','../images/titelblokje.png','../images/download_invert.gif','../images/239t.jpg','../images/facebook.png','../images/nxglogo.png','../images/x.gif' ];

function imageloader() {

	progress.setStyle('visibility', 'visible');
	new Asset.images(images, {
	onProgress: function(i) {

loadedImages[i] = this;
	var percent = ((i + 1) * progress.getStyle('width').toInt()) / images.length;
	bar.setStyle('width', percent);

	},
	onComplete: function() {
	progress.setStyle('display', 'none');
	var xc = new Chain();
	var zero = function() {
	var shadowfade = function(){
	var div = $('shadow').setStyles({
	display:'block',
	opacity: 0
	});
	new Fx.Style(div, 'opacity', {duration: 1000} ).start(1);
	}
	shadowfade();
	};
	var one = function() {
	var block1fade = function(){
	var div = $('block1').setStyles({
	display:'block',
	opacity: 0
	});
	new Fx.Style(div, 'opacity', {duration: 1000} ).start(1);
	}
	block1fade();
	};

	var six = function() { 
	var footerfade = function(){
	var div = $('footer').setStyles({
	display:'block',
	opacity: 0
	});
	new Fx.Style(div, 'opacity', {duration: 1000} ).start(1);
	}
	footerfade();
	};
	xc.chain(zero);
	xc.chain(one);
xc.chain(six);
	xc.callChain();
	xc.callChain.delay(800, xc);
	xc.callChain.delay(1300, xc);
	xc.callChain.delay(1600, xc);
			
			}
		});
	};

imageloader();

	closebuttonaudio = document.getElementsByClassName('closeaudio');
	closebuttonaudio.addEvent('click', function() {
	var x12 = new Chain();
	var one = function(){
	var videoslider4 = new Fx.Elements($$("div.slidermovement"));
	videoslider4.start({
		"0": {
		"height": 3
		},
		"1": {
		"height": 0
		}
	});
	}
	var two = function(){
	closebuttonaudio.setStyle("display", "none");
	}
	x12.chain(one);
	x12.chain(two);
	x12.callChain();
	x12.callChain.delay(800, x12);
	}
);

$$('a').each(function(el) {
  var menucolors = new Fx.Styles(el, {duration:200, transition: Fx.Transitions.Sine.easeIn, wait:false});

  el.addEvent('mouseenter', function(){
    menucolors.start({
        color: '#ccc'
    });
  });
  el.addEvent('mouseleave', function(){
    menucolors.start({
        color: '#666'
    });
  });
});

$$('.button a.active').each(function(el) {
  var menucolors = new Fx.Styles(el, {duration:200, transition: Fx.Transitions.Sine.easeIn, wait:false});

  el.addEvent('mouseenter', function(){
    menucolors.start({
        color: '#ccc'
    });
  });
  el.addEvent('mouseleave', function(){
    menucolors.start({
        color: '#ccc'
    });
  });
});



var rightfader = $$('.frontimg').setStyles({
	opacity: 0.001
	});

rightfader.each(function(element) {
	var fx = new Fx.Styles(element, {duration:300, wait:false});
	element.addEvent('mouseenter', function(){
		fx.start({
			opacity: '0.95'
		});
	});

	element.addEvent('mouseleave', function(){
	fx.start({
			opacity: '0.001'
		});
	});
	
	element.addEvent('click', function(){
this.removeClass('frontimg');
this.addClass('frontimgactive'); 
opacity: '0.99'
	});
});


//var tips = new Tips($$('.tips'), {
//maxTitleChars: 60,
//fixed: true,
//	initialize:function(){
//		this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
//	},
//	onShow: function(toolTip) {
//		this.fx.start(1);
//	},
//	onHide: function(toolTip) {
//		this.fx.start(0);
//	}
//  });

//LOAD HOME PAGE

if (document.referrer.indexOf('http://www.noxgenus.com/') > -1){
var ref = document.referrer;
getstuff(ref,'leftside');

} else {

getstuff('../frontpage/','leftside');

};

}
function getstuff(url, div){

	var fadefx = new Fx.Styles(div, {wait: true, duration: 500, transition: Fx.Transitions.Back.easeInOut});
	fadefx.start({ 'opacity': [1, 0]});
    
	
//START AJAX INSIDE

function onrequesting() {
$('feedbackloader').setHTML('<div class="loading"><p class="loadingtxt">Retrieving content from database <img src="../images/cube.gif" alt="cube" /></p></div>');
var footerslider1 = new Fx.Styles($("footer"), {wait: false, duration: 500, transition:Fx.Transitions.Back.easeInOut});
footerslider1.start({ 'opacity': [1, 0]});	

}

function onfailing() {
$('feedbackloader').setHTML('<div class="loading"><p class="loadingtxt">Error - database unavailable!</p></div>');
var footerslider2 = new Fx.Styles($("footer"), {wait: false, duration: 500, transition:Fx.Transitions.Back.easeInOut});
footerslider2.start({ 'opacity': [1, 0]});
}

function oncancelling() {
$('feedbackloader').setHTML('<div class="loading"><p class="loadingtxt">Request was cancelled by user</p></div>');
var footerslider2 = new Fx.Styles($("footer"), {wait: false, duration: 500, transition:Fx.Transitions.Back.easeInOut});
footerslider2.start({ 'opacity': [1, 0]});
}

function displaypage() {

url = url.replace(/^[^\/]*(?:\/[^\/]*){2}/, "/#");
window.location=('http://www.noxgenus.com' + url);

$('feedbackloader').setHTML('<div class="loading">Content loaded. ready.</div>');
var footerslider3 = new Fx.Styles($("footer"), {wait: false, duration: 2000, transition:Fx.Transitions.Back.easeInOut});
footerslider3.start({ 'opacity': [0, 1]});

var fadefx = new Fx.Styles(div, {wait: false, duration: 1500, transition:Fx.Transitions.Back.easeInOut});

fadefx.start({ 'opacity': [0, 1]});


$$('#shadow a').each(function(el) {
  var menucolors = new Fx.Styles(el, {duration:200, transition: Fx.Transitions.Sine.easeIn, wait:false});

  el.addEvent('mouseenter', function(){
    menucolors.start({
        color: '#ccc'
    });
  });
  el.addEvent('mouseleave', function(){
    menucolors.start({
        color: '#666'
    });
  });
});
$$('#shadow a.active').each(function(el) {
  var menucolors = new Fx.Styles(el, {duration:200, transition: Fx.Transitions.Sine.easeIn, wait:false});

  el.addEvent('mouseenter', function(){
    menucolors.start({
        color: '#ccc'
    });
  });
  el.addEvent('mouseleave', function(){
    menucolors.start({
        color: '#ccc'
    });
  });
});

	openbuttonaudio = document.getElementsByClassName('play');

	openbuttonaudio.addEvent('click', function() {
	var x11 = new Chain();
	var two = function(){
	var videoslider2 = new Fx.Elements($$("div.slidermovement"));
	videoslider2.start({
		"0": {
		"height": 3
		},
		"1": {
		"height": 43
		}
	});	
	}
	var three = function(){
	closebuttonaudio.setStyle("display", "block");
	}
	x11.chain(two);
	x11.chain(three);
	x11.callChain();
	x11.callChain.delay(800, x11);
	}
);


$$('#articleajax a.togglerarticle').each(function(el) { 
	})
	myStretch = document.getElementsByClassName('togglerarticle');
	myStretcher = document.getElementsByClassName('entry');
	
	myStretcher.each(function(el){
		el.style.display = 'block';
	});
	
var ac = new Fx.Accordion(myStretch,myStretcher,
 
  {
		onActive: function(tog){
        tog.setStyle('color', '#666');
		tog.setStyle('background-color', 'transparent');
    },
		alwaysHide: true,
		start : 'all-closed',
		height: true,
		opacity : false			
	});


new Asset.javascript('../js/mediabox.js');
new Asset.javascript('../js/swfobject.js');
new Asset.javascript('../js/slimbox_vixed.js');
		

$$('#contentloader').each(function(el) {
	})	
	loader = document.getElementsByClassName('contentloader');		
	loader.each(function(el){
	el.style.display = 'block';
	}	
	);
	
$$('#entryloader').each(function(el) { 
	})	
	loaderblok = document.getElementsByClassName('entryloader');	
	loaderblok.each(function(el){
	el.style.display = 'none';
	}
	);
	// Article SLIDER SETTINGS
	}
	//end oncomplete routine
    
	
(function(){	

	var ajax = new Ajax(url, {
	onRequest: onrequesting,
	onFailure: onfailing,
	onComplete:displaypage,
	onCancel: oncancelling,
    
	method:'get', 
	evalScripts: true,
 // evalResponse: false,
	update:div
	}).request();
	}).delay(500);
	
// CLOSING WINDOW ONLOAD	
	};

// END OF FILE. and a moo moo here and a moo moo there
