// JavaScript Document

// top header slider starts  
 //$.noConflict();
  
$(document).ready(function() {
//CONTROLLING EVENTS IN jQuery           
  //alert('uuuuuuuu');
	//CLOSING POPUP
    //Click the x event!
    $("#popupContactClose").click(function(){
        popupStatus = 1;
        disablePopup();
    });
    $('.right-collops-content').attr("style","display:none;");
    //LOADING POPUP
    //Click the button event!
    $("#button").click(function(){
        //centering with css
        centerPopup();
        //load popup
        loadPopup();
    });
                
    /*//CLOSING POPUP
    //Click the x event!
    $("#popupContactClose").click(function(){
        debugger;
        disablePopup();
    });*/
    //Click out event!
    $("#backgroundPopup").click(function(){
        disablePopup();
    });
    //Press Escape event!
    $(document).keypress(function(e){
        if(e.keyCode==27 && popupStatus==1){
            disablePopup();
        }
    });




	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
 

 
	//Default Action
//	/$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
        
		/*$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
        */
		//;$(".tab_content").fadeOut(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(this).fadeIn(); //Fade in the active content
		return false;
	});
 
/*
 $('.right-collops-title').click(function() {

        $('.right-collops-title').removeClass('on');
        $('.right-collops-content').slideUp('normal');
        
        $('.right-collops-title').find("h2").css("font-weight","normal");
        $(".right-collops-title").find(".arrow").html('<img src="/img/static_home/top-arrow.jpg" alt=""  title="" />');           
     
        if($(this).next().is(':hidden') == true) {
            $(this).addClass('on');
            $(this).find("h2").css("font-weight","bold");
            $(this).find('.arrow').html('<img src="/img/static_home/bottom-arrow.jpg" alt=""  title="" />');
            $(this).next().slideDown('normal');
            
            
         }                                                                          
 });
      */
    
 /*   
 $('.sidebar-collops-title').click(function() {

        $('.sidebar-collops-title').removeClass('on');
        $('.sidebar-collops-content').slideUp('normal');
        $(".sidebar-collops-title").find(".arrow").html('<img src="/img/static_home/top-arrow.jpg" alt=""  title="" />');           
        if($(this).next().is(':hidden') == true) {
            $(this).addClass('on');
            $(this).find('.arrow').html('<img src="/img/static_home/bottom-arrow.jpg" alt=""  title="" />');
            $(this).next().slideDown('normal');                     
         }                                                                         
 });  
      */
 

/*$(".sidebar-collops-title").click(function()

        { 
        if($(this).attr('style')==undefined)
        {
            $(".sidebar-collops-title").next().slideUp(1000);
            $(".sidebar-collops-title").find(".arrow").html('<img src="/biztechconsultancy/img/static_home/bottom-arrow.jpg" alt=""  title="" />');           
     
            
            $(this).next().slideDown(1000);
            $(this).find('.arrow').html('<img src="/biztechconsultancy/img/static_home/top-arrow.jpg" alt=""  title="" />');
            $(this).attr("style","display:block;");
        }
        else
        {
            $(this).find(".content").slideUp(1000);  
            $(this).find('.arrow').html('<img src="/biztechconsultancy/img/static_home/bottom-arrow.jpg" alt=""  title="" />'); 
            $(this).siblings(".content").slideUp(1000);           
            $(this).removeAttr('style');
        }
          
        });   */
		
		/*$(".right-collops-title").click(function(){ 
        if($(this).attr('style')==undefined)
        {
            $(".right-collops").find(".content").slideUp(1000);
            $(".right-collops").find(".arrow").html('<img src="/biztechconsultancy/img/static_home/bottom-arrow.jpg" alt=""  title="" />');           
            $(".right-collops").find(".arrow").removeAttr('style');
            
            $(this).siblings(".content").slideDown(1000);
            $(this).find('.arrow').html('<img src="/biztechconsultancy/img/static_home/top-arrow.jpg" alt=""  title="" />');
            $(this).attr("style","display:block;");
        }
        else
        {
            $(this).find(".content").slideUp(1000);  
            $(this).find('.arrow').html('<img src="/biztechconsultancy/img/static_home/bottom-arrow.jpg" alt=""  title="" />'); 
            $(this).siblings(".content").slideUp(1000);           
            $(this).removeAttr('style');
        }
          
        }); */
	
    
	// Expand Panel
	$("#open").click(function(){
		$("div#panel").slideDown("slow");
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");	
	});		
	
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});	        

// latest work slider starts
	jQuery("#slider").easySlider({
		controlsBefore:	'<p id="controls">',
		controlsAfter:	'</p>',
		auto: true, 
		continuous: true,
		speed: 2000
	});
	jQuery("#slider2").easySlider({
		controlsBefore:	'<p id="controls">',
		controlsAfter:	'</p>',		
		prevId: 'prevBtn',
		nextId: 'nextBtn',
		auto: true, 
		continuous: true,
		speed: 2000
	});
	
	jQuery("#slider3").easySlider({
	controlsBefore: '<p id="controls">',
	controlsAfter: '</p>',
	auto: true,
	prevId: 'prevBtn1',
	nextId: 'nextBtn2',
	continuous: true,
	speed: 1000
	});
	jQuery("#slider4").easySlider({
	controlsBefore: '<p id="controls1">',
	controlsAfter: '</p>',
	auto: true,
	prevId: 'prevBtn41',
	nextId: 'nextBtn42',
	continuous: true,
	speed: 1500

	});	
});


// drop-down menu starts
sfHover = function() {
	var sfEls = document.getElementById("main_lnks").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
   
    //loads popup only if it is disabled
    if(popupStatus==0){
        $("#backgroundPopup").css({
            "opacity": "0.7"
        });
        $("#backgroundPopup").fadeIn("slow");
        $("#popupContact").fadeIn("slow");
        popupStatus = 1;
    }
}

//disabling popup with jQuery magic!
function disablePopup(){
    //disables popup only if it is enabled
    debugger;
    if(popupStatus==1){
        $("#backgroundPopup").fadeOut("slow");
        $("#popupContact").fadeOut("slow");
        popupStatus = 0;
    }
}

//centering popup
function centerPopup(){
    //request data for centering
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#popupContact").height();
    var popupWidth = $("#popupContact").width();
    
    //centering
    $("#popupContact").css({
        "position": "absolute",
        "top": windowHeight/2-popupHeight/2,
        "left": windowWidth/2-popupWidth/2
    });
    //only need force for IE6
    
    $("#backgroundPopup").css({
        "height": $(document).height()
    });
    
}






