$(function(){




window_width=0;

$(window).on('resize', function(){
	window_width=$(document).width();
		
});



// القفل باسكيب
$(document).keypress(function(e) { 

    if (e.which == 27) {
	$("#big-div-cont").css("display","none");
	$("#over").css("display","none");
	$("#menu").removeAttr("style");
	$(".right_header").css("display","none");
		}

});


// فى حالة وجود قوائم سلايد

menu_opened=0;
$(".btn_wide").click(function(){	 


		$("#bar").slideUp(1000);
		//alert($(".menu_wide[alt="+$(this).attr("lang")+"]").css("display"));
		if( $(".menu_wide[alt="+$(this).attr("lang")+"]").css("display")!="inline-block"){
		
		if(menu_opened!=0){
			
			$("#bar").slideUp(1000);
			$(".menu_wide").delay(700).hide(0);
			$("#menu_wide"+$(this).attr("lang")).delay(1).show(0);
		}else{
			
			$("#menu_wide"+$(this).attr("lang")).show(0);
		}
		
		
	
	
	
		

		$("#bar").slideDown(1000);
		$(".btn_wide img").attr("src","../img/arrow.png");
		$("#button"+$(this).attr("lang")+" img").attr("src","../img/arrow_bottom.png");
		
		
		menu_opened=1;
		}else{
		$(".menu_wide").slideUp(1000);
		$("#button"+$(this).attr("lang")+" img").attr("src","../img/arrow.png");
		menu_opened=0;
		}
		
					 
});





$("ul>li>ul").hover(function(){

$(this).prev("a").addClass("button_hover");	
},function(){		
$(this).prev("a").removeClass("button_hover");	
});


$('body').on('mousewheel', function(e){



$('.num_animate').on('inview', function (event, visible) {
      if (visible == true) {
        
        if($(this).attr("viewed")=="0"){
        
       	 	$(".num_animate").text("0");
			$(".num_animate").animateNumbers(0, false, 500);
       		$(this).attr("viewed","1");
        
        }
          //alert($(this).attr("id"))
      } else {
      $(this).attr("viewed","0");
      }
    });
  			

 
  });
     




$(".move_to").click(function() {
    $('html, body').animate({
        scrollTop: $("#"+$(this).attr("elm")).offset().top
    }, 2000);
});


$(".footer_to_top").click(function(){
	
 $('html, body').animate({
        scrollTop: 0
    }, 3000);	
	
});
		
		
		
	
		
		
		
		
$(".more_img img ").live("click",function(){
$("#big-img").attr("src","");
$("#big-img").attr("src",$(this).attr("src"));
	
});


var menu_open=0;

$("ul li ul li").click(function(){

if($(this).attr("menu_open")=="0"){
	
$("ul li ul li ul").css("display","none");	
$("ul li ul li").attr("menu_open","0");
$(this).find("ul").css("display","block");	
$(this).attr("menu_open","1");

}else{
	
$(this).find("ul").css("display","none");	
$(this).attr("menu_open","0");

}
	
	
});


$( window ).resize(function() {
	

window_width=$(document).width();
window_height=$(window).height();
if(window_width<=900){
//alert(window_width);


	
menu_width=window_width-100;




}	
	
});


$(".resp_menu").click(function(){
	

//alert($("#menu").css("top"));
window_width=$(document).width();
window_height=$(window).height();
if(window_width<=900){
	if($("#menu").css("top")!="30px"){

if($(this).attr("opened")=="0"){
$(this).attr("opened","1");		
//menu_width=window_width-100;
menu_width=0;
$(this).css("position","fixed")
$("#menu").css({"display":"block","height":"102vh","width":(window_width-100)+"px","top":"-25px","padding-top":"20px","left":"-"+menu_width +"px","z-index":"1000000000000"});


if($("#over").css("display")==="block"){
	//alert("saa");
	
}else{
	("#over").css("display","block");
}


$("#menu_wide_cont").css("z-index","102");
}else{
$(this).attr("opened","0");	

}



}
}

});



$("#close_resp_menu").click(function(){
	$("#menu_wide_cont").css("z-index","101");
	$("#menu").css("left","-1400px");
	$("#menu").removeAttr("style");
	$("#over").css("display","none");

	
});

$(".resp_menu").hover(function(){
	
});





$("img").load(function(evt){
      $(this).fadeIn(1000);
});
	


/*
$(window).on('resize', function(){
	window_width=$(document).width();
	
	
	if(window_width<=900){
	
	
	$("#menu").removeAttr("style");	
	}else{
		
	if($('body').scrollTop()>=150 && $('body').scrollTop()<footer_show){
	$("#menu").css("top","0%");	
	$("ul.resp_menu").css({"top":"0px","position":"fixed","height":"50px"});
	}else{
	}else{
	$("#menu").removeAttr("style");	
	
	$("ul.resp_menu").css({"top":"0px","position":"absolute","height":"50px"});
	}
	
	
	
	}
	
});

*/


function responsive_view(){ 
window_height=$(document).height();
window_width=$(document).width();
footer_show=window_height-350;
footer_bottom=window_height-551;	


if($(window).scrollTop() + $(window).height() >= $(document).height()-50){

//$("#top_arrow").html($(window).scrollTop() + $(window).height()+"/"+$(document).height());
//alert(window_height);


$("#top_arrow").css("bottom","50px");
$("#wh-widget-send-button").css({"display":"none","z-index":"0 !important"});

}else{
	
	$("#top_arrow").css("bottom","0px");	
$("#wh-widget-send-button").css({"display":"block","z-index":"0 !important"});
	
}



//فى حالة الاسكرول اكبر من 150	

if($('body').scrollTop()>=280 && $('body').scrollTop()<footer_show){
	

//alert(window_width);

$("#beiond_menu").css({"position":"fixed","height":"64px","background":"var(--black)"})	;
$("#top_social_left").css("position","fixed");
$("#search_botton").css("position","fixed");
$(".lang").css("position","fixed");



$("div.btn").css({"padding":"5px 5px"});

$("ul.resp_menu").css({"top":"0px","position":"fixed","height":"64px","display":"block"});


$("#top_arrow").fadeIn();
$("#opacity").css({"opacity":"0.95","padding-bottom":"15px","border-bottom":"solid 3px #FF7500"});
$("#opacity2").css({"opacity":"0.95"});
$("#menu>li>a#logo>img").css({"width":"110px","margin-right":"0px","margin-left":"10px"});



if(window_width<=900){
$("#logo").css({"position":"fixed","margin-top":"-2px","padding":"6px 6px"});	
$("#logo img").attr("height","53");	
$("#logo img").attr("src","../img/companies/"+comp_id+"/logo1_ar.png?t=");
$(".home").removeAttr("style");



//slide_mobile

$("#slide-cont").css({
	"overflow": "hidden",
    "height": "600px",
    "position": "realtive",
    "margin-top":"-115px",
	"width":"100%"
});



$(".slide_image").css({
	"background-size": "cover",
	"background-position": "center",
    "height": "400px",
    "overflow": "hidden",
    "padding-top": "0%",
    "position": "absolute",
    "top": "140px",
	"min-height":"300px",
	"Width":"100%"
});





$("#search_botton").css({"top":"7px"});

$("html").css({"background":"#fff"});
$(".slide_comment_cont").css({"width":"100%","left":"14%","bottom":"100px"});


$(".website_name").css({"display":"none","width":"190px","color": "#D8B77B","font-size": "17px","left": "60px","margin-top": "-7px","position": "fixed"});
$(".website_name span").hide();

$("#header_curve").css({"display":"none"})


$(".resp_menu").css({"top":"0px","left":"0px","position": "fixed","top":"0px","display":"block","height":"50px","z-index":"1000"});


//$(".comment1").css("width","100%");
//$(".comment2").css("width","100%");


}else{
$("#logo").css({"position":"fixed","margin-top":"0px","padding":"5px 6px" ,"left" :"0px"});	

$(".website_name").css({'display':'block',"width":"240px","color": "#D8B77B","font-size": "26px","right": "50px","margin-top": "-12px","position": "fixed","line-height":"30px"});

$(".website_name span").hide();

$("#header_curve").css({"display":"none"});
$("a.btn").css({"padding":"5px 5px","font-size":"14px"});
$("div.btn").css({"padding":"5px 5px","font-size":"14px"});	
$("#logo img").attr("height","55");
$("#logo img").attr("src","../img/companies/"+comp_id+"/logo_small.png?t=");
$(".lang").css("display","none");
$(".home").css("display","none");
$("#menu").css({"margin-left":"40px","left":"19%"});
$(".resp_menu").css({"right":"0px"});
$("#search_botton").css({"top":"10px","right":"5px","position": "fixed"});	
$(".slide_comment_cont").removeAttr("style");

$("#slide-cont").removeAttr("style");

$(".slide_image").css({
	"background-size": "cover",
	"background-position": "10% 0%",
    "height": "100%",
	"min-height":"100%",
	"overflow":"hidden",	
	"padding-top": "0px",
    "top": "0px"
	
});


}





}else{
	
//فى حالة الاسكرول اقل من 150	

if(window_width<=900){
	$("#beiond_menu").css({"position":"absolute","height":"90px","background":"var(--black)"})	;
	
	$("#menu").css("top","0%");
	$("#top_social_left").css("position","fixed");
	$("#search_botton").css("position","absolute");	
	$(".lang").css("position","absolute");
	

	$("#logo img").attr("src","../img/companies/"+comp_id+"/logo1_ar.png?t=");
	$("#logo img").attr("height","70");
	$("#logo").css({"position":"","margin-top":"2px","padding":"6px 6px","left":"auto"});	

	$(".home").removeAttr("style");
	
	
	$(".website_name").css({"display":"none","width":"150px","color": "#D8B77B","font-size": "22px","left": "80px","margin-top": "-8px","position": "absolute"});

	$("#header_curve").css({"display":"none"})
	$(".website_name span").hide();
	$("#search_botton").css({"top":"27px"});
	$(".resp_menu").css({"top":"20px","position":"absolute"});
	$("#menu").css({"top":"-20px"});
	
//slide_mobile

$("#slide-cont").css({

    "overflow": "hidden",
    "height": "600px",
    "position": "realtive",
    "margin-top":"-115px",
	"width":"100%"

});

$(".slide_image").css({
	"background-size": "cover",
	"background-position": "center",
    "height": "400px",
    "overflow": "hidden",
    "padding-top": "0%",
    "position": "absolute",
    "top": "140px",
	"min-height":"300px",
	"Width":"100%"
});



$("html").css({"background":"#fff"});
$(".slide_comment_cont").css({"width":"100%","left":"4%","bottom":"100px","height":"190px"});


//$(".comment1").css("width","100%");
//$(".comment2").css("width","100%");


	
	
}else{
	$("#beiond_menu").css({"position":"absolute","height":"90px","background":"#222"})	;
	$(".website_name").removeAttr("style");
	$(".website_name").hide();
	

	$("#beiond_menu").css({"position":"absolute","height":"270px"})	;
	$("ul.resp_menu").css({"top":"270px","position":"absolute","height":"64px","display":"none"});
	$("#menu").css("top","0%");
	$("#top_social_left").css("position","fixed");

	$(".lang").css("position","absolute");
	
	$("#logo img").attr("src","../img/companies/"+comp_id+"/logo1_ar.png?t=");
	$("#logo img").attr("height","200");

	$(".slide_comment_cont").removeAttr("style");
	$("#slide-cont").removeAttr("style");
	$("#search_botton").css({"top":"10px","right":"5px","position": "absolute"});	
	
	

$(".slide_image").css({
	"background-size": "cover",
	"background-position": "10% 0%",
    "height": "100%",
	"min-height":"100%",
	"overflow":"hidden",
	"padding-top": "0px",
    "top": "0px"
	
});
	
	

	$("a.btn").css({"padding":"0px 8px","font-size":"20px"});
	$("div.btn").css({"padding":"0px 8px","font-size":"20px"});


	
	$("#logo").css({"position":"","padding":"45px 0px" ,"height": "50px", "width": "300px" ,"left":"auto"});
	
	$(".lang").removeAttr("style");
	$(".home").removeAttr("style");
	$("#menu").css({"margin-left":"0px","left":"19%"});
	$("#header_curve").css({"display":"block"});
}	
	
	
	
	
	
$("#top_arrow").fadeOut();
$("#opacity2").css({"opacity":"0.3"});
$("#opacity").css({"opacity":"0.6","padding-bottom":"0px"});

}	
	
}

	








//alert(window_height);
$(window).scroll(function(){ responsive_view(); });	
$(window).on('resize', function(){ responsive_view(); });
$(window).on('load', function(){ responsive_view(); });



	
$("#top_arrow").click(function(){
$('body').animate({ scrollTop: 0 }, 'slow');	
$("#top_arrow").fadeOut(1000);
});


















$("#search_botton").click(function(){
$("#over").show();
$(".right_header").show();
});

$("#close_btn").click(function(){
$("#over").hide();
$(".right_header").hide();
});


$(".top_cat").mouseenter(function(){
$(this).next('.cat_cont').animate({"top":"-150px"},300);

});

$(".top_cat").mouseout(function(){
$(this).next('.cat_cont').animate({"top":"0px"},300);
});



$(".info").mouseout(function(){
$("#info_box").fadeOut();	
});

$info_title="";
$(".info").on("mouseenter", function() {
	
var offset=$(this).offset();
if(offset.left>800){
if(offset.left>960){
$("#info_box img").css("left","70px");		
}else{
$("#info_box img").css("left","50px");		
}
offset.left=882;
}else{
$("#info_box img").css("left","10px");		
};
$("#info_box").css({"top":offset.top+30,"left":offset.left-10});
$("#info_box").stop().hide(0);

$("#compare_box").stop().hide(0);
$("#info_box").fadeIn();
//$("#edit_box_info").html("تعديل " + $(this).attr("title"));
$("#info_box_info").html($(this).attr("title"));
$info_title=$(this).attr("title");
$(this).attr("title","");	
if ($(this).attr("class")=='add editable'){
//$("#edit_box_info").html("اضافة " + $(this).attr("title"));
$("#info_box_info").html($(this).attr("title"));	
}
}).on("mouseleave", function() {
$(this).attr("title",$info_title);	
});







$("#menu li ul").hover(function(){
	$(this).prevAll("div").css({"background":"#fff","color":"#D22320"});

});


$("#menu li ul").mouseleave(function(){
	$(this).prevAll("div").css({"background":"","color":""});
});






});
