function showlogin(){
	new Effect.BlindDown(logindiv);
	getObj('loginbutton').innerHTML="<a href='/'><b>Sign up</b></a> | <a href='javascript:hidelogin();'><b>Log in</b></a>";
	
}
function hidelogin(){
	new Effect.BlindUp(logindiv);
	getObj('loginbutton').innerHTML="<a href='/'><b>Sign up</b></a> | <a href='javascript:showlogin();'><b>Log in</b></a>";
}


function getObj(name){
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
  }
  else if (document.all)
  {
	this.obj = document.all[name];
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
  }
  return this.obj;
}


function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

function suggestions(objname,rowname,tablename){
	Xleft = findPosX(getObj(objname));
	Ytop = findPosY(getObj(objname))+20;
if(getObj('helpdeck').innerHTML == ""){
		getObj('helpdeck').innerHTML= "<IFRAME NAME=\"iframe\" ID=\"iframe\" STYLE=\"width:220px;height:140px; position:absolute;top:"+Ytop+"px;left:"+Xleft+";filter:Alpha(opacity=95);-moz-opacity:0.95;border-style: solid;border-width: 1px;border-color: #999999;\" SRC=\"suggestions.php?tn="+tablename+"&rn="+rowname+"&t="+objname+"&q="+getObj(objname).value+"\" frameborder=0 border=0 scrolling=auto></IFRAME>";
	} else {
		getObj('helpdeck').innerHTML = "";
	}
}


function toggleLayer(whichLayer){
  var elem, vis;
  elem = getObj(whichLayer);
  vis = elem.style;

 // if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
 //  vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
//vis.display = (vis.display==''||vis.display=='block')?'none':'block';
 
if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined){
	if(elem.offsetWidth!=0&&elem.offsetHeight!=0){
		new Effect.Fade(whichLayer);
	} else {
		new Effect.Appear(whichLayer);		
	}
 }	
	if(vis.display==''||vis.display=='block'){
		new Effect.Fade(whichLayer);
	} else {
		new Effect.Appear(whichLayer);		
	}
   
}

function checkField(obj,type){
// takes obl - html object and checks it in various ways
// type is the type of data it should be formated like
// Type:(ssn,phone,email);
    error = "0";
    switch(type){
	case "ssn":
	    if (!(/^[0-9]{3}-[0-9]{2}-[0-9]{4}$/.test(obj.value))){
 		inE_(obj,"Format for SSN is XXX-XX-XXX");
		error = "1";	
	    }	
	    break;
	case "phone":
            if (!(/\d{3}-\d{3}-\d{4}$/.test(obj.value))){
        	inE_(obj,"Format for Phone Number is XXX-XXX-XXX");
        	error = "1";
            }
            break;
	case "email":
            if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj.value))){
        	inE_(obj,"Format for Email is incorrect");
        	error = "1";
            }
            break;
        case "money":
            if (!(/\$\d{1,3}(,\d{3})*\.\d{2}/.test(obj.value))){
                inE_(obj,"Format for Email is incorrect");
                error = "1";
            }
            break;
        case "time":
            if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj.value))){
                inE_(obj,"Format for Email is incorrect");
                error = "1";
            }
            break;
        case "notnull":
            if (obj.value == ""){
                inE_(obj,"You cannot leave this field blank");
                error = "1";
            }
            break;

	default:
	break;
    }//end swtich
    if(error != "1"){inG_(obj);}
}// End checkField

function checkDates(obj,obj2){
	var d1_array = obj.value.split("-");
	var d2_array = obj2.value.split("-");
	var d1 = new Date();
	var d2 = new Date();
	d1.setFullYear(d1_array[2],d1_array[0],d1_array[1]);
	d2.setFullYear(d2_array[2],d2_array[0],d2_array[1]);
	error = "0";
	if (obj.value == ""){
		inE_(obj,"You cannot leave this field blank");
		error = "1";
	}else{
		if (d1 < d2){
			inE_(obj2,"");
			inE_(obj,"This end date must be later than the start date.");
			error = "1";	
		}	
	}

    if(error != "1"){inG_(obj);}
}// End checkField

function pageGo(todo){
	//main = document.getElementById('main');
	document.getElementById('main1').style.background = "url('bgs/"+ todo + "bgs.jpg')";
	Effect.Fade(currentPage+"bgs");
	Effect.Fade(currentPage+"content", {duration:.2});

	//changeContentBG(returnLat(todo));	
	
	todos = todo + "content";
	todob = todo + "bgs";
	window.setTimeout('Effect.Appear(todos, {duration:.6})',1000);
	window.setTimeout('Effect.Appear(todob, {duration:.6})',1000);
	//if(todo == 'photos') {Effect.Appear("photoset"+currentPhotoSet, {duration:.1});}
	
	currentPage = todo;
}

