jQuery.noConflict();
jQuery( document ).ready( function () {

  // if working locally...
  if (jQuery( 'base' ).exists() && jQuery( 'base' ).attr( 'href' ).match( '127.0.0.1' )) {

    var sPath = jQuery( 'base' ).attr( 'href' ).replace( /\/application\/.+\//, '' );

    // prepend absolute links with (abbreviated) local path
    jQuery( 'a[href^=/]' ).each( function () { jQuery( this ).attr( 'href', sPath + jQuery( this ).attr( 'href' ) ); } );

    // prepend form actions with (abbreviated) local path
    jQuery( 'form' ).each( function () {
      if (jQuery( this ).attr( 'action' ).match( /^\// )) { jQuery( this ).attr( 'action', sPath + jQuery( this ).attr( 'action' ) ); }
    } );

 } else {

    // prepend form actions with (abbreviated) local path
    jQuery( 'form' ).each( function () {
      if (jQuery( this ).attr( 'action' ).match( /^\// )) { jQuery( this ).attr( 'action', jQuery( this ).attr( 'action' ) ); }
    } );

    // prepend absolute links with (abbreviated) local path
    jQuery( 'a[href^=/]' ).each( function () { jQuery( this ).attr( 'href', jQuery( this ).attr( 'href' ) ); } );
  }

  // if focus... blur
  jQuery( 'a' ).focus( function () { this.blur() } );

  // initialize external links
  jQuery( 'a.external' ).click( function() {
    window.open( jQuery( this ).attr( 'href' ) );
    return false;
  } );

  // assign name (to avoid: id="txtFoo" name="txtFoo")
  jQuery( 'form :input[id]' ).each( function () {
    if (jQuery( this ).attr( 'name' ) == '' || jQuery( this ).attr( 'name' ) == null) {
      jQuery( this ).attr( 'name', jQuery( this ).attr( 'id' ) );
    }
  } );

  // remove textarea resize (for safari)
  jQuery( 'textarea' ).css( 'resize', 'none' );

  // if carousel exists... preload carousel images
  if (typeof( window['aCarousel'] ) != 'undefined' && aCarousel.length) {
    for (var i in aCarousel) { jQuery.preloadImage( 'asset/upload/image/' + aCarousel[i].src ); }
  }

  // if (stupid) IE... simulate fixed positioning
  if (jQuery.browser.msie && jQuery.browser.version <= 6) {
    jQuery( 'div#divFooter' ).css( { 'position' : 'absolute' } );
    jQuery( window ).scroll( function() { jQuery( 'div#divFooter' ).css( 'top', (jQuery( this ).scrollTop() + jQuery( window ).height() - 39) + 'px' ); } );
  }
  
  jQuery("ul.sf-menu").superfish(); 
  
  jQuery( 'div#divPageSubmenu .outer .inner' ).corner("round 8px").parent().css('padding','8px').corner("round 14px");
  
  jQuery( 'div.download .outer .inner' ).corner("round 8px").parent().css('padding','8px').corner("round 14px");
  
  jQuery( 'div.mainPromo .outer .inner' ).corner("round 8px").parent().css('padding','8px').corner("round 14px");
  jQuery( 'div.smallPromo .outer .inner' ).corner("round 8px").parent().css('padding','8px').corner("round 14px");
  
  jQuery( 'div#divPromoBig .outer .inner' ).corner("round 8px").parent().css('padding','8px').corner("round 14px");
  
  jQuery( 'div#divPromoText .outer .inner' ).corner("round 8px").parent().css('padding','8px').corner("round 14px");
  
  jQuery( 'div#divSlurpologyHome .outer .inner' ).corner("round 8px").parent().css('padding','8px').corner("round 14px");
  jQuery( 'div.divFAQ .outer .inner' ).corner("round 8px").parent().css('padding','8px').corner("round 14px");
  jQuery( 'div.divAdvice .outer .inner' ).corner("round 8px").parent().css('padding','8px').corner("round 14px");

  
  jQuery( 'div#divSlurpologyContent div#divTexts').corner('round right 4px');
  
  jQuery( 'div#divPageSubmenu select' ).corner("round 4px");
  
  //jQuery( 'div.divCounter_0' ).corner("round 4px");
  jQuery( 'div#divLikeCounter' ).corner("round 4px");
  
  jQuery( 'div#HomeLeft .outer .inner' ).corner("round 8px").parent().css('padding','8px').corner("round 14px");
  jQuery( 'div#HomeRight .outer .inner' ).corner("round 8px").parent().css('padding','8px').corner("round 14px");
  
  jQuery("div.box3_middle .image a img").mouseover(function(){
    jQuery(this).parents("div.box3_middle").css({ backgroundImage : "url(/asset/images/bg_box5_middle.png)" });
    jQuery(this).parents("div.box3_middle").siblings("div.box3_top").css({ backgroundImage : "url(/asset/images/bg_box5_top.png)" });
    jQuery(this).parents("div.box3_middle").siblings("div.box3_bottom").css({ backgroundImage : "url(/asset/images/bg_box5_bottom.png)" });
  }).mouseout(function(){
    jQuery(this).parents("div.box3_middle").css({ backgroundImage : "url(/asset/images/bg_box3_middle.png)" });
    jQuery(this).parents("div.box3_middle").siblings("div.box3_top").css({ backgroundImage : "url(/asset/images/bg_box3_top.png)" });
    jQuery(this).parents("div.box3_middle").siblings("div.box3_bottom").css({ backgroundImage : "url(/asset/images/bg_box3_bottom.png)" });
  });
  
  if (!jQuery.browser.msie){
		jQuery("div#divPageSubmenu div.box6_center select").mouseover(function(){
			jQuery(this).parents("div.box6_center").css({ backgroundImage : "url(/asset/images/bg_box6_center_hover.png)" });
			jQuery(this).parents("div.box6_center").siblings("div.box6_right").css({ backgroundImage : "url(/asset/images/bg_box6_right_hover.png)" });
			jQuery(this).parents("div.box6_center").siblings("div.box6_left").css({ backgroundImage : "url(/asset/images/bg_box6_left_hover.png)" });
		}).mouseout(function(){
			jQuery(this).parents("div.box6_center").css({ backgroundImage : "url(/asset/images/bg_box6_center.png)" });
			jQuery(this).parents("div.box6_center").siblings("div.box6_right").css({ backgroundImage : "url(/asset/images/bg_box6_right.png)" });
			jQuery(this).parents("div.box6_center").siblings("div.box6_left").css({ backgroundImage : "url(/asset/images/bg_box6_left.png)" });
		});
  }
  if (jQuery.browser.safari){
  	jQuery("div.box6_center").css('padding-top', '19px').css('padding-bottom', '21px');
  }
  
});

/*
 * Custom jQuery methods
 */
jQuery.fn.exists = function() { return jQuery( this ).length > 0; }

var aCache = [];
jQuery.preloadImage = function() {

  var oImage = document.createElement( 'img' );
  for (var i = arguments.length; i--;) {
    oImage.src = arguments[i];
    aCache.push( oImage );
  }
}



function linkTo(optVal){
  if(optVal=="") return false;
  window.location='http://www.cientis.com/'+optVal;
}

