
   function Accordian(target) {
   	typeof target == "object" ? this.element = target : this.element = document.getElementById(target); if (!this.element) return false;  
   	this.ul = this.element.getElementsByTagName("ul")[0]; 
   	this.tabs = this.ul.getElementsByTagName("li");
   	this.tabContent = this.getTabContent();
   	this.bind();
   }

   Accordian.prototype.getTabContent = function() {
   	tabContent= new Array();    
   	this.divs = this.element.getElementsByTagName("div");
   	for(var i = 0; i < this.divs.length; i++) {
           if (/tabContent/i.test(this.divs[i].className)) {
           tabContent.push(this.divs[i]);                        
   		}
   	}
   	return tabContent;
   }


   Accordian.prototype.bind = function() {    
   	var o = this;
   	for(var i = 0; i < this.tabs.length; i++) {
   		this.tabs[i].onclick = function() { 
   		   if (this.className != 'selected') {
   		      o.open(this); return false;
   		      var a = this.getElementsByTagName("a")[0];
   		      if (a) a.onclick = function() { 
                    return false; 
               }
   		   }
   		} 
   	}
   }

   Accordian.prototype.open = function(caller) {    
   	for(var i = 0; i < this.tabs.length; i++) {
   		var tab = this.tabs[i]; 
   		if (tab == caller) {  
   			this.collapse();
   			tab.className = "selected"
   			this.tabContent[i].style.display = "block";
   		}
   	}
   }

   Accordian.prototype.collapse = function() {
   	for(var i = 0; i < this.tabs.length; i++) {    
   		this.tabs[i].className = "";
   		this.tabContent[i].style.display = "none";                 
   	}                                                                
   }
  
  function switchDiv(divid){
  	var linkid = 'link'+divid;
    if(document.getElementById(divid).style.display == 'none') {
      document.getElementById(divid).style.display = 'block';
	  document.getElementById(linkid).className = 'unhidden';
    } else {
      document.getElementById(divid).style.display = 'none';
	  document.getElementById(linkid).className = 'hidden';
    }
  }
  
  function closeDiv(divid){
  	 var linkid = 'link'+divid;
	 document.getElementById(divid).style.display = 'none';
	 document.getElementById(linkid).className = 'hidden';
  }
  function closeDivs(){
	 closeDiv('shoppingblock');
	 closeDiv('foodblock');
	 closeDiv('cultureblock');
	 closeDiv('servicesblock');
	 closeDiv('friendsblock');
  }
  function switchDiv(divid){
  	var linkid = 'link'+divid;
    if(document.getElementById(divid).style.display == 'none') {
      document.getElementById(divid).style.display = 'block';
	  document.getElementById(linkid).className = 'unhidden';
    } else {
      document.getElementById(divid).style.display = 'none';
	  document.getElementById(linkid).className = 'hidden';
    }
  }
  function switchArticle(divid){
  	var linkid = 'link'+divid;
	var shortid = 'short'+divid;
    if(document.getElementById(divid).style.display == 'none') {
      document.getElementById(divid).style.display = 'block';
	  document.getElementById(shortid).style.display = 'none';
	  document.getElementById(linkid).className = 'unhiddenarticle';
    } else {
      document.getElementById(divid).style.display = 'none';
	  document.getElementById(shortid).style.display = 'block';
	  document.getElementById(linkid).className = 'hiddenarticle';
    }
  }
  
  function switchFeature(divid){
  	var linkid = 'link'+divid;
	var shortid = 'short'+divid;
    if(document.getElementById(divid).style.display == 'none') {
      document.getElementById(divid).style.display = 'block';
	  document.getElementById(shortid).style.display = 'none';
	  document.getElementById(linkid).className = 'unhiddenfeature';
    } else {
      document.getElementById(divid).style.display = 'none';
	  document.getElementById(shortid).style.display = 'block';
	  document.getElementById(linkid).className = 'hiddenfeature';
    }
  }
  
  function switchUpdate(divid){
  	var linkid = 'link'+divid;
	var shortid = 'short'+divid;
    if(document.getElementById(divid).style.display == 'none') {
      document.getElementById(divid).style.display = 'block';
	  document.getElementById(shortid).style.display = 'none';
	  document.getElementById(linkid).className = 'unhiddenupdate';
    } else {
      document.getElementById(divid).style.display = 'none';
	  document.getElementById(shortid).style.display = 'block';
	  document.getElementById(linkid).className = 'hiddenupdate';
    }
  }
  
  function OnChange(dropdown)
{
    var myindex  = dropdown.selectedIndex
    var SelValue = dropdown.options[myindex].value
    var baseURL  = "eco-magazine2.php?id=" + SelValue
    top.location.href = baseURL;
    
    return true;
}
function OnChangeNet(dropdown)
{
    var myindex  = dropdown.selectedIndex
    var SelValue = dropdown.options[myindex].value
    var baseURL  = "netmag2.php?id=" + SelValue
    top.location.href = baseURL;
    
    return true;
}
function OnChangeBlog(dropdown)
{
    var myindex  = dropdown.selectedIndex
    var SelValue = dropdown.options[myindex].value
    var baseURL  = "eco-life2.php?id=" + SelValue
    top.location.href = baseURL;
    
    return true;
}

function checkform()
{
	if (document.contact.name.value=='')
	{
		alert('Please fill in your name.');
		return false;
	}
	else if (document.contact.email.value=='')
	{
		alert('Please fill in your email address.');
		return false;
	}
	else if (document.contact.message.value=='')
	{
		alert('Please enter a message.');
		return false;
	}
	return true;
}
function adcheckform()
{
	if (document.adcontact.name.value=='')
	{
		alert('Please fill in your name.');
		return false;
	}
	else if (document.adcontact.email.value=='')
	{
		alert('Please fill in your email address.');
		return false;
	}
	else if (document.adcontact.message.value=='')
	{
		alert('Please enter a message.');
		return false;
	}
	return true;
}
function subcheckform()
{
	if (document.submitform.name.value=='')
	{
		alert('Please fill in your name.');
		return false;
	}
	else if (document.submitform.email.value=='')
	{
		alert('Please fill in your email address.');
		return false;
	}
	else if (document.submitform.message.value=='')
	{
		alert('Please enter your story.');
		return false;
	}
	return true;
}
var win = null;
function newWindow(mypage,myname,w,h,features) {
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}

function getHeight (id) {  
		var gh = document.getElementById(id).offsetHeight;
		return gh;
	}
	
function setDotted() {
	var contentHeight = getHeight('content');
	var leftHeight = getHeight('left');
	if (contentHeight > leftHeight) {
		document.getElementById('content').style.borderLeft="1px dotted #333";
	} else {
		document.getElementById('left').style.borderRight="1px dotted #333";
	}

}
