/* preload images*/
function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
    }
    


/*
================================
Popup window
================================
*/
 
// jQuery Alert Dialogs Plugin
//
// Version 1.0
//
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
// 29 December 2008
//
// Visit http://abeautifulsite.net/notebook/87 for more information
//
// Usage:
//		jAlert( message, [title, callback] )
//		jConfirm( message, [title, callback] )
//		jPrompt( message, [value, title, callback] )
// 
// History:
//
//		1.00 - Released (29 December 2008)
//
// License:
// 
// This plugin is dual-licensed under the GNU General Public License and the MIT License and
// is copyright 2008 A Beautiful Site, LLC. 
//
(function($) {
	
	$.alerts = {
		
		// These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time
		
		verticalOffset: -75,                // vertical offset of the dialog from center screen, in pixels
		horizontalOffset: 0,                // horizontal offset of the dialog from center screen, in pixels/
		repositionOnResize: true,           // re-centers the dialog on window resize
		overlayOpacity: .01,                // transparency level of overlay
		overlayColor: '',               // base color of overlay
		draggable: true,                    // make the dialogs draggable (requires UI Draggables plugin)
		okButton: '&nbsp;OK&nbsp;',         // text for the OK button
		cancelButton: '&nbsp;Cancel&nbsp;', // text for the Cancel button
		dialogClass: null,                  // if specified, this class will be applied to all dialogs
		
		// Public methods
		
		alert: function(message, title, callback) {
			if( title == null ) title = 'Alert';
			$.alerts._show(title, message, null, 'alert', function(result) {
				if( callback ) callback(result);
			});
		},
		
		confirm: function(message, title, callback) {
			if( title == null ) title = 'Confirm';
			$.alerts._show(title, message, null, 'confirm', function(result) {
				if( callback ) callback(result);
			});
		},
			
		prompt: function(message, value, title, callback) {
			if( title == null ) title = 'Prompt';
			$.alerts._show(title, message, value, 'prompt', function(result) {
				if( callback ) callback(result);
			});
		},
		
		// Private methods
		
		_show: function(title, msg, value, type, callback) {
			
			$.alerts._hide();
			$.alerts._overlay('show');
			
			$("BODY").append(
			  '<div id="popup_container">' +
			    '<h1 id="popup_title"></h1>' +
			    '<div id="popup_content">' +
			      '<div id="popup_message"></div>' +
				'</div>' +
			  '</div>');
			
			if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass);
			
			// IE6 Fix
			var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed'; 
			
			$("#popup_container").css({
				position: pos,
				zIndex: 99999,
				padding: 0,
				margin: 0
			});
			
			$("#popup_title").text(title);
			$("#popup_content").addClass(type);
			$("#popup_message").text(msg);
			$("#popup_message").html( $("#popup_message").text().replace(/\n/g, '<br />') );
			
			$("#popup_container").css({
				minWidth: $("#popup_container").outerWidth(),
				maxWidth: $("#popup_container").outerWidth()
			});
			
			$.alerts._reposition();
			$.alerts._maintainPosition(true);
			
			switch( type ) {
				case 'alert':
					$("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>');
					$("#popup_ok").click( function() {
						$.alerts._hide();
						callback(true);
					});
					$("#popup_ok").focus().keypress( function(e) {
						if( e.keyCode == 13 || e.keyCode == 27 ) $("#popup_ok").trigger('click');
					});
				break;
				case 'confirm':
					$("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>');
					$("#popup_ok").click( function() {
						$.alerts._hide();
						if( callback ) callback(true);
					});
					$("#popup_cancel").click( function() {
						$.alerts._hide();
						if( callback ) callback(false);
					});
					$("#popup_ok").focus();
					$("#popup_ok, #popup_cancel").keypress( function(e) {
						if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
						if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
					});
				break;
				case 'prompt':
					$("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>');
					$("#popup_prompt").width( $("#popup_message").width() );
					$("#popup_ok").click( function() {
						var val = $("#popup_prompt").val();
						$.alerts._hide();
						if( callback ) callback( val );
					});
					$("#popup_cancel").click( function() {
						$.alerts._hide();
						if( callback ) callback( null );
					});
					$("#popup_prompt, #popup_ok, #popup_cancel").keypress( function(e) {
						if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
						if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
					});
					if( value ) $("#popup_prompt").val(value);
					$("#popup_prompt").focus().select();
				break;
			}
			
			// Make draggable
			if( $.alerts.draggable ) {
				try {
					$("#popup_container").draggable({ handle: $("#popup_title") });
					$("#popup_title").css({ cursor: 'move' });
				} catch(e) { /* requires jQuery UI draggables */ }
			}
		},
		
		_hide: function() {
			$("#popup_container").remove();
			$.alerts._overlay('hide');
			$.alerts._maintainPosition(false);
		},
		
		_overlay: function(status) {
			switch( status ) {
				case 'show':
					$.alerts._overlay('hide');
					$("BODY").append('<div id="popup_overlay"></div>');
					$("#popup_overlay").css({
						position: 'absolute',
						zIndex: 99998,
						top: '0px',
						left: '0px',
						width: '100%',
						height: $(document).height(),
						background: $.alerts.overlayColor,
						opacity: $.alerts.overlayOpacity
					});
				break;
				case 'hide':
					$("#popup_overlay").remove();
				break;
			}
		},
		
		_reposition: function() {
			var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;
			var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;
			if( top < 0 ) top = 0;
			if( left < 0 ) left = 0;
			
			// IE6 fix
			if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop();
			
			$("#popup_container").css({
				top: top + 'px',
				left: left + 'px'
			});
			$("#popup_overlay").height( $(document).height() );
		},
		
		_maintainPosition: function(status) {
			if( $.alerts.repositionOnResize ) {
				switch(status) {
					case true:
						$(window).bind('resize', function() {
							$.alerts._reposition();
						});
					break;
					case false:
						$(window).unbind('resize');
					break;
				}
			}
		}
		
	}
	
	// Shortuct functions
	jAlert = function(message, title, callback) {
		$.alerts.alert(message, title, callback);
	}
	
	jConfirm = function(message, title, callback) {
		$.alerts.confirm(message, title, callback);
	};
		
	jPrompt = function(message, value, title, callback) {
		$.alerts.prompt(message, value, title, callback);
	};
	
})(jQuery);


/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function ajaxpage(url, containerid, callBack,isSkipScroll){

    $("#"+containerid).load(url+ " #bodyContent","", function(){
         
       
        if(callBack)eval(callBack);
        if(isSkipScroll != 1){
             $('html, body').animate({scrollTop:0}, 'slow');
        }
    }); 
}

/*
================================
 URL REWRITE
================================
*/


function urlRewrite(url){
    //  /niews/neiws-item-1.aspx  to  /niews.aspx?name=neiws-item-1.aspx
    
    //  /niews/test/neiws-item-1.aspx  to  /niews.aspx?name=neiws-item-1.aspx
    
    var url = new String(url);
    var index = url.indexOf("/",1);
    
     var newUrl =url.substring(0,index) + ".aspx?!="+url.slice(index+1);
    //location.replace( url.substring(0,index) + ".aspx?name="+url.slice(index+1));

	window.location.href = newUrl ;
    
}

/*home page onload slide images*/

$(document).ready(function() {
	$(function() {
         $(".slideShowClass").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			visible : 3,
			circular: false
		});
	});
	
	
	
});


    /*
================================
JQuery for search box
================================
*/

