// JavaScript Document
$(document).ready(function() {
	//$(".CONTAINER1").css({"width":screen.width,"height":screen.height});
	//alert(screen.height);
	if (screen.width == '1024') {
		$(".M2RTCI").css("width","75px");
		$(".M2RTCI").css("height","75px");
		$(".M2RTCI img").css("width","75px");	
		$(".M2RTCI img").css("height","75px");
	}
    var url;	
    $(window).bind( 'hashchange', function(e) {
      url = $.param.fragment();
	
    });
   
    $(window).trigger( 'hashchange' );
	
	
	//// CHHECK IF URL SSET 
	if (url!='') {
		
		if (url == 'works') {
		
			var left = $(".WRAP2").css("left");
			$(".WRAP").animate({			
				"left":"-="+left
				},0
			);
			$(".WRAP1").animate({			
				"top":"-=3571px"
				},1000
			);
			$(".WRAP").animate({			
				"top":"-=3571px"
				},1000
			);
			$(".B").removeClass("SEL"); 
			$(".B2").addClass("SEL");
			
		} else if (url=='customers') {
			var left = $(".WRAP3").css("left");
			$(".WRAP").animate({			
				"left":"-="+left
				},0
			);
			$(".WRAP1").animate({			
				"top":"-=3571px"
				},1000
			);
			$(".WRAP").animate({			
				"top":"-=3571px"
				},1000
			);
			$(".B").removeClass("SEL"); 
			$(".B3").addClass("SEL");
				
		} else if (url=='about') {
			var left = $(".WRAP4").css("left");
			$(".WRAP").animate({			
				"left":"-="+left
				},0
			);
			$(".WRAP1").animate({			
				"top":"-=3571px"
				},1000
			);
			$(".WRAP").animate({			
				"top":"-=3571px"
				},1000
			);	
			$(".B").removeClass("SEL"); 
			$(".B4").addClass("SEL");
			
		} else if(url=='contact') {
			var left = $(".WRAP5").css("left");
			$(".WRAP").animate({			
				"left":"-="+left
				},0
			);
			$(".WRAP1").animate({			
				"top":"-=3571px"
				},1000
			);
			$(".WRAP").animate({			
				"top":"-=3571px"
				},1000
			);	
			
			$(".B").removeClass("SEL"); 
			$(".B5").addClass("SEL");
		}
		
		
		 
	}
	
	
	// HOME page //
	$(".CLICK1").live('click',function() {		
		
		$(".WRAP").animate({			
			"top":"+=3571px"
		    },1000
		);
		$(".WRAP1").animate({			
			"top":"+=3571px"
		    },1000
		);	
		
	});
	
	// Works Page //
	
	$(".M2RTA").live('click',function() {
		$(this).parent().parent().find(".M2RTC").hide(200);
		$(this).parent().parent().find(".M2RTCN").hide(200);
		$(this).siblings(".M2RTC").slideToggle();		
		$(this).siblings(".M2RTCN").slideToggle();	
	});
	
	$(".B2").live('click',function() { $(".B").removeClass("SEL"); $(".B2").addClass("SEL"); });
	$(".B2_1").live('click',function() {
		var left = $(".WRAP2").css("left");
	    $(".WRAP").animate({			
			"left":"-="+left
		    },0
		);
        $(".WRAP1").animate({			
			"top":"-=3571px"
		    },1000
		);
		$(".WRAP").animate({			
			"top":"-=3571px"
		    },1000
		);	
			
	});
	
	
	$(".B3").live('click',function() { $(".B").removeClass("SEL"); $(".B3").addClass("SEL"); });
	$(".B3_1").live('click',function() {
		var left = $(".WRAP3").css("left");
	    $(".WRAP").animate({			
			"left":"-="+left
		    },0
		);
		$(".WRAP").animate({			
			"top":"-=3571px"
		    },1000
		);
		$(".WRAP1").animate({			
			"top":"-=3571px"
		    },1000
		);

	});
	
	
	
	$(".B4").live('click',function() { $(".B").removeClass("SEL"); $(".B4").addClass("SEL"); });
	$(".B4_1").live('click',function() {
		var left = $(".WRAP4").css("left");
	    $(".WRAP").animate({			
			"left":"-="+left
		    },0
		);
		$(".WRAP").animate({			
			"top":"-=3571px"
		    },1000
		);
		$(".WRAP1").animate({			
			"top":"-=3571px"
		    },1000
		);	
	});
	
	
	$(".B5").live('click',function() { $(".B").removeClass("SEL"); $(".B5").addClass("SEL"); });
	$(".B5_1").live('click',function() {
		var left = $(".WRAP5").css("left");
	    $(".WRAP").animate({			
			"left":"-="+left
		    },0
		);
		
		$(".WRAP").animate({			
			"top":"-=3571px"
		    },1000
		);
		$(".WRAP1").animate({			
			"top":"-=3571px"
		    },1000
		);
	});
	
	
	$(".B2").live('click',function() { $(".B").removeClass("SEL"); $(".B2").addClass("SEL"); });
	$(".CLICK2").live('click',function() {
	   var left = $(".WRAP2").css("left");
	   $(".WRAP").animate({			
			"left":"-="+left+""
		    },{
            duration: 1000, 
            easing: 'easeOutCubic'
			}
		);
		
	});
	
	
	$(".B3").live('click',function() { $(".B").removeClass("SEL"); $(".B3").addClass("SEL"); });
	$(".CLICK3").live('click',function() {
	   var left = $(".WRAP3").css("left");
	   $(".WRAP").animate({			
			"left":"-="+left+""
		    },{
            duration: 1000, 
            easing: 'easeOutCubic'
			}
		);
		
	});
	
	$(".B4").live('click',function() { $(".B").removeClass("SEL"); $(".B4").addClass("SEL"); });
	$(".CLICK4").live('click',function() {
		
	   var left = $(".WRAP4").css("left");
	   $(".WRAP").animate({			
			"left":"-="+left+""
		    },{
            duration: 1000, 
            easing: 'easeOutCubic'
			}
		);
		
	});
	$(".B5").live('click',function() { $(".B").removeClass("SEL"); $(".B5").addClass("SEL"); });
	$(".CLICK5").live('click',function() {
		
	   var left = $(".WRAP5").css("left");
	   $(".WRAP").animate({			
			"left":"-="+left+""
		    },{
            duration: 1000, 
            easing: 'easeOutCubic'
			}
		);
		
	});
	
	/*
	$(".M3TU").live('click',function() {
		$(this).siblings(".TOUCHED").animate({			
			"width":"-=80px",
			"left":"+=40px",
			"top":"-=40px"
		    },{
            duration: 500 
			}
		);
		$(this).siblings(".TOUCHED").addClass("M3TU");
		$(this).siblings().removeClass("TOUCHED");
		$(this).addClass("TOUCHED");
		$(this).animate({			
			"width":"+=80px",
			"left":"-=40px",
			"top":"+=40px"
		    },{
            duration: 500,
			}
		);
		$(this).removeClass("M3TU");
	});
	*/
	$(".M3TU").live('click',function() {
		$(this).siblings(".TOUCHED").animate({			
			"height":"-=40px"
		    },{
            duration: 500 
			}
		);
		$(this).siblings(".TOUCHED").addClass("M3TU");
		$(this).siblings().removeClass("TOUCHED");
		$(this).addClass("TOUCHED");
		$(this).animate({			
			"height":"+=40px"
		    },{
            duration: 500
			}
		);
		$(this).removeClass("M3TU");
	});
	
	$(".M3T0").live('click',function() {
		$(".M3R").hide();
		$(".M3R0").show()	 
	 });
	 
	 $(".M3T1").live('click',function() {
		$(".M3R").hide();
		$(".M3R1").show()	 
	 });
	 
	 $(".M3T2").live('click',function() {
		$(".M3R").hide();
		$(".M3R2").show()	 
	 });
	 
	 $(".M3T3").live('click',function() {
		$(".M3R").hide();
		$(".M3R3").show()	 
	 });
	 
	 $(".M3T4").live('click',function() {
		$(".M3R").hide();
		$(".M3R4").show()	 
	 });
	 
	 
	 
	 
	 // GALLERY 
	 if (screen.width == '1024') {
		 	$(".M2RTCI").hover(function() {
			$(this).css({'z-index' : '10'}); /*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: '-70px', /* The next 4 lines will vertically align this image */ 
					marginLeft: '-70px',
					top: '50%',
					left: '50%',
					width: '97px', /* Set new width */
					height: '97px', /* Set new height */
					padding: '10px',
					border: '1px solid #9b9b9b'
				}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
		
			} , function() {
			$(this).css({'z-index' : '0'}); /* 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: '75px', /* Set width back to default */
					height: '75px', /* Set height back to default */
					padding: '0px',
					border:"0"
				}, 400);
		});

		 
		 
		 
	 } else {
		 
		 $(".M2RTCI").hover(function() {
			$(this).css({'z-index' : '10'}); /*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: '-70px', /* The next 4 lines will vertically align this image */ 
					marginLeft: '-70px',
					top: '50%',
					left: '50%',
					width: '124px', /* Set new width */
					height: '124px', /* Set new height */
					padding: '10px',
					border: '1px solid #9b9b9b'
				}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
		
			} , function() {
			$(this).css({'z-index' : '0'}); /* 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: '97px', /* Set width back to default */
					height: '97px', /* Set height back to default */
					padding: '0px',
					border:"0"
				}, 400);
		});
	}
	
	$("a[class='colo']").colorbox({width:"60%", height:"80%", iframe:true});
	$("a[class='colo1']").colorbox();
	$("a[class='colo2']").colorbox();
	$("a[class='colo3']").colorbox();
	$("a[class='colo4']").colorbox();
	$("a[class='colo5']").colorbox();
	$("a[class='colo6']").colorbox();
	$("a[class='colo7']").colorbox();
	$("a[class='colo8']").colorbox();
 
	 //if (screen.width < 1024) {
		 var countme = 0;
		 $(".NEXT").live('click',function() {
			
			$(".WRAP").animate({			
				"left":"-=500px"
				},500
			);
			countme++;
			if (countme == 2) { 
				$(this).hide();
				$(this).siblings(".PREV").animate({left: '+=300px'},500);
			}
			$(this).siblings(".PREV").show();
			 
		 });
	
		 $(".PREV").live('click',function() {
			
			$(".WRAP").animate({			
				"left":"+=500px"
				},500
			);
			countme--;
			if (countme == 0) { 
				$(this).hide();
			}
			if (countme == 1) {
				$(this).animate({left: '-=300px'},500);
			}
			$(this).siblings(".NEXT").show();
			 
		 });
	 //} else {
		 //$(".M2RTCN").hide(0);
	// }
	
	
	$(".SENDFORM").click(function() {
		
		var name = $(".FNAME").val();
		var subject = $(".FSUBJECT").val();
		var phone = $(".FPHONE").val();
		var email = $(".FEMAIL").val();
		var msg = $(".FMSG").val();
		if (subject!='' && email !='') {
			$.post("includes/mail.php",{fname : name,fsubject : subject, fphone : phone, femail : email , fmsg : msg },function(data) {
				if (data == 'succesfuull') { 
					$(".TY").show();
					$(".TY").html('Thank you for contact us');
					$(".M5RC input").val('');
					$(".M5RC textarea").val('');
				
				}
			});
		}
	
	});
	
	
});
