function Slidedown_ShowHide(id,label) {
    slidedownContentCell = document.getElementById('sd_'+id);
    slidedownContent = document.getElementById('sdc_'+id);
    slidedownContentBox = document.getElementById('sdcb_'+id);
    if (slidedownContent.style.display == 'none') {
                  slidedownContent.style.display = 'block';
                  slidedownContentBox.style.visibility='visible';
                  slidedownContentCell.innerHTML = '[-] '+label;

        }
        else {
                  slidedownContent.style.display = 'none';
                  slidedownContentBox.style.visibility='hidden';
                  slidedownContentCell.innerHTML = '[+] '+label;
        }
}

function SlidedownButton_ShowHide(id,label) {
    slidedownContentCell = document.getElementById('sd_'+id);
    slidedownContent = document.getElementById('sdc_'+id);
    slidedownContentBox = document.getElementById('sdcb_'+id);
    if (slidedownContent.style.display == 'none') {
                  slidedownContent.style.display = 'block';
                  slidedownContentBox.style.visibility='visible';
                  slidedownContentCell.value = '[-] '+label;

        }
        else {
                  slidedownContent.style.display = 'none';
                  slidedownContentBox.style.visibility='hidden';
                  slidedownContentCell.value = '[+] '+label;
        }
}


 	function Button_HighlightingOn(Element)
	{
	    	Element.style.backgroundColor = '#0095A7';
		Element.style.borderTopColor = 'red';
		Element.style.borderBottomColor = 'red';
	}

	function Button_HighlightingOff(Element)
	{
		Element.style.backgroundColor = '#A9C6DB';
		Element.style.borderTopColor = '#025696';
		Element.style.borderBottomColor = '#025696';
	}

function CopyToClipboard(text)
{
 var Element = document.getElementById('ClipboardData');
 Element.value = text;
 try
 {
  Copied = Element.createTextRange();
  Copied.execCommand("Copy");
 } catch(e) {};
}

////////////////////////////////////////////////////////


function Rebuild_WpnClassesList()
{

	function AddWpnClassToList(WpnClassID)
	{
	var NewOption = document.createElement("option");
	NewOption.appendChild(document.createTextNode(WeaponClasses[WpnClassID]));
	NewOption.setAttribute("value", WpnClassID);
	NewOption.defaultSelected = false;
	NewOption.selected = false;
	SelectBox.appendChild(NewOption);
	return NewOption;
	}
  
  SelectBox = document.DmgForm.Select_WpnClass;
  ClearSelectBox(SelectBox);
  for (i in WeaponClasses)
  {
  	var NewOption = AddWpnClassToList(i);
  	if (i == 0) NewOption.selected = true;
  }
}

function Rebuild_AbilitiesList()
{

	function AddAbilityToList(AbilityID)
	{
	var NewOption = document.createElement("option");
	NewOption.appendChild(document.createTextNode(Abilities[AbilityID]['name']));
	NewOption.setAttribute("value", AbilityID);
	NewOption.defaultSelected = false;
	NewOption.selected = false;
	SelectBox.appendChild(NewOption);
	return NewOption;
	}
	SelectBox = document.DmgForm.SelectedWeapon_Ability;
  ClearSelectBox(SelectBox);
  for (i in Abilities)
  {
  	var NewOption = AddAbilityToList(i);
  	if (i == 0) NewOption.selected = true;
  }
}