$(document).ready(function() {

$('#Search_Box').keypress(function(event){

    if(event.keyCode ==13 &&  $(this).val() !=''){
         onSearch('Search_Box') //do search
    }
});

});


function onSearch(textBoxId){

    var searchQuery = document.getElementById(textBoxId).value;
    
     location.replace("/Exio_Search.aspx?search=" + searchQuery);
}


 
 /*
================================
FAQ
================================
*/  

function initFAQ() {
 
 
  $('.QuestionClassName').click(
        function(){
            var slideAnswer=$(this).next();
            slideAnswer.slideToggle('nomarl');
            
        }
    );
         
}

$(document).ready(function() {initFAQ();});

 /*
================================
 Top menu items
================================
*/  


function slideDownTheBottom(){
        return;
        if ($('.org_div').length >0)
        {
            // when the orange is expanded, we are going to slide down
               
            $('#fx').slideToggle('normal');
            $('#global').slideToggle('normal');
            
            if($('#moreArrow')[0]) {
                $('#moreArrow')[0].src = "/Assets/images/arrow_up.gif";
                $("#moreArrow").fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);          
            }
        }
}

//$(document).ready(function() {

//     /*for the top navigation button items*/

//    $('.nav1').click(function() {
//        
//       slideDownTheBottom();      
//      // setTimeout("location.href='/exio_homepage.aspx'",6);
//        
//    });
//    
//  
//    $('.nav2').click(function()
//    {    
//       slideDownTheBottom();      
//      // setTimeout("location.href='/solutions.aspx'",6);
//        
//    });
// 

