
function openAdmin(){
	adminWindow = window.open("admin/adminPanel.php","Administration","width=800,height=600,left=0,top=0,scrollbars=yes,location=no,resizable=yes,status=no,toolbar=no,fullscreen=no,titlebar=yes")


}

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];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);

function BuyItem(id , price){
	quantity = eval ('mer.item' + id)
	if (quantity.value == 0) {
		quantity.value = 1
		total = eval ('document.all.price' + id)
		total.innerHTML = quantity.value * price
	}
	else {
		quantity.value = 0
		total = eval ('document.all.price' + id)
		total.innerHTML = '0'
	}
}
function changeQuantity(id , price){
	quantity = eval ('mer.item' + id)
	if (quantity.value!=0) {
		checker = eval ('mer.check' + id)
		checker.checked = 1
		total = eval ('document.all.price' + id)
		total.innerHTML = quantity.value * price
	}
	else {
		checker = eval ('mer.check' + id)
		checker.checked = 0
		total = eval ('document.all.price' + id)
		total.innerHTML = '0'
	}

}
function openMerchandise(url,title,width,height){
	title=title.replace(/-/g," ")
	var size="width="+width+",height="+height
	winpops=window.open("","",size)
	winpops.document.write("<head><title>",title,"</title></head><body><img src=",url,"></body>")
	winpops.document.bgColor="black"

	}
function countTotal(items){
	var totalprice=0
	var currentprice=0
	for (i=1;i<=items;i++){
	var currentprice = eval('document.all.price' + i +'.innerHTML')
	totalprice=eval(totalprice) + eval(currentprice)

}
	document.mer.totalprice.value=totalprice
}

function check(){
	if (document.mer.totalprice.value==0) {
		alert ("You haven't chosen anything")

	}
	else  document.mer.action="merchandise.php?step=1"

}

function showNews(id,newsTable,totalNews) {
	small = "div_small" + id
	id = "div"+id

	for (i=0 ; i < totalNews ; i++){
		curDiv				= "div"+i
		curSmallDiv		=	"div_small"+i
		curNewsTable 	= "newsTable" + i
		if (curDiv != id){
			document.getElementById(curSmallDiv).style.visibility="visible"
			document.getElementById(curSmallDiv).style.position="relative"
			if (document.getElementById(curNewsTable)) {
				document.getElementById(curNewsTable).className=""
			}
			if (document.getElementById(curDiv)){
				document.getElementById(curDiv).style.visibility="hidden"
				document.getElementById(curDiv).style.position="absolute"
			}
		}
	}

	if (document.layers) {
	layer=document.layers[id]
	//alert("layers")
	}
	else if (document.all) {
	if (document.all[id].style.visibility=="hidden"){
		document.all[newsTable].className="content"
		document.all[id].style.visibility="visible"
		document.all[id].style.position="relative"

		}
	else {
		document.all[newsTable].className=""
		document.all[id].style.visibility="hidden"
		document.all[id].style.position="absolute"
		}
	}
	else if (document.getElementById){
	if (document.getElementById(id).style.visibility=="hidden") {
		document.getElementById(newsTable).className="content"
		document.getElementById(id).style.visibility="visible"
		document.getElementById(id).style.position="relative"
		document.getElementById(small).style.visibility="hidden"
		document.getElementById(small).style.position="absolute"

		}
	else {
		document.getElementById(newsTable).className=""
		document.getElementById(id).style.visibility="hidden"
		document.getElementById(id).style.position="absolute"
		document.getElementById(small).style.visibility="visible"
		document.getElementById(small).style.position="relative"

		}
	 }

}

function openPhoto(source,width,height,text){
	var s_height=eval(height)+60
	var s_width=eval(width)+30
	var s_w = screen.width;
	var s_h = screen.height;
	var left_p=(s_w - s_width) /2
	var top_p=(s_h - s_height) / 2
	if (!text) text=' '
	winpops=window.open("","","height="+s_height+",width="+s_width+" left="+left_p+" top="+top_p)
	winpops.document.write("<link href='styles.css' rel='stylesheet' type='text/css'><title>"+text+"</title><body onMouseDown='close()'><center><img src="+source+" class='imageBorder' alt='Click to close window'></center>")
	winpops.document.bgColor="black"
	winpops.document.write("<br><center><font class=headTitle><b>"+text+"</b></font></center></body>")
}

// MERCHANDISE SECTION
var greatTotal=0