function pageAbout(todo){
if(todo != currentAboutPage){
todos = "about"+todo;
todoo = "about"+currentAboutPage
	new Effect.BlindUp(todoo);

	//changeContentBG(returnLat(todo));	


	new Effect.BlindDown(todos);

	//if(todo == 'photos') {Effect.Appear("photoset"+currentPhotoSet, {duration:.1});}
	currentAboutPage = todo;
	}
}
function pageWorks(todo){
if(todo != currentWorksPage){
todos = "works"+todo;
todoo = "works"+currentWorksPage;
images = "worksimg"+todo;
imageo = "worksimg"+currentWorksPage;
	new Effect.BlindUp(todoo);

	//changeContentBG(returnLat(todo));	
document.getElementById(images).innerHTML="<img src=images/todochecked.jpg>";
document.getElementById(imageo).innerHTML="<img src=images/todobox.jpg>";

	new Effect.BlindDown(todos);

	//if(todo == 'photos') {Effect.Appear("photoset"+currentPhotoSet, {duration:.1});}
	currentWorksPage = todo;
	}
}

function pageNews(todo){
if(todo != currentNewsPage){
todos = "news"+todo;
todoo = "news"+currentNewsPage;
images = "newsimg"+todo;
imageo = "newsimg"+currentNewsPage;
	new Effect.BlindUp(todoo);

	//changeContentBG(returnLat(todo));	
document.getElementById(images).innerHTML="<img src=images/todochecked.jpg>";
document.getElementById(imageo).innerHTML="<img src=images/todobox.jpg>";
	new Effect.BlindDown(todos);

	//if(todo == 'photos') {Effect.Appear("photoset"+currentPhotoSet, {duration:.1});}
	currentNewsPage = todo;

	}
}


function showdeadcenterdiv(Xwidth,Yheight,divid) {
// First, determine how much the visitor has scrolled

var scrolledX, scrolledY;
if( self.pageYOffset ) {
scrolledX = self.pageXOffset;
scrolledY = self.pageYOffset;
} else if( document.documentElement && document.documentElement.scrollTop ) {
scrolledX = document.documentElement.scrollLeft;
scrolledY = document.documentElement.scrollTop;
} else if( document.body ) {
scrolledX = document.body.scrollLeft;
scrolledY = document.body.scrollTop;
}

// Next, determine the coordinates of the center of browser's window

var centerX, centerY;
if( self.innerHeight ) {
centerX = self.innerWidth;
centerY = self.innerHeight;
} else if( document.documentElement && document.documentElement.clientHeight ) {
centerX = document.documentElement.clientWidth;
centerY = document.documentElement.clientHeight;
} else if( document.body ) {
centerX = document.body.clientWidth;
centerY = document.body.clientHeight;
}

// Xwidth is the width of the div, Yheight is the height of the
// div passed as arguments to the function:
var leftOffset = scrolledX + (centerX - Xwidth) / 2;
var topOffset = scrolledY + (centerY - Yheight) / 2;
// The initial width and height of the div can be set in the
// style sheet with display:none; divid is passed as an argument to // the function
var o=document.getElementById(divid);
var r=o.style;
r.position='absolute';
r.top = topOffset + 'px';
r.left = leftOffset + 'px';
//r.display = "block";
new Effect.Appear(o);
} 
function createMessage(to_id,ref_id){
	getObj('MESSAGE_FORM').innerHTML= "<table cellpadding=10><tr><td><iframe src='/profile_message.php?id="+to_id+"&m_ref_id="+ref_id+"' style='width: 450px; height: 300px; background: #f3f3f3; border:none;' frameborder=0 scrolling=no></iframe></td></tr></table>";
	getObj('MESSAGE_FORM').className="message_form"; 
	
	showdeadcenterdiv(450,300,'MESSAGE_FORM');

}

function createAddme(to_id){
	getObj('MESSAGE_FORM').innerHTML= "<table cellpadding=10><tr><td><iframe src='/profile_addme.php?id="+to_id+"' style='width: 450px; height: 300px; background: #f3f3f3; border:none;' frameborder=0 scrolling=no></iframe></td></tr></table>";
	getObj('MESSAGE_FORM').className="message_form"; 
	
	showdeadcenterdiv(450,300,'MESSAGE_FORM');

}