function Rebuild_WpnList()
{
	function AddWpnToList(WpnID)
	{
	var NewOption = document.createElement("option");
	var TextData = '['+Weapon['rlvl']+'] '+Weapon['name'];
	NewOption.appendChild(document.createTextNode(TextData));
	NewOption.setAttribute("value", Weapon['id']);
	NewOption.defaultSelected = false;
	NewOption.selected = false;
	return NewOption;
	}
	
	GroupBoxes = [];
	GroupBoxes[0] = document.createElement('optgroup');
	GroupBoxes[0].label = "Обычное оружие";
	GroupBoxes[0].style.color = 'red';
	GroupBoxes[0].style.backgroundColor = 'yellow';
	
	GroupBoxes[1] = document.createElement('optgroup');
	GroupBoxes[1].label = "Реликты/Оружие Леона";
	GroupBoxes[1].style.color = "green";
	
	SelectBox = document.DmgForm.Select_Wpn;
	ClearSelectBox(SelectBox);

	TargetWeaponClassID = document.DmgForm.Select_WpnClass.options[document.DmgForm.Select_WpnClass.selectedIndex].value;
	for (i in Weapons)
	  {
		Weapon = Weapons[i];
		if ((Weapon['name'].length > 0)&&(Weapon['classid'] == TargetWeaponClassID))
		{
			var NewOption = AddWpnToList(Weapon);
			SelectBox.appendChild(NewOption);
			if (i == 0) NewOption.selected = true;

		}
	  }
	for (i in GroupBoxes)
	{
		//SelectBox.appendChild(GroupBoxes[i]);  
	}  
	var Buffs_CRF_Style = document.getElementById('Buffs_CRF').style;
	var Buffs_LRF_Style = document.getElementById('Buffs_LRF').style;
	var Buffs_LRF_SA_Style = document.getElementById('Buffs_LRF_SA').style;
	var Buffs_LRF_B_Style = document.getElementById('Buffs_LRF_B').style;
	var Buffs_FF_Style =document.getElementById('Buffs_FF').style;
	var Buffs_SM_Style = document.getElementById('Buffs_SM').style;
	var Buffs_CB_CRF_Style = document.getElementById('Buffs_CB_CRF').style;
	var Buffs_CB_LRF_Style = document.getElementById('Buffs_CB_LRF').style;
	var Buffs_CB_LRF_SA_Style = document.getElementById('Buffs_CB_LRF_SA').style;
	var Buffs_CB_LRF_B_Style = document.getElementById('Buffs_CB_LRF_B').style;
	var Buffs_CB_FF_Style =document.getElementById('Buffs_CB_FF').style;
	var Buffs_CB_SM_Style = document.getElementById('Buffs_CB_SM').style;

		Buffs_CRF_Style.display = 'none';
		Buffs_LRF_Style.display = 'none';
		Buffs_LRF_SA_Style.display = 'none';
		Buffs_LRF_B_Style.display = 'none';
		Buffs_FF_Style.display = 'none';
		Buffs_SM_Style.display = 'none';

		Buffs_CB_CRF_Style.visibility = 'hidden';
		Buffs_CB_LRF_Style.visibility = 'hidden';
		Buffs_CB_LRF_SA_Style.visibility = 'hidden';
		Buffs_CB_LRF_B_Style.visibility = 'hidden';
		Buffs_CB_FF_Style.visibility = 'hidden';
		Buffs_CB_SM_Style.visibility = 'hidden';

	if((TargetWeaponClassID==0)||(TargetWeaponClassID==1)||(TargetWeaponClassID==2)||(TargetWeaponClassID==3)||(TargetWeaponClassID==5))//оружия ближнего боя
	{
		Buffs_CRF_Style.display = 'block';
		Buffs_CB_CRF_Style.visibility = 'visible';
	}
	if((TargetWeaponClassID==6)||(TargetWeaponClassID==7)||(TargetWeaponClassID==8)||(TargetWeaponClassID==9))//оружия дальнего боя
	{
		Buffs_LRF_Style.display = 'block';
		Buffs_CB_LRF_Style.visibility = 'visible';
		if((TargetWeaponClassID==6))//луки
		{
		 Buffs_LRF_B_Style.display = 'block';
		 Buffs_CB_LRF_B_Style.visibility = 'visible';
		}
		if((TargetWeaponClassID==7))//луки
		{
		 Buffs_LRF_SA_Style.display = 'block';
		 Buffs_CB_LRF_SA_Style.visibility = 'visible';
		}
		if((TargetWeaponClassID==9))//пу
		{
		 Buffs_LRF_Style.display = 'none';
		 Buffs_CB_LRF_Style.visibility = 'hidden';
		 Buffs_SM_Style.display = 'block';
		 Buffs_CB_SM_Style.visibility = 'visible';
		}
	}


	if((TargetWeaponClassID==4))//жезлы
	{
		Buffs_FF_Style.display = 'block';

		Buffs_CB_FF_Style.visibility = 'visible';
	}


	var Modifications_Style =document.getElementById('SelectedWeapon_Modifications').style;
	var Modifications_CB_Style = document.getElementById('SelectedWeapon_Modifications_CB').style
	if((TargetWeaponClassID==8))
	{
		Modifications_Style.display = 'none';
		Modifications_CB_Style.visibility = 'hidden';
	}
	else
	{
		Modifications_Style.display = 'block';
		Modifications_CB_Style.visibility = 'visible';
	}

	var Talics_Style =document.getElementById('SelectedWeapon_Talics').style;
	var Talics_CB_Style = document.getElementById('SelectedWeapon_Talics_CB').style
	if((TargetWeaponClassID==8))
	{
		Talics_Style.display = 'none';
		Talics_CB_Style.visibility = 'hidden';
	}
	else
	{
		Talics_Style.display = 'block';
		Talics_CB_Style.visibility = 'visible';
	}


	Recalculate_Dmg(true);
}
function Rebuild_TalicsList()
{

	function AddTalicToList(TalicID)
	{
	var NewOption = document.createElement("option");
	NewOption.appendChild(document.createTextNode(Talics[TalicID]));
	NewOption.setAttribute("value", TalicID);
	NewOption.defaultSelected = false;
	NewOption.selected = false;
	SelectBox.appendChild(NewOption);
	return NewOption;
	}

	for(j=1;j<=7;j++)
	{
		SelectBox = document.getElementsByName('SelectedWeapon_Talic'+(j))[0];
	  ClearSelectBox(SelectBox);
	  for (i in Talics)
	  {
	  	var NewOption = AddTalicToList(i);
	  	if (i == 0) NewOption.selected = true;
	  }
	}
}


