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;
    }

function CheckEMailS(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;
    }


    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(mandatory_fields[i] == 'mail') {
           if(CheckEMail($("#"+mandatory_fields[i]).val()) == true) {
            $("#check_"+mandatory_fields[i]).removeClass('font_red_color');
          } else {
            _error = 1;
            $("#check_"+mandatory_fields[i]).addClass('font_red_color');
          }
        }

      }
      if(_error == 1)
        return false;
      else
        return true;
    }

    function CustomCheckForm(c_form, c_mandatory_fields) {
      var return_str = "";
      var error = 0;
      for(i=0;i<c_mandatory_fields.length;i++) {
        if($("#"+c_mandatory_fields[i]).val() == "") {

          error = 1;
          $("#"+c_mandatory_fields[i]).addClass('font_red_color');
          return_str = return_str+ c_mandatory_fields[i]+"\n";
        } else {
          $("#"+c_mandatory_fields[i]).removeClass('font_red_color');
        }



        if(c_mandatory_fields[i] == 'email') {
          if(CheckEMail($("#email").val()) == false) {

            error = 1;
            $("#"+c_mandatory_fields[i]).addClass('font_red_color');
          } else {
            $("#"+c_mandatory_fields[i]).removeClass('font_red_color');
          }
        }

      }

      if(error == 1) {
        alert ("Fill in required fields!\n");
    RefillAll();
        return false;
      }
      else{

//         $('#loading').show();
        if(window['tbx_check'] == 1){
          return true;
        }
        else{
        tb_show2("","http://rpgraphics.com/rp_cms/spage-loading.html","");
        
        chech_tbx_timer=setTimeout("chech_tbx('"+c_form+"')",10)
          return false;
        }
      }
    }

    function chech_tbx(form_name){
      if(window['tbx_check'] == 1){
        document.tbx_form.submit();
      }
      else
        hech_tbx_timer=setTimeout("chech_tbx('"+form_name+"')",10)
    }

    function CustomCheckForm2(c_form, c_mandatory_fields, form_name) {
      var return_str = "";
      var error = 0;
      for(i=0;i<c_mandatory_fields.length;i++) {
      if(document.getElementById(c_mandatory_fields[i]).type=='checkbox'){
        if(form_name.terms.checked != true){
          error = 1;
        }
      }else{
        if($("#"+c_mandatory_fields[i]).val() == "") {
//           
          error = 1;
          return_str = return_str+ c_mandatory_fields[i]+"\n";
        }
      }



        if(c_mandatory_fields[i] == 'email') {
          if(CheckEMail($("#"+c_mandatory_fields[i]).val()) == false) {
          alert("email");
            error = 1;
          }
        }

      }

      if(error == 1) {
        alert ("Fill in required fields!\n");
        return false;
      }
      else
        return true;
    }

    function CustomCheckForm3(c_form, c_mandatory_fields, form_name) {
      var return_str = "";
      var error = 0;
      for(i=0;i<c_mandatory_fields.length;i++) {
      if(document.getElementById(c_mandatory_fields[i]).type=='checkbox'){
        if(!$('#terms').attr('checked')){
          error = 1;
        }
      }

      }

      if(error == 1) {
        alert ("Fill in required fields!\n");
        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();


  	}
	});
}

var codiv = '';
var copimg = '';

function switch_divs(div_to_hide, div_to_show) {
  if(div_to_hide != ''){
// 	  $('#'+div_to_hide).BlindUp(500);
$("#"+div_to_hide).slideToggle('slow');

  }
//   $('#'+div_to_show).BlindDown(500, null, 'easeout');
$("#"+div_to_show).slideToggle('slow');

  codiv = div_to_show;
}

function switch_imgs(div_to_hide, div_to_show) {
  if(div_to_hide != ''){
//    $('#'+div_to_hide).BlindUp(500);
    document.getElementById(div_to_hide).style.display = 'none';
  }
//   $('#'+div_to_show).BlindDown(500, null, 'easeout');
  document.getElementById(div_to_show).style.display = 'block';
  copimg = div_to_show;
}

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);
  	}
});
}

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Mr J | http://www.huntingground.net/ */

scrollStep=3

