var visible_popup = "";
var active_area = "";
var timeout = 0;

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 handlePopupClick(Event){
	alert("huhu");
	
}

function switch_visibility(id) {
	if (is_visible(id)) {
		hidediv(id);
	} else {
		showdiv(id);
	}
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidesoon(id){
	window.setTimeout("hidediv('"+id+"')",700);
    active_area="";
}

function hidediv(id) {
	if (id!=visible_popup && id!=active_area){
		//safe function to hide an element with a specified id
		if (document.getElementById) { // DOM3 = IE5, NS6
			
			document.getElementById(id).style.display = 'none';
		}
		else {
			if (document.layers) { // Netscape 4
				document.id.display = 'none';
			}
			else { // IE 4
				document.all.id.style.display = 'none';
			}
		}	
	}

}

function showdiv(id) {
	active_area = id;
	//safe function to show an element with a specified id

	if (document.getElementById) { // DOM3 = IE5, NS6		  
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function is_visible(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == 'none') {
			return false;
		} else {
			return true;
		}
	} else {
		if (document.layers) { // Netscape 4
			if (document.id.display == 'none') {
				return false;
			} else {
				return true;
			}
		} else { // IE 4
			if (document.all.id.style.display == 'none') {
				return false;
			} else {
				return true;
			}
		}
	}
}


function setPopupVisible(id){
	visible_popup = id;
}

function setPopupInvisible(id){
	visible_popup = "";
	hidesoon(id);
}

function select_ecard(id){
	
	var ecards_box = document.getElementById('ecards-box');
	var ecards = ecards_box.getElementsByTagName('img');
	
	for(i = 0; i < ecards.length; i++){
		var ecard = ecards[i];
		ecard.style.display = "none";
	}
	
	var ecardx = document.getElementById('ecard_'+id);
	ecardx.style.display = "inline";
}

function truncate_area(){
	//document.getElementById('count').innerHTML=this.value.length;
	area = document.getElementById('cnt');
	if (area.value.length > 999) {
		area.value = area.value.substr(0, 999);
	}
}
