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($("#web-sms").length>0){
		$("#web-sms").click(function(){
			$("#WebSMS").submit();
		});
	}
	if($("#sms-messenger").length>0){
		$("#sms-messenger").click(function(){
			$("#SM").submit();
		});
	}
	if($("#email-sms").length>0){
		$("#email-sms").click(function(){
			$("#E2S").submit();
		});
	}
	if($("#sms-gateway").length>0){
		$("#sms-gateway").click(function(){
			$("#API").submit();
		});
	}
	if($("#outlook-sms").length>0){
		$("#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("");
		}
		$("#trial-form").submit();
	});
	 $('.slideshow').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});

	$(".terms").colorbox({iframe:true, innerWidth:350, innerHeight:350});
	$("#video").colorbox({iframe:true, innerWidth:1050, innerHeight:650});
	
    
    $("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 ($('#eloqua-connector').length > 0) {
	     $('#eloqua-connector').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
	     });
	 };
	 $('#trial-form #submit').click(function(){
	    if($("#trial-form").valid()){
	    	$('#trial-form #submit').css('display','none');
	    }
	 });
	 if ($('#trial-form').length > 0) {
	     $('#trial-form').validate({
	        errorContainer: "#formTrialErroMsg",
	        errorClass: "invalid",
	        errorPlacement: function(error, element) {
                //error.appendTo( element.parent("label") );
	     	},
	        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();
	});
	
	if(getParameterByName('video')=="view"){
		if($("#video").length>0){
			$('#video').click();
		}
	}
});
function getParameterByName( name ){
	  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
	  var regex = new RegExp( regexS );
	  var results = regex.exec( window.location.href );
	  if( results == null )
	    return "";
	  else
	    return decodeURIComponent(results[1].replace(/\+/g, " "));
}