function BuyItem(id , price){
	quantEl = document.getElementById("sale[" + id +"][quant]")
	PriceEl	=	document.getElementById("sale[" + id +"][cost]")
	curQ = quantEl.value
	if (curQ == 0) {
		quantEl.value = 1
		PriceEl.innerHTML = 1 * price
	}
	else {
		quantEl.value = 0
		PriceEl.innerHTML = '0'
	}
}
function changeQuantity(id , price){
	quantEl = document.getElementById("sale[" + id +"][quant]")
	PriceEl	=	document.getElementById("sale[" + id +"][cost]")
	checkId	=	"check[" + id +"]"
	var curQ = quantEl.value
	checker = document.getElementById(checkId)
	if (curQ!=0) {
		checker.checked = 1
		PriceEl.innerHTML = curQ * price
	}
	else {
		checker.checked = 0
		PriceEl.innerHTML = '0'
	}

}
function openMerchandise(url,title,width,height){
	title=title.replace(/-/g," ")
	var size="width="+width+",height="+height
	winpops=window.open("","",size)
	winpops.document.write("<head><title>",title,"</title></head><body><img src=",url,"></body>")
	winpops.document.bgColor="black"

	}
function countTotal(items){
	greatTotal = 0
	var currentprice=0
	for (i=1;i<=10;i++){
		currPriceEl = document.getElementById("sale[" + i +"][cost]")
		if (currPriceEl){
			var currentprice = eval(currPriceEl.innerHTML)
			greatTotal += currentprice
		}
	}
	if (document.getElementById("totalprice")){
		document.getElementById("totalprice").innerHTML="<font size='+1'>" + greatTotal + " &euro;</font>"
	}
}

function check(){
	countTotal(10)
	if (greatTotal==0) {
		alert ("You haven't chosen anything")

	}
	else  {
		document.getElementById("mer").action = "merchandise.php?step=1"
	}

}

function checkInfo(){

	var radio_choice = false;
	for (counter = 0; counter < document.info.method.length; counter++)			{
		if (document.info.method[counter].checked) radio_choice = true;
	}

	if (document.info.fullName.value=="") alert("You haven't filled the fullname field")
	else if (document.info.email.value=='') alert("You haven't filled the email field");
	else if (document.info.address.value=='') alert("You haven't filled the address field");
	else if (document.info.zip.value=='') alert("You haven't filled the zip code field");
	else if (document.info.city.value=='') alert("You haven't filled the city, Country field");
	else if (radio_choice == false ) alert("You haven't chosen a delivery method");
	else 	document.info.action='merchandise.php?step=2'


}


function copyToClipboard(text){
	if (window.clipboardData) {
		text = unescape(text)
		newText = text.replace(/<br>/g,"\r\n")
		//alert(newText)
		window.clipboardData.setData('Text',newText)
		alert("The lyrics have been copied to the clipboard")
	}
	else {
		alert("Copy to clipboard is disabled in Mozzila/Firefox")
	}
}

function printLyrics(text){

	text = unescape(text)

	popup = window.open('','popup','toolbar=no,menubar=no,width=350,height=600');
	popup.document.open();
	popup.document.write("<html><head></head><body onload='print()'>");
	popup.document.write("<font size=2>"+text+"</font>");
	popup.document.write("</body></html>");
	popup.document.close();

}

function saveLyrics(text){
	text = unescape(text)

	popup = window.open('','popup','toolbar=no,menubar=no,width=350,height=600');
	popup.document.open();
	popup.document.write("\<\?php ");
	popup.document.write("$out .= header('Content-type: application/octetstream')\r\n");
	popup.document.write("$out .=	header('Content-Disposition: inline; filename=AEK_backup-$date.sql')\r\n");
	popup.document.write("$out .= header('Expires: 0')\r\n");
	popup.document.write("$out .= header('Cache-Control: must-revalidate, post-check=0, pre-check=0')\r\n");
	popup.document.write("$out .= header('Pragma: public')\r\n");
	popup.document.write("$out .= "+text+"\r\n");
	popup.document.write("?>");
	popup.document.close();

}

function deleteItem(what,id){

	if (what == "news" ){
		if (confirm("Do you really want to delete these news?")){
			location.href = "admin_deleteNews.php?news_ID=" + id
		}
	}
	if (what == "album" ){
		if (confirm("Do you really want to delete this album?")){
			location.href = "admin_deleteAlbum.php?album_ID=" + id
		}
	}
	if (what == "songs" ){
		if (confirm("Do you really want to delete this song?")){
			location.href = "admin_deleteSongs.php?song_ID=" + id
		}
	}
	if (what == "liveDates" ){
		if (confirm("Do you really want to delete this live Date?")){
			location.href = "admin_deleteLiveDates.php?liveDates_ID=" + id
		}
	}
	if (what == "photos" ){
		if (confirm("Do you really want to delete this photo?")){
			location.href = "admin_deletePhotos.php?photo_ID=" + id
		}
	}
	if (what == "links" ){
		if (confirm("Do you really want to delete this link?")){
			location.href = "admin_deleteLinks.php?link_ID=" + id
		}
	}
	if (what == "guestbook" ){
		if (confirm("Do you really want to delete this entry?")){
			location.href = "admin_deleteGuestbook.php?guestbook_ID=" + id
		}
	}
	if (what == "download" ){
		if (confirm("Do you really want to delete this entry?")){
			location.href = "admin_deleteDownload.php?download_ID=" + id
		}
	}
}