timerLeft=""
timerRight=""
timerTop=""
timerBottom=""


function toLeft(id){
  document.getElementById(id).scrollLeft=0
}

function scrollDivLeft(id){
  clearTimeout(timerRight) 
  document.getElementById(id).scrollLeft+=scrollStep
  timerRight=setTimeout("scrollDivLeft('"+id+"')",10)
}

function scrollDivRight(id){
  clearTimeout(timerLeft)
  document.getElementById(id).scrollLeft-=scrollStep
  timerLeft=setTimeout("scrollDivRight('"+id+"')",10)
}

function toRight(id){
  document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth
}

function scrollDivBottom(id){
  clearTimeout(timerTop) 
  document.getElementById(id).scrollTop+=scrollStep
  timerRight=setTimeout("scrollDivBottom('"+id+"')",10)
}

function scrollDivTop(id){
  clearTimeout(timerTop) 
  document.getElementById(id).scrollTop-=scrollStep
  timerRight=setTimeout("scrollDivTop('"+id+"')",10)
}

function toTop(id){
  document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight
}
function toBottom(id){
  document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight
}

function stopMe(){
  clearTimeout(timerRight) 
  clearTimeout(timerLeft)
  clearTimeout(timerBottom) 
  clearTimeout(timerTop)
}
// PRODUCT_DIVS
function ShowDiv(id){
  document.getElementById(id).style.display = 'block';
}
function HidesDiv(id){
  document.getElementById(id).style.display = 'none';
}

  var keywords =  "Search";
  var semail =  "Enter your emaill";

function make_blank(name1){
  if(document.getElementById(name1).value != window[name1]) { }
  else { document.getElementById(name1).value =""; }
}
function refill(name1){
  if(document.getElementById(name1).value != "") { }
  else { document.getElementById(name1).value = window[name1]; }
}

    function CheckFormInput(ref) {
      var _error = 0;
      var _message = "Please fill in:\n";
      var _add = "";
      var _class = "";
      if(ref == 1){
        _add = "#";
        _class = "font_red_color";
      }
      else{
        if(ref == 2){
          _add = "#check_";
          _class = "font_red_color";
        }
        else{
          _add = "#check_";
          _class = "font_red_color";
        }
      }
      for(i=0;i<mandatory_fields.length;i++) {
        if($("#"+mandatory_fields[i]).val() == ""
           && mandatory_fields[i] != 'email'
           && mandatory_fields[i] != 'smail'
           && mandatory_fields[i] != 'd_phone_a'
           && mandatory_fields[i] != 'd_phone'
           && mandatory_fields[i] != 'e_phone_a'
           && mandatory_fields[i] != 'e_phone'
           && mandatory_fields[i] != 'mail' ) {
          _error = 1
          if(mandatory_fields[i] == 'file')
            $("#check_"+mandatory_fields[i]).addClass('font_red_color_file');
          else
            $(_add+mandatory_fields[i]).addClass(_class);

            _message += ' - '+window[mandatory_fields[i]]+'\n';


        } else {
          if(mandatory_fields[i] == 'file')
            $("#check_"+mandatory_fields[i]).removeClass('font_red_color_file');
          else
            $(_add+mandatory_fields[i]).removeClass(_class);
        }

        if(mandatory_fields[i] == 'email' || mandatory_fields[i] == 'smail' || mandatory_fields[i] == 'mail') {

          if(CheckEMail($("#"+"email").val()) == false) {
            _error = 1;

            _message += ' - '+window[mandatory_fields[i]]+'\n';

            $(_add+mandatory_fields[i]).addClass(_class);
          } else {
            $(_add+mandatory_fields[i]).removeClass(_class);
          }
        }

      }

 
      if(_error == 1) {
            alert(_message+"field(s)!");
        if(ref == 1)
          RefillAll();

        return false;
      } else
        return true;

    }

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
 
    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
          chngOpc1=setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
          timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            chngOpc2=setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }

    }
}
 
//change the opacity for different browsers
function changeOpac(opacity, id) {
    if(opacity ==1){
      if(document.getElementById(id).style.display == 'block')
        document.getElementById(id).style.display = 'none';
      else
        document.getElementById(id).style.display = 'block';
    }
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}