var IE = false;
var w = 1; //document width
var h = jQuery( window ).height( ); //window height

// JavaScript Document
font_size = new Array( "14px", "16px", "18px", "20px" );
font_cur = 0;

function hideShowSearchWord( obj, s_w ){
	s_value = obj.value;
	if( s_value == s_w ){
		obj.value = '';
	} else if( s_value == '' ){
		obj.value = s_w;
	}
}

function screenSize( ){
      var w, h;
      w = ( window.innerWidth ? window.innerWidth : ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth ) );
      h = ( window.innerHeight ? window.innerHeight : ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight ) );
      return { w:w, h:h };
}

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function( ) {
    var args_len = arguments.length;
    for( var i = args_len; i--; ) {
      var cacheImage = document.createElement( 'img' );
      cacheImage.src = arguments[i];
      cache.push( cacheImage );
    }
  }
})(jQuery)

jQuery( function( ){
	jQuery( document ).ready( function( ){
        var w = jQuery( 'body' ).width( );
        jQuery.preLoadImages( "/images/layout/preloader.gif" );
    	var flag = false;
    	jQuery( '#accordion h3' ).click( function( )
          {
      	    if( jQuery(this).find( '#pic_icon' ).hasClass( 'accord_closed' ) ){
                  var o = jQuery( this ).parent( ).eq( 0 );
                  var omo = jQuery( "iframe", o );
                  if( omo.size( ) > 0 && !flag )
                  {
                      omo.attr( 'src', omo.attr( 'src' ) );
                      flag = true;
                  }
      			jQuery( this ).find( '#pic_icon' ).addClass( 'accord_opened' ).removeClass( 'accord_closed' );
      		    jQuery( this ).find( '#pan_name' ).addClass( 'pan_opened' ).removeClass( 'pan_closed' );
      			jQuery( this ).find( '#bottomb' ).addClass( 'ie_img_opened' ).removeClass( 'ie_img_closed' );
                  //jQuery( "#evo-chart" ).bind( "load", function( ){alert('load ok');} );
      		}
              else
              {
                  flag = true;
      			jQuery( this ).find( '#pic_icon' ).removeClass( 'accord_opened' ).addClass( 'accord_closed' );
      			jQuery( this ).find( '#pan_name' ).removeClass( 'pan_opened' ).addClass( 'pan_closed' );
      			jQuery( this ).find( '#bottomb' ).removeClass( 'ie_img_opened' ).addClass( 'ie_img_closed' );
      		}
      		jQuery( this ).next( ).toggle( "blind" );
      		return false;
      	  }
        );
        jQuery( '#accordion h3.closed' ).next( ).hide( );
    	jQuery( '#accordion h2' ).click( function( ) {
        	if( jQuery( this ).find( '#pic_icon' ).hasClass( 'h2_accord_closed' ) )
            {
        		jQuery( this ).find( '#pic_icon' ).addClass( 'h2_accord_opened' ).removeClass( 'h2_accord_closed' );
        		jQuery( this ).find( '#pan_name' ).addClass( 'pan_opened' ).removeClass( 'pan_closed' );
        		jQuery( this ).find( '#bottomb' ).addClass( 'ie_img_opened' ).removeClass( 'ie_img_closed' );
        	}
            else
            {
        		jQuery( this ).find( '#pic_icon' ).removeClass( 'h2_accord_opened' ).addClass( 'h2_accord_closed' );
        		jQuery( this ).find( '#pan_name' ).removeClass( 'pan_opened' ).addClass( 'pan_closed' );
        	}
        	jQuery( this ).next( ).toggle( "blind" );
        	return false;
    	}).next( ).hide( );
    	jQuery( '.lupa .lupa_p' ).click(function( ){
    	    if( jQuery( ".text" ).css( "font-size" ) != "20px" )
            {
    		    font_cur += 1;
    			jQuery( ".text" ).css( "font-size", font_size[font_cur] );
    		}
    		return false;
    	} );
    	jQuery( '.lupa .lupa_m' ).click( function( ){
        	if( jQuery( ".text" ).css( "font-size" ) != "14px" )
            {
    		    font_cur -= 1;
    			jQuery( ".text" ).css( "font-size", font_size[font_cur] );
    		}
    		return false;
    	});

    	jQuery( '.map' ).click( function( ){
        	jQuery( '#n_lay' ).fadeIn( );
    		return false;
    	});

    	jQuery( window ).scroll( function( ){
          	jQuery( "#n_lay" ).css( "top", jQuery( window ).scrollTop( ) + 'px' ) + ( jQuery( window ).height( ) - 410 ) / 2;
    	});

        //added by Mamed @ 2010-01-09
        //while implementing bodycover/loader site functions
        var gHash = { width: w, height: h };
        var gWnd = jQuery( window );
        jQuery( "<div id='bodycover'><div id='bodyloader'><div id='swObj'></div></div></div>" ).prependTo( 'body' );
        jQuery( "#bodycover" ).css( 'height', jQuery( 'body' ).height( ) );
        jQuery( "#bodyloader, #swObj" ).css( gHash );
        jQuery( "#swObj" ).click( function( ){ jQuery( this ).slideUp( "slow", function( ){ genieLoader( false ); } ); } )
        gWnd.scroll( function( ){ jQuery( "#swObj, #bodyloader" ).css( { top: gWnd.scrollTop( ) } ); } );
	});
});

function show_mp3_player( path, id )
{
    if( jQuery( '#' + id ).size( ) > 0 )
    {
        jQuery( '#' + id + ' object' ).remove( );
        jQuery( '#' + id ).remove( );
        return false;
    }
    jQuery( '<div id="' + id + '"></div>' ).css( {
     top: '-999px', left: '-999px', position: 'absolute'
    } ).html( '<object type="application/x-shockwave-flash" data="/images/player_mp3_mini.swf" width="200" height="20">'
    + '<param name="movie" value="/images/player_mp3_mini.swf" />'
    + '<param name="bgcolor" value="#000000" />'
    + '<param name="FlashVars" value="mp3=' + path + '&autoplay=1" />'
    + '</object>' ).appendTo( 'body' );
}

function genieLoader( swPosition )
{
    var o = jQuery( "#bodycover, #bodyloader" );
    if( swPosition )
        o.fadeIn( );
    else
        o.fadeOut( );
}