function showUserLink(href)
{
	if (confirm('We cannot guarantee that this site is legal.\nPlease read the FAQ for more info'))
		window.open('outside_frameset.php?'+href,'_blank');
}

function showClubPicture(id)
{
	window.open('club_pictures_show_large.php?lngID='+id,'_blank','width=200,height=200,resizable=0,scrollbars=0');
}

function showUserPicture(id)
{
	window.open('profile_pictures_show_large.php?lngID='+id,'_blank','width=200,height=200,resizable=0,scrollbars=0');
}
function sendInstantMessage(lngRID,lngSID,strUserName)
{
	if (lngSID!=lngRID)
		window.open('messages_send_instant.php?strUserName='+strUserName+'&lngRID='+lngRID,'messages_send_instant'+lngRID,'height=350,width=315');
	else
    	alert('Sending to yourself? Now that\'s not gonna work :\)');
}

function readInstantMessage(lngMID)
{
	window.open('messages_read_instant.php?lngMID='+lngMID,'messages_read_instant'+lngMID,'height=350,width=330,scrollbars=yes');
}

function sendSupportMessage()
{
	window.open('messages_send_support.php','messages_send_support','height=300,width=330,scrollbars=yes');
}

function verify(strAction,strQuestion)
{
    if (confirm('Delete '+strQuestion+'?'))
        window.location=strAction;
}

function left_status_update(name,count,message)
{
    var image=false;
		var bln = (count>0);
		if (document.all)
        image = window.top.document.all('left_'+name+'_image');
    else if (document.getElementById)
        image = window.top.document.getElementById('left_'+name+'_image');
    if (!image)
        return;

    var newsrc = 'images/left_menu_'+name+'_'+((bln=='1')?'on':'off')+'.gif';
    if (image.src != newsrc) image.src = newsrc;
    if (bln)
        image.title = message;
    else
        image.title = '';
}

function left_status_parse(data)
{
    var arr = data.split(':');
    if (arr[0])
		{
			if (document.getElementById && document.getElementById('onlinecount'))
				document.getElementById('onlinecount').innerText = arr[0];
		}
		if (arr[1])
    {
        if (arr[1].indexOf(';')>=0)
        {
					var arr2 = arr[1].split(';');
					for (var i=0;i<arr2.length;i++)
						if (arr2[i])
							readInstantMessage(arr2[i]);
        }
        else if (arr[1].length>0)
            left_status_update('mail',parseInt(arr[1]),'You have '+arr[1]+' message(s) waiting');
    }
    if (arr[2])
        left_status_update('contacts',parseInt(arr[2]),'You have contact(s) waiting');
    if (arr[3])
        left_status_update('guestbook',parseInt(arr[3]),'Someone has written in your guestbook');
    if (arr[4])
        left_status_update('discussion',parseInt(arr[4]),'You have '+arr[3]+' replies in the FORUM');
    if (arr[5])
        left_status_update('diary',parseInt(arr[5]),'You have '+arr[5]+' comments in your diary');
}
function left_status_check()
{
    var o = document.getElementById('left_status_layer');
	if (!document.all) return;
    if (o)
    {
        o.startDownload('messages_popup_instant_ie5.php',left_status_parse);
    }
}


	function _show_context()
	{
		var d = document;
		if (!d.getElementById) return;
		var _e = event.srcElement;
		if (_e.tagName != 'A')
			if (_e.parentElement && _e.parentElement.tagName != 'A')
			{
  			if (_e.parentElement.parentElement && _e.parentElement.parentElement.tagName == 'A')
  				_e = _e.parentElement.parentElement;
			}
			else
				_e = _e.parentElement;
		
		var re = /profile[.]+php[?]+lngUID=([0-9]+)$/;
		
		if (_e.tagName == 'A' && _e.href.match(re))
		{
			var tmp = _e.href.match(re);

			caui = tmp[1];
			var div = d.getElementById('uc');
			div.style.left = event.clientX+d.body.scrollLeft;
			div.style.top = event.clientY+d.body.scrollTop;
			div.style.visibility = 'visible';
			d.getElementById('uc_image').src = 'profile_get_image.php?lngUID='+caui+'&size=b';
			event.returnValue=false;
			event.cancelBubble=true;
			return false;
		}
	}
	function _hide_context()
	{
			var d = document;
			var div = d.getElementById('uc');
			d.getElementById('uc_image').src = 'images/nothing.gif';
			div.style.visibility = 'hidden';
	}

	function get_gsm_logo(format,category,logo)
	{
		window.open('gsm_logo_send_popup.php?format='+format+'&cat='+category+'&logo='+logo,'gsm_logo_popup','height=350,width=330,scrollbars=no');
	}
	
	function gf_validate_password(password)
	{
		var allowedchars = 'abcdefghijklmnopqrstuvwxyz1234567890,.-;:_+!"@#��$%�&/{([)]=}?*';
		var illegalfound = false;
		var character = '';
		if (password.length < 5)
			return gv_password_error_to_short;
		if (password.length > 20)
			return gv_password_error_to_long;
		for (var i=0;i<password.length;i++)
			if (allowedchars.indexOf(password.charAt(i).toLowerCase()) == -1)
				return gv_password_error_character;
		return gv_password_error_no;
	}
	
	var gv_password_error_no        =  0;
	var gv_password_error_to_short  = -1;
	var gv_password_error_to_long   = -2;
	var gv_password_error_character = -3;

