// Copyright (c) 2000-2003 Classical Archives, LLC. All rights reserved.
//var cma_domain

var av = navigator.appVersion.toUpperCase();
var ua = navigator.userAgent.toUpperCase();
var an = navigator.appName.toUpperCase();
var win = (av.indexOf('WIN') != -1) ? true : false; // Windows
var mac = (av.indexOf('MAC') != -1) ? true : false; // Mac
var XP = (win && av.indexOf('XP') != -1) ? true : false; // XP
var webtv = (ua.indexOf("WEBTV") != -1) ? true : false; // WebTV
var ie = (ua.indexOf("IE") != -1) ? true : false; // ie
var ie55 = (ie && av.indexOf(5.5) != -1) ? true : false; // ie 5.5
var ie6 = (ie && parseInt(av) >= 6) ? true : false; // ie 6+
var ns = (an.indexOf('NETS') != -1) ? true : false; // Netscape
var ns6 = (ns && parseInt(av) >= 5) ? true : false; // Netscape 6+
var opera = (ua.indexOf("OPERA") != -1) ? true : false; // opera
var aol = (ua.indexOf("AOL") != -1) ? true : false; // AOL

var msg_ticket_right =		"Please left-click on this link. Note that ticketed concerts cannot be downloaded as a batch.\n\nPlease click OK to close this message.";
var msg_ticket_login =		"You need to be a logged-in paying subscriber to benefit from the One-click Concert feature.\nHowever you may click on each individual link to listen to the files, but each click counts towards the daily limit.\n\nPlease click OK to login as a paying subscriber or Cancel to close this message.";
var msg_ticket_subscribe =	"You must be a logged-in paying subscriber to benefit from the One-click Concert feature.\nHowever you may click on each individual link to listen to the files, but each click counts towards the daily limit.\nSubscribe today: One-click Concerts count only as one file - even when the concert offers several hours of great music!\n\nPlease click OK to subscribe or CANCEL to close this message.";
var msg_wma_right =			"Please left-click on this link. Note that WMA are streams which cannot be saved.\n\nPlease click OK to close this message.";
var msg_send_right =		"Please left-click on this link.\n\nPlease click OK to close this message.";
var msg_sub_sign_in =		"You must be a logged-in paying subscriber to access this file.\n\nPlease click OK to login as a paying subscriber or CANCEL to close this message.";
var msg_sign_in =			"You must be logged-in either as a free member\nor as a paying subscriber to access this file.\n\nPlease click OK to login/register or CANCEL to close this message.";
var msg_subscribe =			"This file can be downloaded by our logged-in paying subscribers.\n\nPlease click OK to subscribe or CANCEL to close this message.";
var msg_send_sign_in =		"You must be logged-in either as a free member\nor as a paying subscriber to use this function.\n\nPlease click OK to login/register or CANCEL to close this message.";
var msg_zip_login = 		"You need to login as a paying subscriber to download this compressed collection of MIDI files.\n\nPlease click OK to login as a paying subscriber or CANCEL to close this message.";
var msg_zip_subscribe =		"This compressed collection of MIDI files can be downloaded by our logged-in paying subscribers.\n\nPlease click OK to subscribe or CANCEL to close this message.";
var msg_mp3_subscribe =		"This file can be played and/or downloaded by our logged-in paying subscribers.\n\nPlease click OK to subscribe or CANCEL to close this message.";

function player_ready() { // queuing or video player enabled?
	if (GetCookie("CMA_QP") == "" || GetCookie("CMA_QP", "noQP") == "true")
		return false; // default to no
	return ((win && ie && !ns && !webtv && !opera && !aol) && GetCookie("CMA_id") != "" && location.hostname.toLowerCase().indexOf("classicalarchives.com") != -1);
}

function find_recent() {
	window.top.location.href = "/cgi-bin/search_key.cgi?q=%7B%2B%7D";
}

function find_file(fn) {
	window.top.location.href = "/cgi-bin/search_key.cgi?q=" + escape(fn);
}

var use_frame;
//if (parent.frames.length && !use_frame)
//	window.open(window.location.href,"_top","left=0,top=0,directories,location,menubar,resizable,scrollbars,status,titlebar,toolbar");
//if (window.top != window && !use_frame) window.top.location.replace(window.location.href);

if(document.layers){origWidth=innerWidth;origHeight=innerHeight;onresize=function(){if(innerWidth!=origWidth||innerHeight!=origHeight)location.reload()}}

