function CheckEMail(str_email, ref) {
          
        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) == '.'))  {
        if(ref == 1)
         alert('Enter Valid Email Adress!');
        return false;
        }
        return true;
    }

//Main page effects
    $(function() {
        $('a[@rel*=gallery]').lightBox();
    });

    $(function() {
        $('a.gallery').lightBox();
    });

//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 ValidateNo(NumStr, String)
    {
        for(var Idx=0; Idx<NumStr.length; Idx++)
        {
            var Char = NumStr.charAt(Idx);
            var Match = false;
    
            for(var Idx1=0; Idx1<String.length; Idx1++)
            {
                if(Char == String.charAt (Idx1))
                    Match = true;
            }
    
            if (!Match)
                return false;
        }
        return true;
    }



    function CheckFormInput(ref) {
      var error = 0;
      var message = "Please fill in:\n";
      var message2 = "";
      var add = "";
      if(ref == 1)
        add = "#";
      else
        add = "#check_";
      for(i=0;i<mandatory_fields.length;i++) {
        if($("#"+mandatory_fields[i]).val() == "" && mandatory_fields[i] != 'email' && mandatory_fields[i] != 'smail' && mandatory_fields[i] != 'mail') {
          error = 1;
          $(add+mandatory_fields[i]).addClass('font_red_color');

            message += ' - '+window[mandatory_fields[i]]+'\n';


        } else {
          $(add+mandatory_fields[i]).removeClass('font_red_color');
        }

        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('font_red_color');
          } else {
            $(add+mandatory_fields[i]).removeClass('font_red_color');
          }
        }

        if(mandatory_fields[i] == 'phone' && $("#"+"phone").val() != '') {
          if(!ValidateNo($("#"+"phone").val(),"1234567890.-")) {
            error = 1;
            message += ' - '+window[mandatory_fields[i]]+'\n';


            $(add+mandatory_fields[i]).addClass('font_red_color');
          }
        }

        if (mandatory_fields[i] == 'agree') {
          if(document.getElementById('agree').checked == false) {
            error = 1;

            message += ' - '+window[mandatory_fields[i]]+'\n';


            $(add+mandatory_fields[i]).addClass('font_red_color');
          } else {
            $(add+mandatory_fields[i]).removeClass('font_red_color');
          }

        }
      }

      if (error != 1){
        message = '';
      }
      else {
        message += "field(s)!";
      }
        
      if(ref != 2){
        if($("#smail").val() != $("#email").val()){
  
          error = 1;
          message2 +=  "\nYour email adresses diferent!";
          $(add+"smail").addClass('font_red_color');
          $(add+"email").addClass('font_red_color');
        }
        else {
              $(add+"smail").removeClass('font_red_color');
              $(add+"email").removeClass('font_red_color');
        }
        if((($("#confirm_password").val() != "") || ($("#password").val() != "")) && (($("#password").val() != $("#confirm_password").val()) || ($("#password").val().length < 8) || ($("#password").val().length > 20) || ($("#confirm_password").val().length > 20) || ($("#confirm_password").val().length < 8))) {
          if($("#password").val() != $("#confirm_password").val()){
    
            error = 1;
            message2 +=  "\nYour passwords diferent!";
            $(add+"password").addClass('font_red_color');
            $(add+"confirm_password").addClass('font_red_color');
    
          }
          else {
            $(add+"password").removeClass('font_red_color');
            $(add+"confirm_password").removeClass('font_red_color');
          }
          if(($("#password").val().length < 8) || ($("#password").val().length > 20) || ($("#confirm_password").val().length > 20) || ($("#confirm_password").val().length < 8)){
    
            error = 1;
            message2 +=  "\nPasswords must be 8 - 20 characters!";
            $(add+"password").addClass('font_red_color');
            $(add+"confirm_password").addClass('font_red_color');
    
          }
          else {
            $(add+"password").removeClass('font_red_color');
            $(add+"confirm_password").removeClass('font_red_color');
          }
        }

      }

      if(error == 1) {
            alert(message+message2);
        if(ref == 1)
          RefillAll();

        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] == 'confirm_password') {

          if($("#"+c_form+"_confirm_password").val() != $("#"+c_form+"_password").val()) {
            error = 1;
            $("#check_"+c_form+"_"+c_mandatory_fields[i]).addClass('font_red_color');
          }
        }
        if(c_mandatory_fields[i] == 'email') {
          if(CheckEMail($("#"+c_form+"_email").val()) == false) {
            error = 1;
            $("#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 switch_divs(div_to_hide, div_to_show) {
	$('#'+div_to_hide).BlindUp(500);
  $('#'+div_to_hide).hide();
  $('#'+div_to_show).BlindDown(500, null, 'easeout');
  $('#'+div_to_show).show();
}

function GetOptions(this_id, change_next, sections){
  if(($(this_id).val() == 'USA' || $(this_id).val() ==  'Canada') && sections == 'city2'){
    document.getElementById('state_select_block').style.display = 'block'; 
  }
  else{
    document.getElementById('state_select_block').style.display = 'none'; 
  }
  

	$.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);
  	}
});
}
function resubmit_date(date_lable){

  $.ajax({
      url: _base_url + "get_select.php?section=resubmit_date",
      cache: false,
      success: function(html){
      $(date_lable).empty();
    $(date_lable).html(html);
    }
});

}