function createSong(to_id){
	getObj('MESSAGE_FORM').innerHTML= "<table cellpadding=10><tr><td><iframe src='/song_create.php?songid="+to_id+"' style='width: 450px; height: 300px; background: #f3f3f3; border:none;' frameborder=0 scrolling=no></iframe></td></tr></table>";
	getObj('MESSAGE_FORM').className="message_form"; 
	
	showdeadcenterdiv(450,300,'MESSAGE_FORM');

}
function createStory(to_id){
	getObj('MESSAGE_FORM').innerHTML= "<table cellpadding=10><tr><td><iframe src='/song_story.php?songid="+to_id+"' style='width: 450px; height: 300px; background: #f3f3f3; border:none;' frameborder=0 scrolling=no></iframe></td></tr></table>";
	getObj('MESSAGE_FORM').className="message_form"; 
	
	showdeadcenterdiv(450,300,'MESSAGE_FORM');

}
function createNotes(to_id){
	getObj('MESSAGE_FORM').innerHTML= "<table cellpadding=10><tr><td><iframe src='/song_notes.php?songid="+to_id+"' style='width: 450px; height: 300px; background: #f3f3f3; border:none;' frameborder=0 scrolling=no></iframe></td></tr></table>";
	getObj('MESSAGE_FORM').className="message_form"; 
	
	showdeadcenterdiv(450,300,'MESSAGE_FORM');

}
function createLyrics(to_id){
	getObj('MESSAGE_FORM').innerHTML= "<table cellpadding=10><tr><td><iframe src='/song_lyrics.php?songid="+to_id+"' style='width: 630px; height: 470px; background: #f3f3f3; border:none;' frameborder=0 scrolling=no></iframe></td></tr></table>";
	getObj('MESSAGE_FORM').className="message_form"; 
	
	showdeadcenterdiv(630,470,'MESSAGE_FORM');

}
function createPrint(song_id,a_id){
	getObj('MESSAGE_FORM').innerHTML= "<table cellpadding=10><tr><td><iframe src='/print_properties.php?a_id="+a_id+"&s_id="+song_id+"' style='width: 450px; height: 300px; background: #f3f3f3; border:none;' frameborder=0 scrolling=no></iframe></td></tr></table>";
	getObj('MESSAGE_FORM').className="message_form"; 
	
	showdeadcenterdiv(450,300,'MESSAGE_FORM');

}

function createMP3(song_id,sf_id,a_id){
	getObj('MESSAGE_FORM').innerHTML= "<table cellpadding=10><tr><td><iframe src='/mp3_form.php?song_id="+song_id+"&sf_id="+sf_id+"&a_id="+a_id+"' style='width: 450px; height: 300px; background: #f3f3f3; border:none;' frameborder=0 scrolling=no></iframe></td></tr></table>";
	getObj('MESSAGE_FORM').className="message_form"; 
	
	showdeadcenterdiv(450,300,'MESSAGE_FORM');

}

function createSongComments(to_id){
	getObj('MESSAGE_FORM').innerHTML= "<table cellpadding=10><tr><td><iframe src='/song_comments.php?songid="+to_id+"' style='width: 450px; height: 300px; background: #f3f3f3; border:none;' frameborder=0 scrolling=no></iframe></td></tr></table>";
	getObj('MESSAGE_FORM').className="message_form"; 
	
	showdeadcenterdiv(450,300,'MESSAGE_FORM');

}
function createArtistComments(to_id){
	getObj('MESSAGE_FORM').innerHTML= "<table cellpadding=10><tr><td><iframe src='/artist_comments.php?a_id="+to_id+"' style='width: 450px; height: 300px; background: #f3f3f3; border:none;' frameborder=0 scrolling=no></iframe></td></tr></table>";
	getObj('MESSAGE_FORM').className="message_form"; 
	
	showdeadcenterdiv(450,300,'MESSAGE_FORM');

}

function downloadSong(to_id){
	getObj('MESSAGE_FORM').innerHTML= "<table cellpadding=10><tr><td><iframe src='/song_download.php?songid="+to_id+"' style='width: 450px; height: 300px; background: #f3f3f3; border:none;' frameborder=0 scrolling=no></iframe></td></tr></table>";
	getObj('MESSAGE_FORM').className="message_form"; 
	
	showdeadcenterdiv(450,300,'MESSAGE_FORM');

}
function createArtistTypes(to_id){
	getObj('MESSAGE_FORM').innerHTML= "<table cellpadding=10><tr><td><iframe src='/artist_types.php?a_id="+to_id+"' style='width: 450px; height: 300px; background: #f3f3f3; border:none;' frameborder=0 scrolling=no></iframe></td></tr></table>";
	getObj('MESSAGE_FORM').className="message_form"; 
	
	showdeadcenterdiv(450,300,'MESSAGE_FORM');

}
