var tabs = ["oscar","oscar_conf","division","promobile","indep"];

$(document).ready(function(){

  $.each(tabs, function(index, value){
    
    $("#"+value+"_tab").click(function(){
      hideServicesTabs();
      $("#"+value).show();
      return false;
    });

  });

  pimg();
  


});

function hideServicesTabs(){

  $.each(tabs, function(index, value){
    $("#"+value).hide();
  });

}

$(document).ready(function(){

$(".zoom").hover(function() {
  $(this).css({'z-index' : '1000'}); /*Add a higher z-index value so this image stays on top*/ 
  $(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
    .animate({
      marginTop: '-110px', /* The next 4 lines will vertically align this image */ 
      marginLeft: '-110px',
      top: '50%',
      left: '50%',
      width: '600px', /* Set new width */
      height: '380px' /* Set new height */
      
    }, 200); /* this value of "200" is the speed of how fast/slow this hover animates */

  } , function() {
  $(this).css({'z-index' : '100'}); /* Set z-index back to 0 */
  $(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
    .animate({
      marginTop: '0', /* Set alignment back to default */
      marginLeft: '0',
      top: '0',
      left: '0',
      width: '300px', /* Set width back to default */
      height: '190px' /* Set height back to default */
      
    }, 400);
});

/* Contact Us Form Validation */

$("#email").keyup(function(){
  if(valid_email($(this).val())){
    $("span.wrong_email").css("display", "none");
    $("span.ok_email").css("display", "inline");
  }else {
    $("span.wrong_email").css("display", "inline");
    $("span.ok_email").css("display", "none");
  }
});

$("#company").keyup(function(){
  if(!empty($(this).val())){
    $("span.wrong_com").css("display", "none");
    $("span.ok_com").css("display", "inline");
  }else {
    $("span.wrong_com").css("display", "inline");
    $("span.ok_com").css("display", "none");
  }
});

$("#name").keyup(function(){
  if(!empty($(this).val())){
    $("span.wrong_name").css("display", "none");
    $("span.ok_name").css("display", "inline");
  }else {
    $("span.wrong_name").css("display", "inline");
    $("span.ok_name").css("display", "none");
  }
});

$("#phone").keyup(function(){
  if(!empty($(this).val())){
    $("span.wrong_phone").css("display", "none");
    $("span.ok_phone").css("display", "inline");
  }else {
    $("span.wrong_phone").css("display", "inline");
    $("span.ok_phone").css("display", "none");
  }
});

$("#text").keyup(function(){
  if(!empty($(this).val())){
    $("span.wrong_text").css("display", "none");
    $("span.ok_text").css("display", "inline");
  }else {
    $("span.wrong_text").css("display", "inline");
    $("span.ok_text").css("display", "none");
  }
});

$(".contact_submit").live("click", function(){

  var inputs = ["email", "company", "name", "phone", "text"];
  var err = 0;

  $.each(inputs, function(index, value){
    
    if(!empty($("#"+value).val())){
      if(value == "email" && !valid_email($("#"+value).val())){       
        err = 1;
      }
    }else {      
      err = 1;
    }    

  });

  if(err != 1) {
    $("form.contactform").submit();
    return true;
  }
  else {
    alert("Please, fill in all required fields!");
    return false;
  }
});

});

function valid_email(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

   if(reg.test(email) == false) {      
      return false;
   }

   return true;
}

function empty(mixed_var) {
    var key;
     if (mixed_var === "" || mixed_var === 0 || mixed_var === "0" || mixed_var === null || mixed_var === false || typeof mixed_var === 'undefined') {
        return true;
    }
 
    if (typeof mixed_var == 'object') {        for (key in mixed_var) {
            return false;
        }
        return true;
    } 
    return false;
}

$(document).ready(function(){
    $("#oscar_tab").attr("class","activ_li");
  $(".services_sub_center_hover").bind("click", function(){
 $(".servtab li").children("a").removeClass("activ_li");
    $(this).closest("a").attr("class","activ_li");
  });


/* Menu efects */
$("#menu ul li").hover(function(){
  $(this).find("ul.submenu").show();
},
function(){
 $(this).find("ul.submenu").hide();
});


/* Submenu stairs efect*/

  $(".submenu").each(function(){
    var margin = 0;
    var step = 15;
    $(this).children("li").each(function(){
      $(this).css("margin-left", margin+"px");
      margin = margin + step;    
    });
  });
});

