var loaded=false


function BrowserCheck() {
    
    var b = navigator.appName
    if (b=="Netscape") this.b = "ns"
    else if (b=="Microsoft Internet Explorer") this.b = "ie"
    else this.b = "ie";
  
    this.v = parseInt(navigator.appVersion)
    this.ns = (this.b=="ns" && this.v==4)
    this.ns4 = (this.b=="ns" && this.v==4)
    this.ie = ((this.b=="ie" && this.v>=4)||(this.b=="ns" && this.v>=5))
    this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
    this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
    this.moz = (this.b=="ns" && this.v>=5)

    if (this.ie5) this.v = 5
    this.min = (this.ns||this.ie)

    if(!this.ns) this.ie=true;
}

is = new BrowserCheck()

// Show/Hide script
function show(id) { 
    if (is.ns && document.layers[id]) document.layers[id].display = "inline"
    else if (is.ie4 && document.all[id]) document.all[id].style.display = "inline"
    else if (is.ie && document.getElementById(id)) document.getElementById(id).style.display = "inline"
}

function hide(id) {

    if (is.ns && document.layers[id]) document.layers[id].display = "none"
    else if (is.ie4 && document.all[id]) document.all[id].style.display = "none"
    else if (is.ie && document.getElementById(id)) document.getElementById(id).style.display = "none"
}


function hideall() {
                     hide('home');
               changeImage('mainNav', 'b_home', 'home_active');
                            hide('searching');
               changeImage('mainNav', 'b_searching', 'searching_active');
                                    hide('invite');
               changeImage('mainNav', 'b_invites', 'invites_active');
                                    hide('mail');
               changeImage('mainNav', 'b_mail', 'mail_active');
			                        hide('blog');
               changeImage('mainNav', 'b_blog', 'blog_active');

									hide('forum');
               changeImage('mainNav', 'b_forum', 'forum_active');

									hide('myprofile');
               changeImage('mainNav', 'b_myprofile', 'myprofile_active');

									hide('groups');
               changeImage('mainNav', 'b_groups', 'groups_active');

									hide('space');
               changeImage('mainNav', 'b_space', 'space_active');

									hide('browse');
               changeImage('mainNav', 'b_browse', 'browse_active');

									hide('letters');
               changeImage('mainNav', 'b_letters', 'letters_active');

									hide('ratings');
               changeImage('mainNav', 'b_ratings', 'ratings_active');

									hide('classifieds');
               changeImage('mainNav', 'b_classifieds', 'classifieds_active');

   									hide('signup');
               changeImage('mainNav', 'b_signup', 'signup_active');

                  
}

function hidesignoutall() {
                     hide('home');
               changeImage('mainNav', 'b_home', 'home_active');
                            hide('searching');
               changeImage('mainNav', 'b_searching', 'searching_active');
                                    hide('invite');
               changeImage('mainNav', 'b_invites', 'invites_active');
                                    hide('mail');
               changeImage('mainNav', 'b_mail', 'mail_active');
			                        hide('blog');
               changeImage('mainNav', 'b_blog', 'blog_active');

									hide('forum');
               changeImage('mainNav', 'b_forum', 'forum_active');

									hide('myprofile');
               changeImage('mainNav', 'b_myprofile', 'myprofile_active');

									hide('groups');
               changeImage('mainNav', 'b_groups', 'groups_active');

									hide('space');
               changeImage('mainNav', 'b_space', 'space_active');

									hide('browse');
               changeImage('mainNav', 'b_browse', 'browse_active');

									hide('letters');
               changeImage('mainNav', 'b_letters', 'letters_active');

									hide('ratings');
               changeImage('mainNav', 'b_ratings', 'ratings_active');

									hide('classifieds');
               changeImage('mainNav', 'b_classifieds', 'classifieds_active');

   									hide('signout');
               changeImage('mainNav', 'b_signout', 'signout_active');
}

function reset(activeTab) {
//  if(activeTab == '') activeTab = 'home';
  if (loaded) {
                              hide('home');

                     changeImage('mainNav', 'b_home', 'home_active');

							  hide('searching');
                     changeImage('mainNav', 'b_searching', 'searching_active');

                              hide('invite');
                     changeImage('mainNav', 'b_invites', 'invites_active');

                              hide('mail');
                     changeImage('mainNav', 'b_mail', 'mail_active');

							   hide('blog');
                     changeImage('mainNav', 'b_blog', 'blog_active');

 							   hide('forum');
                     changeImage('mainNav', 'b_forum', 'forum_active');

 							   hide('myprofile');
                     changeImage('mainNav', 'b_myprofile', 'myprofile_active');

							   hide('groups');
                     changeImage('mainNav', 'b_groups', 'groups_active');

							   hide('space');
                     changeImage('mainNav', 'b_space', 'space_active');

							   hide('browse');
                     changeImage('mainNav', 'b_browse', 'browse_active');

							   hide('letters');
                     changeImage('mainNav', 'b_letters', 'letters_active');

							   hide('ratings');
                     changeImage('mainNav', 'b_ratings', 'ratings_active');

							   hide('classifieds');
                     changeImage('mainNav', 'b_classifieds', 'classifieds_active');
 							   hide('signup');
                     changeImage('mainNav', 'b_signup', 'signup_active');
					 if(activeTab != '')
					  {
							  show(activeTab);
					 changeImage('mainNav', 'b_'+activeTab, activeTab+'_inactive');
					  }


  }
}