//    $('.nav3').click(function()
//    {    
//       slideDownTheBottom();        
//       //setTimeout("location.href='/sourcing.aspx'",6);
//        
//    });
//  

//    $('.nav4').click(function()
//    {
//    
//       slideDownTheBottom(); 
//       //setTimeout("location.href='/support.aspx'",6);
//        
//    });
//    
//   

//    $('.nav5').click(function()
//    {
//    
//       slideDownTheBottom(); 
//      //setTimeout("location.href='/showcases.aspx'",6);
//        
//    });
//    
//  

//    $('.nav6').click(function()
//    {
//    
//       slideDownTheBottom(); 
//       //setTimeout("location.href='/contact.aspx'",6);
//        
//    });
//    


//});




//adjust Footer And MoreXXX lable 
function initBottomAndTopMenuArea(){
    
    
    $('.org_div').css('margin-top', '-4px');
   
    
    // Keep the foot at bottom except the home page
    
    if($('#i_mainbj_box_home').length<=0){
    
        //Slide down the orange part on start.
        
        
      
        
//        $('#fx').slideToggle(1);
//        $('#global').slideToggle(1);
    
         if($('#moreSolutions')[0]) $('#moreArrow')[0].src = "/Assets/images/arrow_up.gif";
             
         $('#footbox').addClass('footbox_float');
         $('#footbox').removeClass('footbox');
         
         $('#org_div').addClass('org_div_float');
         $('#org_div').removeClass('org_div');
       
        // blink the arrow
        $("#moreArrow").fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200);
       
        
    
    }
    // when the home page is loaded, the change the menu item to the one withe blue border
//    if($('#i_mainbj_box_home').length>0){
//        $('.nav1:link').css('background', 'url(/Assets/images/sl_websites_h.png) no-repeat left');    
//    }
//    
//    // if the it is 4s pages, then add the float layout
//    if($('#moreSolutions')[0]){         
//         $('.nav2:link').css('background', 'url(/Assets/images/solutions_h.gif) no-repeat left'); 
//    }
//    if($('#moreSourcing')[0]){                         
//         $('.nav3:link').css('background', 'url(/Assets/images/sourcing_h.gif) no-repeat left'); 
//    }
//    if($('#moreSupport')[0]){
//         $('.nav4:link').css('background', 'url(/Assets/images/support_h.gif) no-repeat left'); 
//    }
//    if($('#moreShowCases')[0]){
//         $('.nav5:link').css('background', 'url(/Assets/images/showcase_h.gif) no-repeat left'); 
//    }    
//    if($('#contactPageId').length>0){    
//        $('.nav6:link').css('background', 'url(/Assets/images/contact_h.gif) no-repeat left');    
//    }
           
}

 /*
================================
jquery for slide down
================================
*/  

