/***********************************************
* Encrypt Email script- Please keep notice intact.
* Tool URL: http://www.dynamicdrive.com/emailriddler/
    caffeinated by mr_coffee ...
    btw... document.write is lazy.
* **********************************************/

function mrcoffeeemail() {
  var aLink = $('mrcoffeeemail');
  if (aLink){
    var emailriddlerarray=[109,114,99,111,102,102,101,101,64,109,114,99,111,102,102,101,101,46,119,115];
    var encryptedemail_id61=''; //variable to contain encrypted email 
    for (var i=0; i<emailriddlerarray.length; i++) encryptedemail_id61+=String.fromCharCode(emailriddlerarray[i]);
    
    var altLink = document.createElement("span");
    altLink.innerHTML = '<a href="mailto:'+encryptedemail_id61+'?subject=re: newcreationmusic.us" title="Contact the Webmaster">Contact the Webmaster</a>';
    aLink.parentNode.replaceChild(altLink, aLink);
  }
}

/*
	End obufscated e-mail functions
*/

function fixforsmallscreens() {	
	$$('img').each(function(el){
		if(el.src.test(/1024x768/))	el.src = el.src.replace('1024x768','800x600');		
	});
	$$('body').setStyles({
		'background':"#FFFFFF url('http://andy.newcreationmusic.us/images/back_800x600.jpg') no-repeat fixed -30px -120px",
		'margin':'15px'
	});
	$('navigation').setStyles({
		'top':'15px',
    'left':'490px'
	});
	$$('#navigation a').setStyle('height','52px');
	$$('#navigation a').each(function(el){
		el.addEvent('mouseover', function() {
			this.setStyle('background-position','0px -52px');
		});
		el.addEvent('mouseout', function() {
			this.setStyle('background-position','0px 0px');
		});
	});	
	$$('#navigation .home_link').setStyles({
		'width':'137px',
    'background':'url(http://andy.newcreationmusic.us/images/home_800x600.png) 0px 0px no-repeat'
	});
	$$('#navigation .photo_link').setStyles({
		'top':'61px',
    'left':'45px',
		'width':'137px',
    'background':'url(http://andy.newcreationmusic.us/images/photos_800x600.png) 0px 0px no-repeat'
	});
	$$('#navigation .links_link').setStyles({
		'top':'133px',
    'left':'68px',
		'width':'120px',
    'background':'url(http://andy.newcreationmusic.us/images/links_800x600.png) 0px 0px no-repeat'
	});
	$$('#navigation .order_link').setStyles({
		'top':'212px',
    'left':'65px',
		'width':'138px',
    'background':'url(http://andy.newcreationmusic.us/images/order_800x600.png) 0px 0px no-repeat'
	});
	$$('#navigation .discography_link').setStyles({
		'top':'287px',
    'left':'34px',
		'width':'227px',
    'background':'url(http://andy.newcreationmusic.us/images/discography_800x600.png) 0px 0px no-repeat'
	});
	$$('#navigation .contact_link').setStyles({
		'top':'344px',
    'left':'-20px',
		'width':'175px',
    'background':'url(http://andy.newcreationmusic.us/images/contact_800x600.png) 0px 0px no-repeat'
	});
	
	$$('.homelogo').setStyles({  
  	'top':'15px',
  	'left':'170px'
	});
	$$('.copyright').setStyles({
  	'top':'410px',
  	'left':'15px'  
	});
	if ($('digits')){
		$('digits').setStyles({  
	  	'top':'375px',
	  	'left':'35px'  
		});	
	};
	$$('#container .pageinfo').setStyles({    	
  	'max-height':'350px',
  	'height':'350px',
  	'max-width':'450px',
  	'width':'450px'  
	});
}

function fixietransparency() {	
	// fix all imges in document
	$$('img').each(function(el){
		if(el.src.test(/\.png$/i)){
			var tempimage = new Image();
			tempimage.src = el.src;						
			el.setProperty('width',tempimage.width);
			el.setProperty('height',tempimage.height);
			el.setStyle('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled="true", sizingMethod="crop", src="' + el.src + '")');
			el.setProperty('src','http://andy.newcreationmusic.us/images/blank.gif');
		}
	});

	// fix navigation rollovers
	$$('#navigation a').each(function(el,i){		
		el.setStyle('visibility','hidden');
		var imageurl = el.getStyle('background-image').match(/((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^\"\'\)#?\s]+)(.*)?(#[\w\-]+)?/i);		
		var ieup = RegExp.$2 + '://' + RegExp.$3 + RegExp.$4 + RegExp.$6;
		var iedown = RegExp.$2 + '://' + RegExp.$3 + RegExp.$4 + RegExp.$6.replace(/^([^_]+)_([^_]+)$/,"$1"+"_ie_down_"+"$2");

		var filterup = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled="true", sizingMethod="crop", src="' + ieup + '")';
		var filterdown = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled="true", sizingMethod="crop", src="' + iedown + '")';

		// set default state image
		if ((i == 0) && ($('homepage'))) {  // if on homepage iteration.
			el.setStyle('filter',filterdown);
		} else if (!document.location.toString().match(el.href)) {		
			el.setStyle('filter',filterup);
		}	else {
			el.setStyle('filter',filterdown);			
		}

		// repair rollover images for ie6 only
		el.addEvents({
			mouseover: function() {
				el.setStyle('filter',filterdown)
			},
			mouseout: function() {
				if (!document.location.toString().match(el.href)) el.setStyle('filter',filterup)
			}
		});

		// set 'final' image for ie background (clear original value)
		el.setStyle('background-image','url(http://andy.newcreationmusic.us/images/blank.gif)');			
	});	
}


function createNav(){
	/* visual slide-in effect for navigational buttons */
	var mySliderChain = new Chain();
	var mySliders = new Array;

	$$('#navigation a').each(function(el, i) {		
		// display "selected" state of current page		
		if ((((i == 0) && $('homepage')) || (document.location.toString().match(el.href))) && ((!window.ie) || (window.ie7))) {			
			if (window.getWidth() < 950 )	el.setStyle('background-position','0px -52px');
			else el.setStyle('background-position','0px -66px');
		}		
				
		el.setStyle('visibility','hidden');

		mySliders[i] = new Fx.Styles( el.id, {duration: 900});
		mySliderChain.chain(function(){
			el.setStyle('visibility','visible');
			var leftvalue = el.getStyle('left');      
      if (leftvalue == "auto") leftvalue = "0px"; // fix for ie7 and Safari
			el.setStyle('left',window.getWidth());
			mySliders[i].start({left: [window.getWidth(), leftvalue]});
			mySliders[i].addEvent('onComplete', function(){mySliderChain.callChain(mySliderChain)});
		});
	});
	mySliderChain.callChain(mySliderChain);
}


Window.addEvent('domready', function() {
	if (window.getWidth() < 950) fixforsmallscreens();
	
	// this part is here to keep the left to right scroll bar from appearing during animations
	$$('body').setStyles({
		'width':window.getWidth(),
		'max-width':window.getWidth(),
		'overflow':'hidden'
	});

	if ((window.ie) && (!window.ie7)) fixietransparency();

	createNav();
});