function Reinsert_Talics()
{
		Weapon = Weapons[document.DmgForm.Select_Wpn.options[document.DmgForm.Select_Wpn.selectedIndex].value];
		Weapon['talics'] = [0,0,0,0,0,0,0];
		var DmgForm = document.DmgForm;
		var temp = 0;
		for(i=0;i<7;i++)
		{
		temp = i + 1;
		SelectBox = document.getElementsByName('SelectedWeapon_Talic'+temp)[0];
		Weapon['talics'][i] =   SelectBox.options[SelectBox.selectedIndex].value;
		}
		Recalculate_Dmg();
}

function AutoInsert_Talics(IgnoranceTalicsNumber)
{
		Weapon = Weapons[document.DmgForm.Select_Wpn.options[document.DmgForm.Select_Wpn.selectedIndex].value];
		Weapon['talics'] = [0,0,0,0,0,0,0];
		var DmgForm = document.DmgForm;
		var temp = 0;
		for(i=0;i<IgnoranceTalicsNumber;i++)
			{Weapon['talics'][i] = 1;}
		
		var TalicsCount = 0;
		for(i=0;i<7;i++)
			{ TalicsCount += (Weapon['talics'][i] == 1)?1:0; }
		document.DmgForm.SelectedWeapon_IgnoranceTalicsCount.selectedIndex = TalicsCount;
		Recalculate_Dmg();
}

function Reselect_Ability()
{
		Weapon = Weapons[document.DmgForm.Select_Wpn.options[document.DmgForm.Select_Wpn.selectedIndex].value];
		Ability = Abilities[document.DmgForm.SelectedWeapon_Ability.options[document.DmgForm.SelectedWeapon_Ability.selectedIndex].value];
    		Weapon['abilityid'] = Ability['id'];
		Recalculate_Dmg();
}
function Reselect_Intensivity()
{
		Weapon = Weapons[document.DmgForm.Select_Wpn.options[document.DmgForm.Select_Wpn.selectedIndex].value];
		WeaponIsIntense = document.DmgForm.SelectedWeapon_Intense.checked;
    		Weapon['isintense'] = WeaponIsIntense;
		Recalculate_Dmg();
}

function SelectWeaponByID(WpnID)
{
for(i=0;i<document.DmgForm.Select_Wpn.length;i++)
{
 WpnOption = document.DmgForm.Select_Wpn.options[i];
 if (WpnOption.value == WpnID)
 {
  document.DmgForm.Select_Wpn.selectedIndex = WpnOption.index;
  break;
 }
}
}