$(document).ready(function()
{

     setTimeout("$('#fx').css('display','none'); $('#fx').css('height','auto');",1000);

     //adjust Footer And MoreXXX lable  and make the top menu with mouse over effect
     initBottomAndTopMenuArea();

    $('#moreBtn').click(function()
    {
        
        
        if ($('.org_div').length >0)
        {
        
        // $('#global')[0].style.height =378;
         
            // when the orange is expanded, we are going to slide down
          $('#org_div').removeClass('org_div');
          $('#org_div').addClass('org_div_float');
          
          $('.slideShowClass ul li img').css('display','none');
              
           /*when the bottom is slided up*/
            $('#org_div').css('margin-top', '0px');
            $('#global').css('height', '378px');
           
                   
            if($('#moreArrow')[0]) $('#moreArrow')[0].src = "/Assets/images/arrow_up.gif";
         
        }else{
            // to slide up
              //$('html, body').animate({scrollTop:1500}, 'slow');
              
              //$('#global')[0].style.height =0;
              
                       
              $('#gallery').css('z-index', '0');  
              
             $('#org_div').removeClass('org_div_float');
             $('#org_div').addClass('org_div'); 
             
              $('.slideShowClass ul li img').css('display','block');
              
             
            
              

                         
             $('#org_div').css('margin-top', '-4px');                
             $('#global').css('height', '0px');                
                 
           if($('#moreArrow')[0]) $('#moreArrow')[0].src = "/Assets/images/arrow_down.gif";
        }
        

        $('#fx').slideToggle('normal');
        $('#global').slideToggle('normal', function(){            
             $("#moreArrow").fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);

        });
       
        return false;

    });

    
      
     
});
 
 
 
 /*
================================
Swap the navigation menu  MM_preloadImages 图片预加载
================================
*/  

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
 
 
     /*
================================
JQuery for search box
================================
*/

$(document).ready(function() {




$('#EXIO_Search_Box').keypress(function(event){

    if(event.keyCode ==13 &&  $(this).val() !=''){
         onSearch('EXIO_Search_Box') //do search
       
    }
});


$('#EXIO_Search_Box').focus(function(event){

    if(this.value =="zoeken"){
         this.value ='';
       
    }
}).blur(function(event){

    if(this.value =="zoeken"){
         this.value ='';
       
    }
});





});


/*
================================
JQuery for showcase flash page

jQuery.browser.mozilla
jQuery.browser.msie
jQuery.browser.opera
jQuery.browser.safari
jQuery.browser.version
================================
*/

function setFlashDivPosition() {    
    
    if($('#i_mainbj_box')[0]){
        
        
            
            var left = ($('#i_mainbj_box')[0].offsetWidth - 778)/2;// the left position for the flash  component 820x820
            
             var centerFlashTableLeft = ($('#i_mainbj_box')[0].offsetWidth - 786)/2;// the left position for the flash  component 820x820
            
            var orgDivLeft = ($('#i_mainbj_box')[0].offsetWidth - 162)/2;
            
             if(jQuery.browser.mozilla ==true){
               
                              
               // $('#moreShowCases').css('margin-left', orgDivLeft);   
                $('#org_div table:first').css('margin-left', orgDivLeft);   
                
             }
             if(jQuery.browser.msie ==true){
                                
                if(jQuery.browser.version=="8.0"){
                
                                 
                    $('#org_div table:first').css('margin-left', orgDivLeft);  
                    $('.flvbtn').css('margin-left', '-4px');  
                     
                }
                
             }
             if(jQuery.browser.opera ==true){
               
                
             }
             if(jQuery.browser.safari ==true){
               
                $('#org_div table:first').css('margin-left', orgDivLeft);   
                
             }
             
             
              $('#hiddenFlashLayerId').css('left', left);  
              $('#centerFlashTable').css('left', centerFlashTableLeft);  
               
              
               
      
      }
}; 
var resizeTimer = null;
$(window).bind('resize', function() {    
    if (resizeTimer) clearTimeout(resizeTimer); 
       resizeTimer = setTimeout(setFlashDivPosition, 100);
});