function resetsignout(activeTab) {
//  if(activeTab == '') activeTab = 'home';
  if (loaded) {
                              hide('home');

                     changeImage('mainNav', 'b_home', 'home_active');

							  hide('searching');
                     changeImage('mainNav', 'b_searching', 'searching_active');

                              hide('invite');
                     changeImage('mainNav', 'b_invites', 'invites_active');

                              hide('mail');
                     changeImage('mainNav', 'b_mail', 'mail_active');

							   hide('blog');
                     changeImage('mainNav', 'b_blog', 'blog_active');

 							   hide('forum');
                     changeImage('mainNav', 'b_forum', 'forum_active');

 							   hide('myprofile');
                     changeImage('mainNav', 'b_myprofile', 'myprofile_active');

							   hide('groups');
                     changeImage('mainNav', 'b_groups', 'groups_active');

							   hide('space');
                     changeImage('mainNav', 'b_space', 'space_active');

							   hide('browse');
                     changeImage('mainNav', 'b_browse', 'browse_active');

							   hide('letters');
                     changeImage('mainNav', 'b_letters', 'letters_active');

							   hide('ratings');
                     changeImage('mainNav', 'b_ratings', 'ratings_active');

							   hide('classifieds');
                     changeImage('mainNav', 'b_classifieds', 'classifieds_active');
 							   hide('signout');
                     changeImage('mainNav', 'b_signout', 'signout_active');
					 if(activeTab != '')
					  {
							  show(activeTab);
                     changeImage('mainNav', 'b_'+activeTab, activeTab+'_inactive');
					  }


  }
}


function preload(imgObj,imgSrc) {
  
  if (document.images) {
   
    eval(imgObj+' = new Image()')
    eval(imgObj+'.src = "'+imgSrc+'"')
  }
}

function changeImage(layer,imgName,imgObj) {
  
  if (document.images) {
    if (document.layers && layer!=null) eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src')
    else document.images[imgName].src = eval(imgObj+".src")
  }
}

function checkwidth(o,rh) {

   var w = o.width, h = o.height
   o.width = (o.width > 640) ? 640 : w;
   o.height = (rh) ? h : 640;
}


preload('home_active','./../images/home_but.gif');
preload('home_inactive','./../images/home_but-r.gif');

preload('searching_active','./../images/search_but.gif');
preload('searching_inactive','./../images/search_but-r.gif');

preload('invites_active','./../images/invite_but.gif');
preload('invites_inactive','./../images/invite_but-r.gif');

preload('mail_active','./../images/mail_but.gif');
preload('mail_inactive','./../images/mail_but-r.gif');

preload('blog_active','./../images/blog_but.gif');
preload('blog_inactive','./../images/blog_but-r.gif');

preload('forum_active','./../images/forum_but.gif');
preload('forum_inactive','./../images/forum_but-r.gif');

preload('myprofile_active','./../images/myprofile_but.gif');
preload('myprofile_inactive','./../images/myprofile_but-r.gif');

preload('groups_active','./../images/groups_but.gif');
preload('groups_inactive','./../images/groups_but-r.gif');
     
preload('space_active','./../images/space_but.gif');
preload('space_inactive','./../images/space_but-r.gif');

preload('browse_active','./../images/browse_but.gif');
preload('browse_inactive','./../images/browse_but-r.gif');

preload('letters_active','./../images/letters_but.gif');
preload('letters_inactive','./../images/letters_but-r.gif');

preload('ratings_active','./../images/ratings_but.gif');
preload('ratings_inactive','./../images/ratings_but-r.gif');

preload('classifieds_active','./../images/classifieds_but.gif');
preload('classifieds_inactive','./../images/classifieds_but-r.gif');

preload('signup_active','./../images/signup_but.gif');
preload('signup_inactive','./../images/signup_but-r.gif');

preload('signout_active','./../images/signout_but.gif');
preload('signout_inactive','./../images/signout_but-r.gif');

loaded = true;
// Function for displaying the image popup
var imageWindow;
function image_popup(url, title) {

	if (imageWindow && !imageWindow.closed) { 
		imageWindow.resizeTo(200, 150);
		imageWindow.focus(); 
		imageWindow.document.clear();		
	} else { 
		imageWindow=window.open('','','width=200,height=150,resizable=0') 
	}
	imageWindow.document.writeln('<html>');
	imageWindow.document.writeln('  <head>');
	imageWindow.document.writeln('    <title>'+title+'<\/title>');
	imageWindow.document.writeln('    <script language="javascript">');

	imageWindow.document.writeln('       var arrTemp=self.location.href.split("?");');
	imageWindow.document.writeln('       var picUrl = (arrTemp.length>0)?arrTemp[1]:"";');
	imageWindow.document.writeln('       var NS = (navigator.appName=="Netscape")?true:false;');
	imageWindow.document.writeln('         function FitPic() {');
	imageWindow.document.writeln('           iWidth = (NS)?window.innerWidth:document.body.clientWidth;');
	imageWindow.document.writeln('           iHeight = (NS)?window.innerHeight:document.body.clientHeight;');
	imageWindow.document.writeln('           iWidth = document.images[0].width - iWidth;');
	imageWindow.document.writeln('           iHeight = document.images[0].height - iHeight;');
	imageWindow.document.writeln('           window.resizeBy(iWidth, iHeight);');
	imageWindow.document.writeln('           self.focus();');
	imageWindow.document.writeln('         };');
 	imageWindow.document.writeln('    <\/script>');
	imageWindow.document.writeln('  <\/head>');
	imageWindow.document.writeln('  <body style="margin: 0px;" onblur="self.close();" onload="FitPic();">');
	imageWindow.document.writeln('    <img src="'+url+'" alt="'+title+'" />');
	imageWindow.document.writeln('  <\/body>');
	imageWindow.document.writeln('<\/html>');
	imageWindow.document.close();
	imageWindow.focus();
}

