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', '#ffedd4');
	change_bg('profileGroups2', '#ffedd4');
	change_bg('profileGroups4', '#ffedd4');
	change_bg('profileGroups5', '#ffedd4');
	change_bg('profileGroups6', '#ffedd4');
	change_bg('profileGroups7', '#ffedd4');
	change_bg('profileGroups8', '#ffedd4');
	
	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', '#ffedd4');
	change_bg('profileDetailsGroups2', '#ffedd4');
	change_bg('profileDetailsGroups4', '#ffedd4');
	change_bg('profileDetailsGroups5', '#ffedd4');
	change_bg('profileDetailsGroups6', '#ffedd4');
	change_bg('profileDetailsGroups7', '#ffedd4');
	
	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', '#ffedd4');
	change_bg('rbarVideoMenu2', '#ffedd4');
	
	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;
	}
}

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');
        }
    }
}