function sprintf(str)
{
	var i;
	var arg;
	for (i=1;i<arguments.length;i++)
	{
		arg = arguments[i];
		switch(typeof(arg))
		{
			case 'number':
				str = str.replace(/%d/,arg);
				break;
			case 'boolean':
				str = str.replace(/%b/,arg);
				break;
			default:
				str = str.replace(/%s/,arg);
		}
	}
	return str;
}
function displayDiv(objName, state){

	if(objName!='undefined' && objName!=""){
		if(state != 'undefined' && state != ""){

			obj=document.getElementById(objName);
			orygStyle = obj.style.display;
			
			switch(state){

				case 'block':
					obj.style.display = 'block';
				break;
				case 'none':
					obj.style.display = 'none';
				break;
				default:
					obj.style.display = 'block';
				break;
			}
		}else{
			orygStyle = obj.style.display;
			
			switch(orygStyle){

				case 'block':
					obj.style.display = 'none';
				break;
				case 'none':
					obj.style.display = 'block';
				break;
				default:
					obj.style.display = 'block';
				break;
			}
		}
	}
	return false;
}



function showAlbumEdit() {
	var state = document.forms['saveAlbum'].style.display;
	if(state=='none') {
				document.forms['saveAlbum'].style.display = 'block';
				document.forms['addAlbum'].style.display = 'none';
        } else {
                document.forms['saveAlbum'].style.display = 'none';
			
	}
}

function showAlbumAdd() {
	var state = document.forms['addAlbum'].style.display;
	if(state=='none') {
                document.forms['addAlbum'].style.display = 'block';
                document.forms['saveAlbum'].style.display = 'none';
        } else {
                document.forms['addAlbum'].style.display = 'none';
			
	}
}


        // by cmike
        function select_innerHTML(objeto,innerHTML){
		    objeto.innerHTML = ""
		    var selTemp = document.createElement("micoxselect")
		    var opt;
		    selTemp.id="micoxselect1"
		    document.body.appendChild(selTemp)
		    selTemp = document.getElementById("micoxselect1")
		    selTemp.style.display="none"
		    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto
		        innerHTML = "<option>" + innerHTML + "</option>"
		    }
		    innerHTML = innerHTML.toLowerCase().replace(/<option/g,"<span").replace(/<\/option/g,"</span")
		    selTemp.innerHTML = innerHTML
		      
		    
		    for(var i=0;i<selTemp.childNodes.length;i++){
		  var spantemp = selTemp.childNodes[i];
		  
		        if(spantemp.tagName){     
		            opt = document.createElement("OPTION")
		    
		   if(document.all){ //IE
		    objeto.add(opt)
		   }else{
		    objeto.appendChild(opt)
		   }       
		    
		   //getting attributes
		   for(var j=0; j<spantemp.attributes.length ; j++){
		    var attrName = spantemp.attributes[j].nodeName;
		    var attrVal = spantemp.attributes[j].nodeValue;
		    if(attrVal){
		     try{
		      opt.setAttribute(attrName,attrVal);
		      opt.setAttributeNode(spantemp.attributes[j].cloneNode(true));
		     }catch(e){}
		    }
		   }
		   //getting styles
		   if(spantemp.style){
		    for(var y in spantemp.style){
		     try{opt.style[y] = spantemp.style[y];}catch(e){}
		    }
		   }
		   //value and text
		   opt.value = spantemp.getAttribute("value")
		   opt.text = spantemp.innerHTML
		   //IE
		   opt.selected = spantemp.getAttribute('selected');
		   opt.className = spantemp.className;
		  } 
		 }    
		 document.body.removeChild(selTemp)
		 selTemp = null
		}
        
        function getEid(id)
        {
        	return document.getElementById ? document.getElementById(id):document.all[id];
        }
        function loadRegions()
        {
                var f = document.forms['userpreferences'];
                var country = f.lstrCountry.value;
                
                var req = mint.Request();
                
                req.OnSuccess = function() {
                    getEid("regionList").innerHTML = this.responseText;
                }
        
                req.Send(domena+"/ajax.php?axn=loadRegions&countryID="+country);
        }
        
        function loadCities(regionID)
        {
                
                var req = mint.Request();
                
                req.OnSuccess = function() {
                	getEid("citiesList").innerHTML = this.responseText;
                }
                
                req.OnError = function() {
                	alert(this.responseText);
                }
        
                req.Send(domena+"/ajax.php?axn=loadCities&regionID="+regionID);
        }
        
        function loadCitiesStart(regionID)
        {
                
                var req = mint.Request();
                
                req.OnSuccess = function() {
                	getEid("citiesList").innerHTML = this.responseText;
                }
                
                req.OnError = function() {
                	alert(this.responseText);
                }
        
                req.Send(domena+"/ajax.php?axn=loadCitiesStart&regionID="+regionID);
        }
        
        function fillF(tekst,pole) {
                if(pole.value=='')
                {
                        pole.value=tekst;
                }
        }
        
        function clearF(tekst,pole) {
                if(pole.value==tekst)
                {
                        pole.value='';
                }
        }
        
        function make_editor()
        {
        	return;
        }
        
        function html_entity_decode(str) {
			var	tarea=document.createElement('textarea');
			tarea.innerHTML = str; 
			return tarea.value;
			tarea.parentNode.removeChild(tarea);
		}
