//CONFIRM FUNCTION

function confirm_proc(url, msg)
{
	if (confirm(msg)) {
		self.location.href = url;
	}
}

function buy_confirm(url, msg)
{
	if (confirm(msg)) {
		window.opener.location.href = url;
		self.close();
	}
}

//POPUP

function pop(link, w, h, r, s)
{
   adres=link;
     x = ( window.screen.width - w ) / 2;
     y = ( window.screen.height - h) / 2;
    l= x;
    t= y;
  window.open(adres, "msg", "toolbar=no, location=no, left="+l+", top="+t+", directories=no, status=no, menubar=no, scrollbars="+s+", resizable="+r+", width="+w+", height="+h);
}

//GUILD WHOIS CLOSE SELF

function gw_cs(url){
	window.opener.location.href = url;
	self.close();
}

//REDIRECT

function redirect(url)
{
	window.location.replace("+url+");
}

//FAQ SCRIPTS

function FaqSHAll(proc)
{
	var divs = document.getElementsByTagName("div");
	for(var i=0; i<divs.length; i++)
	{
		var divId = divs[i].id;

		if(divId.indexOf("sh_") != -1){
			if(proc == "show"){
				eval("document.getElementById('" + divId + "').style.display = 'block'");
			}
			if(proc == "hide"){
				eval("document.getElementById('" + divId + "').style.display = 'none'");
			}
		}
	}

	var imgs = document.getElementsByTagName("img");
	for (var i=0; i<imgs.length; i++)
	{
		var imgId = imgs[i].id;

		if (imgId.indexOf("sh_pic_") != -1) {
			if(proc == "show"){
				eval("document.getElementById('" + imgId + "').src = 'http://mu.lifegames.lv/style/pluis/style/minus.gif'");
			}
			if(proc == "hide"){
				eval("document.getElementById('" + imgId + "').src = 'http://mu.lifegames.lv/style/pluis/style/plus.gif'");
			}
		}
	}
}

function show_hide(id)
{
	var pText = document.getElementById('sh_' + id);
	var pPic = document.getElementById('sh_pic_' + id);

	if (pText.style.display == 'none') {
		eval("pText.style.display = 'block'");
		eval("pPic.src = 'http://mu.lifegames.lv/style/pluis/minus.gif'");
	}
	else {
		eval("pText.style.display = 'none'");
		eval("pPic.src = 'http://mu.lifegames.lv/style/pluis/plus.gif'");
	}
}

//BBCODE ADD TO FORM

function InsertCode(codes, codee) {
  document.pform.p_text.focus();
  
  if (document.selection) {
    // ie & may be opera 8
    var rng = document.selection.createRange();
    if (rng.text) {   
      document.selection.createRange().text = codes + rng.text + codee;
    } else {  
      document.pform.p_text.value += codes  + codee;
    }
    document.pform.p_text.focus();
  } else if (document.pform.p_text.selectionStart ||
document.pform.p_text.selectionStart == '0') {
    // mozilla: intellegent bcodes support
    var selStart = document.pform.p_text.selectionStart;
    var selEnd = document.pform.p_text.selectionEnd;

    var s = document.pform.p_text.value;
    s = s.substring(0, selStart) + codes + s.substring(selStart, selEnd)
+ codee + s.substring(selEnd, s.length);
    document.pform.p_text.value = s;

    if (selEnd != selStart) {
      document.pform.p_text.selectionStart = selStart;
      document.pform.p_text.selectionEnd = selEnd + codes.length +
codee.length;
    } else {
      document.pform.p_text.selectionStart = selStart + codes.length;
      document.pform.p_text.selectionEnd =
document.pform.p_text.selectionStart;
    }
  } else {
    // other browsers
    document.pform.p_text.value += codes + codee;
  }
}