function CheckEMail(str_email) {
        t = str_email.indexOf("@");
        if ((str_email.indexOf(".") == -1) || (t == -1) || (t < 1) || (t > str_email.length - 5) || (str_email.charAt(t - 1) == '.') || (str_email.charAt(t + 1) == '.'))  {
        return false;
        }
        return true;
    }



//Form Functions
    function CheckForm() {
      var error = 0;
    	for(i=0;i<mandatory_fields.length;i++) {
        if($("#"+mandatory_fields[i]).val() == "") {
          error = 1
          $("#check_"+mandatory_fields[i]).addClass('font_red_color');
        } else {
          $("#check_"+mandatory_fields[i]).removeClass('font_red_color');
        }
      }
      if(error == 1)
        return false;
      else
        return true;
    }

    function CustomCheckForm(c_form, c_mandatory_fields) {
      var error = 0;
    	for(i=0;i<c_mandatory_fields.length;i++) {
        if($("#"+c_form+"_"+c_mandatory_fields[i]).val() == "") {
          error = 1;

          $("#check_"+c_form+"_"+c_mandatory_fields[i]).addClass('font_red_color');
        } else {
          $("#check_"+c_form+"_"+c_mandatory_fields[i]).removeClass('font_red_color');
        }

        if(c_mandatory_fields[i] == 'email') {
          if(CheckEMail($("#"+c_form+"_email").val()) == false) {
            error = 1;
            window.alert("Невірний Е-mail!");
            $("#check_"+c_form+"_"+c_mandatory_fields[i]).addClass('font_red_color');
          }
        }
      }
      if(error == 1)
        return false;
      else
        return true;
    }

//solutiob ajax content
function GET_SOL_DATA(get_vals) {
	$('#content').DropOutRight(500);
	GetContent(get_vals);
	return false;
}

function Reinit_Thikbox() {
	tb_init('a.thickbox, area.thickbox, input.thickbox');
  	imgLoader = new Image();// preload image
  	imgLoader.src = tb_pathToImage;
}

function GetContent(get_vals) {
	$.ajax({
  		url: _base_url + "get_content.php"+get_vals,
  		cache: false,
  		success: function(html){
        $("#content").empty();
        $("#content").append(html);
        $("#breadcrumb").empty();
        $("#breadcrumb").append($("#breadcrumb_backup").html());
        $('#content').DropInRight(500, null, 'easeout');
		Reinit_Thikbox();
    $(function() {
        $('a[@rel*=gallery]').lightBox();
        $('a.gallery').lightBox();
    });

  	}
	});
}



function GetOptions(this_id, change_next, sections){
	$.ajax({
  		url: _base_url + "get_select.php?id="+$(this_id).val()+"&section="+sections,
  		cache: false,
  		success: function(html){
      $(change_next).empty();
		$(change_next).html(html);
  	}
});
}


// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose;