function MarkProfile(date_lable, id){

  $.ajax({
      url: _base_url + "get_select.php?section=mark&id="+id,
      cache: false,
      success: function(html){
      $(date_lable).empty();
    $(date_lable).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=""

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 stopMe(){
  clearTimeout(timerRight) 
  clearTimeout(timerLeft)
}
// 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 HideDivs(){

  if(window["occupation_check_status"] == 1){
    document.getElementById("occupation_check").style.visibility = "hidden";
    document.getElementById("occupation_check").style.display = "none";
  }
  if(window["occupation_check_status"] == 2){
    window["occupation_check_status"] = 1;
  }

  if(window["lang_check_status"] == 1){
    document.getElementById("lang_check").style.visibility = "hidden";
    document.getElementById("lang_check").style.display = "none";
  }
  if(window["lang_check_status"] == 2){
    window["lang_check_status"] = 1;
  }

  if(window["type_check_status"] == 1){
    document.getElementById("type_check").style.visibility = "hidden";
    document.getElementById("type_check").style.display = "none";
  }
  if(window["type_check_status"] == 2){
    window["type_check_status"] = 1;
  }

  if(window["job_responsibilities_check_status"] == 1){
    document.getElementById("job_responsibilities_check").style.visibility = "hidden";
    document.getElementById("job_responsibilities_check").style.display = "none";
  }
  if(window["job_responsibilities_check_status"] == 2){
    window["job_responsibilities_check_status"] = 1;
  }

  if(window["job_requirements_check_status"] == 1){
    document.getElementById("job_requirements_check").style.visibility = "hidden";
    document.getElementById("job_requirements_check").style.display = "none";
  }
  if(window["job_requirements_check_status"] == 2){
    window["job_requirements_check_status"] = 1;
  }

  if(window["salary_check_status"] == 1){
    document.getElementById("salary_check").style.visibility = "hidden";
    document.getElementById("salary_check").style.display = "none";
  }
  if(window["salary_check_status"] == 2){
    window["salary_check_status"] = 1;
  }

}

function Listbox(name1){

  if(name1 != 'type_check' && name1 != 'lang_check' && name1 != 'occupation_check' && name1 != 'job_responsibilities_check'){
   if(window["type_check_status"] == 1)
    window["type_check_status"] = 2;
   if(window["lang_check_status"] == 1)
    window["lang_check_status"] = 2;
   if(window["occupation_check_status"] == 1)
    window["occupation_check_status"] = 2;
   if(window["job_responsibilities_check_status"] == 1)
    window["job_responsibilities_check_status"] = 2;
   if(window["job_requirements_check_status"] == 1)
    window["job_requirements_check_status"] = 2;
   if(window["salary_check_status"] == 1)
    window["salary_check_status"] = 2;
  }

  if(document.getElementById(name1).style.visibility != "visible")
    { document.getElementById(name1).style.visibility = "visible";
      window[name1+"_status"] = 2; }
  else {document.getElementById(name1).style.visibility = "hidden";window[name1+"_status"] = 0; }

  if(document.getElementById(name1).style.display != "block")
    { document.getElementById(name1).style.display = "block"; }
  else {document.getElementById(name1).style.display = "none";}


}

function Select_item(what, item, clicked, desc, val, empty){
   if(window["type_check_status"] == 1)
    window["type_check_status"] = 2;
   if(window["lang_check_status"] == 1)
    window["lang_check_status"] = 2;
   if(window["occupation_check_status"] == 1)
    window["occupation_check_status"] = 2;
   if(window["job_responsibilities_check_status"] == 1)
    window["job_responsibilities_check_status"] = 2;
   if(window["job_requirements_check_status"] == 1)
    window["job_requirements_check_status"] = 2;
   if(window["salary_check_status"] == 1)
    window["salary_check_status"] = 2;
   if(clicked != 'none'){
    if(document.getElementById(clicked).checked == true){ window[val] = window[val] + 1;}
    else {window[val] = window[val] - 1;}
   }

    if(empty == 'All' &&  (window[val] + window["misc_ocupation_item_selected"]) == 0)
      document.getElementById(what).value = 'All';
    else {
      if(empty == '-' &&  (window[val] + window["misc_ocupation_item_selected"]) == 0)
        document.getElementById(what).value = '';
      else {
        if(desc == "" && (window[val] + window["misc_ocupation_item_selected"]) == 0)
          document.getElementById(what).value = "";
        else
        document.getElementById(what).value = (window[val] + window["misc_ocupation_item_selected"]) + ' '+desc+' selected';
      }
    }


}
