function toggleDiv(div) {
	var bg = document.getElementById("overlayBg");
    var fg = document.getElementById(div + "Div");
    var link = document.getElementById(div + "Link");

    if (fg.style.display == "none") {
        bg.style.display = 'block';
        fg.style.display = 'block';
        link.style.zIndex= 0;
    } else {
        bg.style.display = 'none';
        fg.style.display = 'none';
        link.style.zIndex= 0;
    }
}
            
$(document).ready(function(){
	if(frames){
		  if(top.frames.length>0)
			  top.location.href=self.location;
	}
	$("#web-sms").click(function(){
		$("#WebSMS").submit();
	});
	$("#sms-messenger").click(function(){
		$("#SM").submit();
	});
	$("#email-sms").click(function(){
		$("#E2S").submit();
	});
	$("#sms-gateway").click(function(){
		$("#API").submit();
	});
	$("#outlook-sms").click(function(){
		$("#OMS").submit();
	});
	
	if($('.field-tip').length>0){
		$('.field-tip').tooltip({
			track: true, 
		    delay: 0, 
		    showURL: false, 
		    showBody: " - ", 
		    extraClass: "pretty", 
		    fixPNG: true, 
		    opacity: 0.95, 
		    left: -120 
		});
	}
	 
	$("#name").focus(function(){
		if (this.value=="Name"){
			this.value="";
		}
	}).blur(function() {
		if (this.value==""){
			this.value="Name";
		}
	}); 
	$("#company").focus(function(){
		if (this.value=="Company / NPO name"){
			this.value="";
		}
	}).blur(function() {
		if (this.value==""){
			this.value="Company / NPO name";
		}
	}); 
	$("#email").focus(function(){
		if (this.value=="Email"){
			this.value="";
		}
	}).blur(function() {
		if (this.value==""){
			this.value="Email";
		}
	}); 
	$("#phone").focus(function(){
		if (this.value=="Phone"){
			this.value="";
		}
	}).blur(function() {
		if (this.value==""){
			this.value="Phone";
		}
	});
	$("#mobile").focus(function(){
		if (this.value=="Mobile"){
			this.value="";
		}
	}).blur(function() {
		if (this.value==""){
			this.value="Mobile";
		}
	});
	
	
	
	$("#submit").click(function(){
		if ($("#name").val()=="Name"){
			$("#name").val("");
		}
		if ($("#company").val()=="Company / NPO name"){
			$("#company").val("");
		}
		if ($("#email").val()=="Email"){
			$("#email").val("");
		}
		if ($("#phone").val()=="Phone"){
			$("#phone").val("");
		}
		if ($("#mobile").val()=="Mobile"){
			$("#mobile").val("");
		}
		$("#trial-form").submit();
	});
	 $('.slideshow').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});

	$(".terms").colorbox({iframe:true, innerWidth:350, innerHeight:350});
	
    
    $("ul.sc_menu li").hover(function() {
          $(this).css({'zIndex' : '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: '-80px', /* The next 4 lines will vertically align this image */
               marginLeft: '0',
               top: '50%',
               left: '0',
               width: '100px', /* Set new width */
               height: '95px' /* Set new height */
           }, 400); /* this value of "200" is the speed of how fast/slow this hover animates */
     } ,
     function() {
          $(this).css({'zIndex' : '0'}); /* Set z-index back to 0 */
          $(this).find('img.offset').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
          .animate({
                marginTop: '15px', /* Set alignment back to default */
                marginLeft: '0',
                top: '0',
                left: '0',
                width: '100px', /* Set width back to default */
                height: '95px' /* Set height back to default */
           }, 600);
          $(this).find('img.normal').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: '100px', /* Set width back to default */
                height: '95px' /* Set height back to default */
           }, 600);
     });
     if ($('#contact-industry').length > 0) {
	     $('#contact-industry').validate({
	        errorContainer: "#formContactErroMsg",
	        errorClass: "invalid",
	        errorPlacement: function(error, element) {
                //error.appendTo( element.parent("label") );
	     	},
	        debug:false
	     });
	 };
	 if ($('#contact-partner').length > 0) {
	     $('#contact-partner').validate({
	        errorContainer: "#formContactErroMsg",
	        errorClass: "invalid",
	        errorPlacement: function(error, element) {
                //error.appendTo( element.parent("label") );
	     	},
	        debug:false
	     });
	 };
	 if ($('#contact-us').length > 0) {
	     $('#contact-us').validate({
	        errorContainer: "#formErroMsg",
	        errorClass: "invalid",
	        errorPlacement: function(error, element) {
                //error.appendTo( element.parent("label") );
	     	},
	        debug:false
	     });
	 };
	 if ($('#trial-form').length > 0) {
	     $('#trial-form').validate({
	        errorContainer: "#formTrialErroMsg",
	        errorClass: "invalid",
	        errorPlacement: function(error, element) {
                //error.appendTo( element.parent("label") );
	    	    if ($("#name").val()==""){
		 			$("#name").val("Name");
		 		}
		 		if ($("#company").val()==""){
		 			$("#company").val("Company / NPO name");
		 		}
		 		if ($("#email").val()==""){
		 			$("#email").val("Email");
		 		}
		 		if ($("#phone").val()==""){
		 			$("#phone").val("Phone");
		 		}
		 		if ($("#mobile").val()==""){
		 			$("#mobile").val("Mobile");
		 		}
	     	},
	        debug:false
	     });
	 };
	 

	 $('#choose-country').click(function(){
			$('#country-select').show('slow');
			return false;
	 });
	 $('#country-select').mouseleave(function(){
			$('#country-select').hide('slow');
	 });
	 
	 $("#nav-list li").hover(function(){
		$(this).addClass("sfhover");
		$(this).children('a').addClass("active");
	 }, function(){
		$(this).removeClass("sfhover");
		$(this).children('a').removeClass("active");
	 });
	 
	// set zIndex for each bubble (to fix
	$('ul.sc_menu li').each(function() {
	    $(this).css('zIndex', 0);
	    $(this).hover();
	});
});