function need_login(cma_m, msg) {
//	if (cma_m.f) {
//		remember_page();
//		window.top.location.href = "https://secure.classicalarchives.com/login.html";
//	} else
	if (confirm(msg)) {
		remember_page();
		window.top.location.href = "https://secure.classicalarchives.com/login.html";
	}
	return;
}

//SetCookie("action",GetCookie("CMA_cur_path")+"_dl");
var lastclick = 0;
//var play1;
function click(e) {
	var targ;
	if (typeof(e) == "object") { // typeof(window.event) == "undefined" -- ns
		if (e.which == 1)
			targ = e.target;
	} else if (opera) {
		if (event.button <= 1)
			targ = event.target;
	} else { // ie
		if (event.button == 0)
			targ = event.srcElement;
	}
	if (targ && targ.nodeName) {
		while (targ.parentNode && targ.nodeName != "A" && targ.nodeName != "BODY")
			targ=targ.parentNode;
	}
	if (targ && targ.href) {
		var newclick = new Date().getTime();
		if (newclick-lastclick < 1000) return false;
		lastclick = newclick;
		targ.className="visited";
//show_props(targ);

		if (/\/m\/.*\.(mid|wax)$/.test(targ.href)) {
//			if (GetCookie("CMA_CC","nopop") == "true") {
//				load(targ.href.replace(/^.*\/m\//,""));
//				return false;
//			}
//			//if (typeof(play) == "undefined" || play.closed) // old browsers w/o iframe
//				play1=window.open("","play1",'left=0,top=0,width=20,height=20');
//			if (play1 == null) {
			if (GetCookie("CMA_CC","vls") != "true" || typeof(hw1) == "undefined" || hw1.closed) {
//				//window.top.location.href = "/error/popup.html";
//				SetCookie("CMA_CC", {nopop:true}, 1000*60*60*24*365, cma_domain);
				load(targ.href.replace(/^.*\/m\//,""));
				return false;
			}
//			targ.target="play1";
			targ.target="hw1";
			setTimeout('load("'+targ.href.replace(/^.*\/m\//,"")+'")',100);
			//setTimeout('SetCookie("action","'+GetCookie("CMA_cur_path")+'_dl")',1000);
			SetCookie("action","html",1500);
		} else if (/\/m\/free\/.*\.mp3$/.test(targ.href)) {
			if (GetCookie("CMA_CC","vls") != "true" || typeof(hw1) == "undefined" || hw1.closed) {
				load(targ.href.replace(/^.*\/m\//,""));
				return false;
			}
			targ.target="hw1";
			setTimeout('load("'+targ.href.replace(/^.*\/m\//,"")+'")',100);
			//setTimeout('SetCookie("action","'+GetCookie("CMA_cur_path")+'_dl")',1000);
			SetCookie("action","html",1500);
		} else if (/^http:\/\/.*\.mid$/.test(targ.href)) {
			load(targ.href);
			return false;
		} else if (/\/m\/.*\.(mp3|zip)$/.test(targ.href)) {
			// FIXME use popups for these too? (for visited)
			load(targ.href.replace(/^.*\/m\//,""));
			return false;
		}
	}
	if (typeof(document.routeEvent) == "function") return routeEvent(e);
	else return true;
}
function d_mousedown(e) {
	var targ;
	if (typeof(e) == "object") { // typeof(window.event) == "undefined" -- ns
		if (e.which == 3)
			targ = e.target;
	} else if (opera) { // opera
		if (event.button == 2) // FIXME right-click is not caught in opera?
			targ = event.target;
	} else { // ie
		if (event.button == 2)
			targ = event.srcElement;
	}
	if (targ && targ.nodeName) {
		while (targ.nodeName != "A" && targ.nodeName != "BODY")
			targ=targ.parentNode;
	}
	if (targ && targ.href) {
		var cma_m = get_cma_m()
		if (/\/m\/tickets\/.*\.wax/.test(targ.href)) {
			if (cma_m.pi || cma_m.p) {
				alert(msg_ticket_right);
			} else {
				if (confirm(msg_ticket_subscribe)) {
					remember_page();
					window.top.location.href = "https://secure.classicalarchives.com/membership/signup.html?tk";
				}
			}
			return false;
		} else if (/\/m\/.*\.wax/.test(targ.href)) {
			alert(msg_wma_right);
			return false;
		} else if (/javascript:send_file/.test(targ.href)) {
			alert(msg_send_right);
			return false;
		} else if (/\/m\/free\/.*\.mp3|\/m\/.*\.mid/.test(targ.href)) {
			if (cma_m.s != "i") {
				need_login(cma_m, msg_sign_in);
				return false;
			}
		} else if (/\/m\/.*\.mp3/.test(targ.href)) {
			if (cma_m.pi) {
			} else if (cma_m.p) {
				if (confirm(msg_sub_sign_in)) {
					remember_page();
					window.top.location.href = "https://secure.classicalarchives.com/login.html";
				}
				return false;
			} else {
				if (confirm(msg_subscribe)) {
					remember_page();
					window.top.location.href = "https://secure.classicalarchives.com/membership/signup.html?mp3";
				}
				return false;
			}
		} else if (/\/m\/.*\.zip/.test(targ.href)) {
			if (cma_m.pi) {
			} else if (cma_m.p) {
				if (confirm(msg_zip_login)) {
					remember_page();
					window.top.location.href = "https://secure.classicalarchives.com/login.html";
				}
				return false;
			} else {
				if (confirm(msg_zip_subscribe)) {
					remember_page();
					window.top.location.href = "https://secure.classicalarchives.com/membership/signup.html?zip";
				}
				return false;
			}
		}
	}
	if (typeof(document.routeEvent) == "function") return routeEvent(e);
	else return true;
}
if (typeof(document.captureEvents) == "function") document.captureEvents(Event.CLICK|Event.MOUSEDOWN);
document.onclick=click;
document.onmousedown=d_mousedown;

function open_popup(url,obj) {
	var w = 640, h = 480, x = 50, y = 50;
	if (obj) {
		if (obj.w) w = obj.w;
		if (obj.h) h = obj.h;
		if (obj.x) x = obj.x;
		if (obj.y) y = obj.y;
	}
	window.open(url,"_blank","width="+w+",height="+h+",top="+y+",left="+x+",scrollbars,resizable");
	return false;
}

function ct(a,i) { // see clickthroughs.csv
	if (a == "am") {
		var ct_win = window.open("/cgi-bin/ct.cgi?a=" + a + "&i=" + escape(i),"_blank","width=380,height=450,top=10,left=10,location,scrollbars,status,toolbar,resizable");
		ct_win.focus();
	} else {
		var ct_win = window.open("/cgi-bin/ct.cgi?a=" + a + "&i=" + escape(i),"_blank");
		ct_win.focus();
	}
	return;
}

function open_Civilization() {
	var minWidth = 640;
	var minHeight = 480;
	var left = (window.screen) ? (screen.availWidth / 2) - (minWidth / 2) : 0;
	var top = (window.screen) ? (screen.availHeight / 2) - (minHeight / 2) : 0;

	window.open('/civilization.html','','left=' + left + ',top=' + top + ',width=' + minWidth + ',height=' + minHeight + ',resizable' + ((ns) ? ',scrollbars' : ''));
}

function benefits() {
	var minWidth = 640;
	var minHeight = 300;
	var aol = (navigator.userAgent.toUpperCase().indexOf("AOL") != -1);

	if (window.screen && !aol) {
		var x = (screen.availWidth / 2) - (minWidth / 2);
		var y = (screen.availHeight / 2) - (minHeight / 2);
		window.open('https://secure.classicalarchives.com/benefits.html','benefits','width=' + minWidth + ',height=' + minHeight + ',left=' + x + ',top=' + y + ',scrollbars,resizable');
	} else
		window.open('https://secure.classicalarchives.com/benefits.html','benefits','width=' + minWidth + ',height=' + minHeight + ',scrollbars,resizable');
	return;
}

function launchRadio() {
	window.open('/radio.html','','width=20,height=20,resizable');
}

var passed_cdSearch_composer;
function cdSearch(composer) { // search CDNOW and AMAZON.COM by composer
	passed_cdSearch_composer = composer;
	window.open("/popup_cdsearch.html","searchCD","left=" + 5 + ",top=" + 5 + ",width=540,height=430,scrollbars,resizable");
}

function closeMe() {
	if (window.opener && !window.opener.closed)
		self.close();
	else
		window.location.href = "/";
}

function remember_page() {
	// store tmp info if user gets redirected to log in
	SetCookie("CMA_page",{done:0,url:document.location.href.replace(/_hl[12]?\.html/,".html"), title:document.title.replace(/^CLASSICAL MUSIC ARCHIVES */i,"").replace(/^[:-] */,"")},"",cma_domain);

	var sX = 0, sY = 0;
	if (typeof(document.body.scrollLeft) != "undefined") {
		sX = document.body.scrollLeft;
		sY = document.body.scrollTop;
	} else if (document.documentElement && typeof(document.documentElement.scrollLeft) != "undefined") {
		sX = document.documentElement.scrollLeft;
		sY = document.documentElement.scrollTop;
	} else if (typeof(window.pageXOffset) != "undefined") {
		sX = window.pageXOffset;
		sY = window.pageYOffset;
	} else if (typeof(window.scrollX) != "undefined") {
		sX = window.scrollX;
		sY = window.scrollY;
	}
	if (sX + sY > 0) SetCookie("CMA_page",{sX:sX,sY:sY},"",cma_domain);

	// FIXME add goto login.html here - but see {gift,renew}.html
}

function remember_scroll() {
	if (GetCookie("CMA_page") != "") {
		if (GetCookie("CMA_page", "url") == window.location.href) {
			var sX = GetCookie("CMA_page", "sX");
			var sY = GetCookie("CMA_page", "sY");
			if (sX + sY > 0) window.scrollTo(sX, sY);
		}
		DelCookie("CMA_page",cma_domain);
	}
}
window.onload = remember_scroll;

function randomPlay() { // calls random.cgi which sends random url to load() function
	window.open('/cgi-bin/random.cgi','random_popup','left=0,top=0,width=20,height=20');
//	return false;
}

var plugin = null;
function load(file) {
	var m_path = cma_url(file);
	var cma_m = get_cma_m();
	if (GetCookie("CMA_cur_path") == "") { window.top.location.href = "/cookies.html"; return; }
	if (typeof(urchinTracker) == "function") urchinTracker("/ga/m/load?file="+file);
	if (file.indexOf(".mid") != -1) { // midi
		if (cma_m.s != "i") {
			need_login(cma_m, msg_sign_in);
			return;
		}
//		if (play1 && !play1.closed) play1.close();
		if (player_ready() && GetCookie("CMA_QP", "midi") != "false") {
			openPlayer(file);
		} else {
//			var plugin1 = (navigator.mimeTypes && navigator.mimeTypes["audio/midi"]) ? navigator.mimeTypes["audio/midi"].enabledPlugin : 0;
//			var plugin2 = (navigator.mimeTypes && navigator.mimeTypes["audio/mid"]) ? navigator.mimeTypes["audio/mid"].enabledPlugin : 0;
//			if (plugin1 || plugin2) {
//				if (plugin && !plugin.closed) plugin.close(); // FIXME check for inter-browser playing
//				plugin = window.open(file,"plugin","left=" + (screen.width/2 - 210) + ",top=" + (screen.height/2 - 115) + ",width=420,height=230,resizable");
//			} else
				window.location.href = m_path; // system
		}
	} else if (/^free\/.*\.mp3$/.test(file)) { // unprotected mp3
		if (cma_m.s != "i") {
			need_login(cma_m, msg_sign_in);
			return;
		}
		if (player_ready() && GetCookie("CMA_QP", "mp3") != "false")
			openPlayer(file.replace(/\.mp3$/,".m3u"));
		else if (GetCookie("CMA_CC", "m3u") == "false")
			window.location.href = m_path; // system
		else
			window.location.href = m_path.replace(/\.mp3$/,".m3u"); // system
	} else if (file.indexOf(".mp3") != -1) { // protected mp3
		if (cma_m.pi) {
			if (player_ready() && GetCookie("CMA_QP", "mp3") != "false")
				openPlayer(file.replace(/\.mp3$/,".m3u"));
			else if (GetCookie("CMA_CC", "m3u") == "false")
				window.location.href = m_path; // system
			else
				window.location.href = m_path.replace(/\.mp3$/,".m3u");
		} else if (cma_m.p) {
			if (confirm(msg_sub_sign_in)) {
				remember_page();
				window.top.location.href = "https://secure.classicalarchives.com/login.html";
			}
		} else {
			if (confirm(msg_mp3_subscribe)) {
				remember_page();
				window.top.location.href = "https://secure.classicalarchives.com/membership/signup.html?mp3";
			}
		}
	} else if (file.indexOf(".wax") != -1) { // windows media (audio), tickets (audio)
		// warning: have_wmp is defined in the footer
		if (mac && !have_wmp) { window.top.location.href = "/wmp.html"; return; }
		if (file.indexOf("tickets/") == 0) { // ticket (audio)
			if (cma_m.pi) {
				var suffix = "";
				if (GetCookie("CMA_CC", "playall") == "mp3") {
					if (GetCookie("CMA_CC", "m3u") == "false") {
						suffix = "?mp3=http";
					} else {
						suffix = "?mp3=mms";
					}
				}
				if ( (suffix == "" && player_ready() && GetCookie("CMA_QP", "wma") != "false") || // wma wax
					 (suffix != "" && player_ready() && GetCookie("CMA_QP", "mp3") != "false") ) // mp3 wax
					openPlayer(file+suffix);
				else
					window.location.href = m_path+suffix; // system
			} else if (cma_m.p) {
				if (confirm(msg_ticket_login)) {
					remember_page();
					window.top.location.href = "https://secure.classicalarchives.com/login.html";
				}
			} else {
				if (confirm(msg_ticket_subscribe)) {
					remember_page();
					window.top.location.href = "https://secure.classicalarchives.com/membership/signup.html?tk";
				}
			}
		} else {
			if (cma_m.s != "i" && file.indexOf("sample/") != 0) {
				need_login(cma_m, msg_sign_in);
				return;
			}
			if (player_ready() && GetCookie("CMA_QP", "wma") != "false")
				openPlayer(file);
			else
				window.location.href = m_path; // system
		}
	} else if (file.indexOf(".wvx") != -1) { // windows media (video)
		if (cma_m.s != "i") {
			need_login(cma_m, msg_sign_in);
			return;
		}
		// warning: have_wmp is defined in the footer
		if (mac && !have_wmp) { window.top.location.href = "/wmp.html"; return; }
		if (player_ready()) {
			if (/^(.*\.wvx)\?(.*)$/.test(m_path))
				window.location.href = RegExp.$1;
			else
				window.open(m_path + "?popup","cma_video_popup","width=330,height=260,resizable");
		} else // external player for non-compatible systems
			window.location.href = m_path;
	} else if (file.indexOf(".zip") != -1) { // zip
		if (cma_m.pi) {
			window.location.href = m_path;
		} else if (cma_m.p) {
			if (confirm(msg_zip_login)) {
				remember_page();
				window.top.location.href = "https://secure.classicalarchives.com/login.html";
			}
		} else {
			if (confirm(msg_zip_subscribe)) {
				remember_page();
				window.top.location.href = "https://secure.classicalarchives.com/membership/signup.html?zip";
			}
		}
	}
	return;
}

function getWinById(win_name, windef, qp_file) {
	var test_win = window.open("", win_name, windef);
	var popup = "";
	var _cookie = GetCookie('QP_test');

	eval('try {if (test_win!=null){popup = (test_win.document.title) ? "open" : "ok"}else{popup = "killed"}} catch (e){popup = "killed"}');

	if (qp_file != _cookie) {
		_cookie = "killed";
		eval('try { test_win.close() } catch (e) {}');
	} else
		_cookie = "ok";

	var obj = new Object();
		obj.popup = popup;
		obj.cookie = _cookie;
	return obj;
}

function openPlayer(url) {
	SetCookie('QP_test', url, 1000*10, cma_domain); // cookie test

	var winDef = "left=" + getSavedPosition('left') + ",top=" + getSavedPosition('top') + ",width=409,height=368";
	var setupWinDef = "left=" + (screen.width/2-275) + ",top=" + (screen.height/2-220) + ",width=550,height=440,resizable";
	var qp_killed_msg = "YOUR BROWSER BLOCKED OUR CMA MUSIC PLAYER WINDOW.\n\nWhich music player would you like to use?\n\nClick [    OK    ] to use your regular music player instead.\n\nClick [ Cancel ] to try our CMA music player (see below)\n\n\nFor the CMA player, you must add \"classicalarchives.com\" to your popup-blocker program.\n(If you're not sure how to do this, just click [  OK  ] to use your regular player instead.)";

	var test = (GetCookie("CMA_QP", "setup") != "true") ? getWinById("player",setupWinDef,url) : getWinById("player",winDef,url);

	if (test.popup == "open") // player already open
		window.open("","player").addToQueue(url); // pass file
	else if (test.popup == "ok" && test.cookie == "ok") { // popup & cookie OK
		if (GetCookie("CMA_QP", "setup") == "true") // qp
			window.open('/player/player.html?qp_file=' + url, 'player', winDef);
		else // qp setup
			window.open('/player/player_setup_connection.html?qp_file=' + url, 'player', setupWinDef);
	} else if (test.cookie == "killed") { // cookie killed - automatically open default
		location.href = cma_url(url);
	} else if (test.popup == "killed" && confirm(qp_killed_msg)) { // popup killed - ask user
		SetCookie('CMA_QP', {noQP:true}, 1000*60*60*24*365, cma_domain);
		setTimeout("location.href = '" + cma_url(url) + "'", 600);
	}
}

function send_file(url) {
	var dst = "https://secure.classicalarchives.com/cgi-bin/send_file.cgi?do=popup&url=" + escape(url);
	var cma_m = get_cma_m();
	if (cma_m.s == "i") {
		var minWidth = 540;
		var minHeight = 380;
		var aol = (navigator.userAgent.toUpperCase().indexOf("AOL") != -1);
		if (window.screen && !aol) {
			var x = (screen.availWidth / 2) - (minWidth / 2);
			var y = (screen.availHeight / 2) - (minHeight / 2);
			window.open(dst,'popup','width=' + minWidth + ',height=' + minHeight + ',left=' + x + ',top=' + y);
		} else
			window.open(dst,'popup','width=' + minWidth + ',height=' + minHeight);
	} else {
		need_login(cma_m, msg_send_sign_in);
	}
}

function getSavedPosition(action) {
	if (action == "left") {
		if (GetCookie("CMA_QP", "x") != "")
			return (GetCookie("CMA_QP", "x") > screen.width) ? (screen.width/2-175) : GetCookie("CMA_QP", "x");
		else
			return screen.width/2-175;
	}
	if (action == "top") {
		if (GetCookie("CMA_QP", "y") != "")
			return (GetCookie("CMA_QP", "y") > screen.width) ? (screen.height/2-175) : GetCookie("CMA_QP", "y");
		else
			return screen.height/2-175;
	}
	return 1;
}

function favorites() {
	if (ie) window.external.AddFavorite("http://www.classicalarchives.com/","Classical Archives");
}

function getBrowserHeight() {
	if ( typeof( window.innerHeight ) == 'number' ) // non ie
		return window.innerHeight;
	else {
		if( document.documentElement && ( document.documentElement.clientHeight ) ) //IE 6+ in 'standards compliant mode'
			return document.documentElement.clientHeight;
		else {
			if ( document.body && ( document.body.clientHeight ) ) { // ie4
				return document.body.clientHeight;
			}
		}
	}
}

function getBrowserWidth() {
	if ( typeof( window.innerWidth ) == 'number' ) // non ie
		return window.innerWidth;
	else {
		if( document.documentElement && ( document.documentElement.clientWidth ) ) //IE 6+ in 'standards compliant mode'
			return document.documentElement.clientWidth;
		else {
			if ( document.body && ( document.body.clientWidth ) ) { // ie4
				return document.body.clientWidth;
			}
		}
	}
}

function album_win(page) {
	var album_win = window.open(page,"_album_win","width=540,height=450,top=10,left=10,scrollbars,resizable");
	album_win.focus();
}

var changingopacity;
function fadeIn(obj) {
	if (ie) {
		if (window.changingopacity) clearInterval(changingopacity);
		theobject=obj;
		changingopacity = setInterval("FadingIn(theobject)",1);
	}
}

function fadeOut(obj) {
	if (ie) {
		if (window.changingopacity) clearInterval(changingopacity);
		theobject=obj;
		changingopacity = setInterval("FadingOut(theobject)",1);
	}
}

function FadingIn(obj) {
	if (ie) {
		if (obj.filters.alpha.opacity < 100)
			obj.filters.alpha.opacity += 5;
		else if (window.changingopacity)
			clearInterval(changingopacity);
	}
}

function FadingOut(obj) {
	if (ie) {
		if (obj.filters.alpha.opacity > 85)
			obj.filters.alpha.opacity -= 5;
		else if (window.changingopacity)
			clearInterval(changingopacity);
	}
}