function checkMailingList(){
	if ((document.getElementById("name").value == "") || (document.getElementById("email").value == "")){
		alert("You have to fill the Name and email fields")
	}
	else {
		document.forms[0].action = "subscribe.php"
	}
}

function showTab(id,numToHide){
		for(i=1;i<=numToHide;i++){
			var tabContentToHide	= "tabContent_" + i
			var tabToHide					=	"tab_" + i
			if 	(tabToHide != tab_id) {
				hideDiv(tabContentToHide,tabToHide)
			}
		}
		var tab_id = "tab_" + id
		var tabContent_id = "tabContent_" + id
		if (document.getElementById(tabContent_id)){
			elTabContent = document.getElementById(tabContent_id)
			elTab				 = document.getElementById(tab_id)
			elTabContent.style.visibility = "visible"
			elTabContent.style.position = "relative"
			elTabContent.className = "activeTabContent"
			elTab.className = "activeTab"
		}
	}

function hideDiv(tabContentToHide,tabToHide){
	elTabContent = document.getElementById(tabContentToHide)
	elTab				 = document.getElementById(tabToHide)
	if (document.getElementById(tabContentToHide)){
		elTabContent.style.position= "absolute"
		elTabContent.style.visibility = "hidden"
		//elTabContent.className = "inactiveTabContent"
		elTab.className = "inactiveTab"
	}
}



// Chenge the images opacity



/***********************************************
* Gradual Highlight image script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var baseopacity=50

function slowhigh(which2){
	if (document.getElementById(which2)){
		which2 = document.getElementById(which2)
	}
	imgobj=which2
	browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
	instantset(baseopacity)
	highlighting=setInterval("gradualfade(imgobj)",50)
}

function slowlow(which2){
	if (document.getElementById(which2)){
			which2 = document.getElementById(which2)
		}
	cleartimer()
	instantset(baseopacity)
}

function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}

function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}

function mail(mail_url){
	mail_url=mail_url.replace(/ at /g,"@")
	location.href="mailto:"+mail_url
}

function clickSmilie(smile) {
document.gbook.comments.value=document.gbook.comments.value+smile;
document.gbook.comments.focus=1;
}

function setPhotoCategory(el){
	if (document.getElementById(el).value != ""){
 		document.getElementById("newCategory").disabled = true
 		document.getElementById("newCategory").className = "disabled"
 		document.getElementById("newCategory").value = ""
		if (document.getElementById(el).value != "Live"){
			document.getElementById("newSet").disabled = true
			document.getElementById("newSet").className = "disabled"
			document.getElementById("set").disabled = true
			document.getElementById("set").className = "disabled"
 			document.getElementById("newSet").value = ""
 			document.getElementById("set").value = "-"
		}
		else {
			document.getElementById("newSet").disabled = false
			document.getElementById("set").disabled = false
			document.getElementById("newSet").className = ""
			document.getElementById("set").className = ""
 			document.getElementById("newSet").value = ""
 			document.getElementById("set").value = "New Set"
		}
 	}
 	else {
 		document.getElementById("newCategory").disabled = false
 		document.getElementById("newCategory").className = ""
 		document.getElementById("newCategory").value = ""
 	}
}

function setPhotoSet(el){
	if (document.getElementById(el).value != ""){
 		document.getElementById("newSet").disabled = true
 		document.getElementById("newSet").className = "disabled"
 		document.getElementById("newSet").value = ""

 	}
 	else {
 		document.getElementById("newSet").disabled = false
 		document.getElementById("newSet").className = ""
 		document.getElementById("newSet").value = ""
 	}
}

function setDownloadCategory(el){
	if (document.getElementById(el).value != ""){
 		document.getElementById("newCategory").disabled = true
 		document.getElementById("newCategory").className = "disabled"
 		document.getElementById("newCategory").value = ""
	}
 	else {
 		document.getElementById("newCategory").disabled = false
 		document.getElementById("newCategory").className = ""
 		document.getElementById("newCategory").value = ""
 	}
}

// FOCUS FORMS FOR IE
sfFocus = function() {
	var sfEls = document.getElementsByTagName("INPUT");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onfocus=function() {
			this.className+=" sffocus";
		}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfFocus);

