function show_element(id)
{
	obj = document.getElementById(id);
	 
	if(obj)
	{
		obj.style.display = "";
	}
}

function hide_element(id)
{
	obj = document.getElementById(id);
	
	if(obj)
	{
		obj.style.display = "none";
	}
}

function change_bg(id, bgcolor)
{
	obj = document.getElementById(id);
	 
	if(obj)
	{
		obj.style.backgroundColor = bgcolor;
	}
}

function tabs_myprofile(tabId)
{
	var f1 = "formPeronalData";
	var f2 = "formSexPrios";
	var f4 = "formPassword";
	var f5 = "formFamily";
	var f6 = "formAppearance";
	var f7 = "formWorkData";
	var f8 = "formLifePrios";
	
	hide_element(f1);
	hide_element(f2);
	hide_element(f4);
	hide_element(f5);
	hide_element(f6);
	hide_element(f7);
	hide_element(f8);
	
	change_bg('profileGroups1', '#e2e2e2');
	change_bg('profileGroups2', '#e2e2e2');
	change_bg('profileGroups4', '#e2e2e2');
	change_bg('profileGroups5', '#e2e2e2');
	change_bg('profileGroups6', '#e2e2e2');
	change_bg('profileGroups7', '#e2e2e2');
	change_bg('profileGroups8', '#e2e2e2');
	
	if(tabId == 1)
	{
		show_element(f1);
		change_bg('profileGroups1', '#fff');
	}
	else if(tabId == 2)
	{
		show_element(f2);
		change_bg('profileGroups2', '#fff');
	}
	else if(tabId == 4)
	{
		show_element(f4);
		change_bg('profileGroups4', '#fff');
	}
	else if(tabId == 5)
	{
		show_element(f5);
		change_bg('profileGroups5', '#fff');
	}
	else if(tabId == 6)
	{
		show_element(f6);
		change_bg('profileGroups6', '#fff');
	}
	else if(tabId == 7)
	{
		show_element(f7);
		change_bg('profileGroups7', '#fff');
	}
	else if(tabId == 8)
	{
		show_element(f8);
		change_bg('profileGroups8', '#fff');
	}
}

function tabs_profile(tabId)
{
	var f1 = "formPersonalData";
	var f2 = "formSexPrios";
	var f4 = "formFamily";
	var f5 = "formAppearance";
	var f6 = "formWorkData";
	var f7 = "formLifePrios";
	
	hide_element(f1);
	hide_element(f2);
	hide_element(f4);
	hide_element(f5);
	hide_element(f6);
	hide_element(f7);
	
	change_bg('profileDetailsGroups1', '#e2e2e2');
	change_bg('profileDetailsGroups2', '#e2e2e2');
	change_bg('profileDetailsGroups4', '#e2e2e2');
	change_bg('profileDetailsGroups5', '#e2e2e2');
	change_bg('profileDetailsGroups6', '#e2e2e2');
	change_bg('profileDetailsGroups7', '#e2e2e2');
	
	if(tabId == 1)
	{
		show_element(f1);
		change_bg('profileDetailsGroups1', '#fff');
	}
	else if(tabId == 2)
	{
		show_element(f2);
		change_bg('profileDetailsGroups2', '#fff');
	}
	else if(tabId == 4)
	{
		show_element(f4);
		change_bg('profileDetailsGroups4', '#fff');
	}
	else if(tabId == 5)
	{
		show_element(f5);
		change_bg('profileDetailsGroups5', '#fff');
	}
	else if(tabId == 6)
	{
		show_element(f6);
		change_bg('profileDetailsGroups6', '#fff');
	}
	else if(tabId == 7)
	{
		show_element(f7);
		change_bg('profileDetailsGroups7', '#fff');
	}
}

function tabs_rbar_video(tabId)
{
	var tab_uv = "videos_user";
	var tab_rv = "videos_related";
	
	hide_element(tab_uv);
	hide_element(tab_rv);
		
	change_bg('rbarVideoMenu1', '#e2e2e2');
	change_bg('rbarVideoMenu2', '#e2e2e2');
	
	if(tabId == 1)
	{
		show_element(tab_uv);
		change_bg('rbarVideoMenu1', '#fff');
	}
	else if(tabId == 2)
	{
		show_element(tab_rv);
		change_bg('rbarVideoMenu2', '#fff');
	}
}

function AppendText(id, text)
{
    obj = document.getElementById(id);
	 
	if(obj)
	{
	    if(obj.value == "")
	    {
	        obj.value = text;
	    }
	    else
	    {
	        obj.value = obj.value + ", " + text;
	    }
	}
}

/* 

    Emoticons

*/

function Emoticon(id, text)
{
    obj = document.getElementById(id);
    	 
	if(obj)
	{
	    obj.value = obj.value + text;
	    obj.focus();
	}
}

function openwin(theURL, wi, he, sc)
{
	var s=",width="+wi+",height="+he+",scrollbars="+sc;
	var cwin = window.open(theURL, "winMaruniPict", "toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1"+s, true);
	cwin.focus();
	return true;
}

var mail_upload_file;
mail_upload_file = 0;

function ShowHideMailUpload()
{
    if(mail_upload_file == 0)
    {
        show_element("mail_upload");
    }
}

function ShowHideColorPicker()
{
    show_element("bgcolor_picker");
}

function selectBgColor(color, hidden)
{
    obj = document.getElementById('color_list');
    hid = document.getElementById(hidden);
    	 
	if(obj)
	{
	    obj.style.backgroundColor = color;
	    hid.value = color;
	}
}

// --------------------------------------
// register Form functions
// --------------------------------------

function registerValidatePassword(errorText)
{
    objP1 = document.getElementById("password");
    objP2 = document.getElementById("password2");
    errorDiv = document.getElementById("registerForm_element_password");
    
    if(objP1 && objP2)
    {
        if(objP1.value != "" && objP2.value != "")
        {
            if(objP1.value != objP2.value)
            {
                errorDiv.innerHTML = errorText;
            }
            else
            {
                errorDiv.innerHTML = "";
            }
        }
    }
}

function registerValidateEmails(errorText)
{
    objP1 = document.getElementById("email");
    objP2 = document.getElementById("email2");
    errorDiv = document.getElementById("registerForm_element_email");
    
    if(objP1 && objP2)
    {
        if(objP1.value != "" && objP2.value != "")
        {
            if(objP1.value != objP2.value)
            {
                errorDiv.innerHTML = errorText;
            }
            else
            {
                errorDiv.innerHTML = "";
            }
        }
    }
}

function changeFeedbackSubject(subject_id)
{
    if(subject_id == 1)
    {
        show_element('formFeedback_tr_phone');
        show_element('formFeedback_tr_sms');
    }
    else
    {
        hide_element('formFeedback_tr_phone');
        hide_element('formFeedback_tr_sms');
    }   
}

function limitTextAreaChars(obj, maxChars)
{
    if(obj != null && obj.value != null)
    {
        var enteredValue = obj.value;
        if(enteredValue.length > maxChars)
        {
            obj.value = enteredValue.substring(0, maxChars);
            alert('Max teksta garums: ' + maxChars + ' simboli');
        }
    }
}