function setLinkStyles() {  
    $("a[title!=]").addClass("link") ;
    
}

$(document).ready(function() {
        
      setFlashDivPosition();

      setLinkStyles();



});



    
    
    $(document).ready(function() {
    
     if($('#gallery').length<=0){
     
            return true;
     }
        
         $(function() {
            $('#gallery a').lightBox({
                overlayBgColor: '#FFF',
	            overlayOpacity: 0.8,
	            containerResizeSpeed: 350,
	            fixedNavigation: true        
            });
        });
    
//	        $(function() {
//                 $("#gallery").jCarouselLite({
//			        btnNext: ".nextL",
//			        btnPrev: ".prevL",
//			        visible : 4,
//			        circular: true
//		        });
//	        });
	
    });
    
    
  /*
================================
for flash video
================================
*/  
    
     function getVcastr(idPrefix) {
      if (navigator.appName.indexOf("Microsoft") != -1) {
      return window[idPrefix+"_vcastr3"];
      } else {
      return document[idPrefix+"_vcastr3"];
      }
  }

  /*
  ================================
  for Solutions and Sourcing top navigation menu
  ================================
  */

  function activeTopMenuItem(id) {
      var oldSrc = (document.getElementById(id))? document.getElementById(id).src: "";

      if (oldSrc.indexOf("_h.png")!=-1) {
          return;
      }
      var re = /.png/g; 
      var newSrc = oldSrc.replace(re , "_h.png")
     if(document.getElementById(id)) document.getElementById(id).src = newSrc;
  }

  function deactiveTopMenuItem(id) {
      var oldSrc = (document.getElementById(id)) ? document.getElementById(id).src : "";
      var crtId = "/" + jQuery.url.segment(0) + "/" + jQuery.url.segment(1);

      if (oldSrc.indexOf("_h.png") == -1 || crtId== id ) {
          return;
      }
      var re = /_h.png/g;
      var newSrc = oldSrc.replace(re, ".png")
      if(document.getElementById(id)) document.getElementById(id).src = newSrc;
  }

  function highLightCrtCategory() {
      var crtId = "/" + jQuery.url.segment(0) + "/" + jQuery.url.segment(1);
     
      activeTopMenuItem(crtId);

}

function topMenuItem_OnClick(url){
    
    window.location.href = url;
}
  
  $(document).ready(function() {
   highLightCrtCategory();
   // set nav script
   var u=self.location.href;
   if(u.indexOf("websites",18)!=-1)
   {
     $(".website").addClass("websited");
    }
    else if(u.indexOf("software",18)!=-1)
    {
     $(".softwares").addClass("softwared");
    }
    else if(u.indexOf("design3d",18)!=-1)
    {
     $(".designs").addClass("designd");
    }
    else if(u.indexOf("qm",18)!=-1)
    {
        $(".qm").addClass("qmd");
    }
    else if(u.indexOf("zinin",18)!=-1)
    {
       $(".zinin").addClass("zinind");
    }
    else if(u.indexOf("odc",18)!=-1)
    {
       $(".odcs").addClass("odcsd");
    }
    else if(u.indexOf("LOCALIZE",18)!=-1)
    {
       $(".localizes").addClass("localizesd");
    }
    else if(u.indexOf("designdesk",18)!=-1)
    {
       $(".designdesks").addClass("designdesksd");
    }
    else if(u.indexOf("hosting",18)!=-1)
    {
       $(".hostings").addClass("hostingsd");
    };
  });
  

  function getnav()
  {
      var dd=document.getElementById("r_nav").offsetHeight+"px"; 
      $("#abc").css("height",dd);
  }
  
  // set websit left nav style
  function setorg(navid)
  {
    var num=$(".zhang img");
    for(var i=0;i<num.length;i++)
    {
       $("img.ddd").attr("src","/Assets/images/nav_white_arrow.jpg");
    }
    document.getElementById(navid+ "_img").src = "/Assets/images/nav_org_arrow.jpg";
  }

