/**
 * @author blazsak
 */


 $(document).ready(function(){ 
  
    
    $("a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_rounded'});

     
    $("img[align='right']").css('float','right');
    $("img[align='left']").css('float','left');
    $("*[border='0']").addClass('nb');
    
   $(".accordcat").accordion({
         active: true,
         header: 'a.accordlink',  
         navigation: true,
         alwaysOpen: false, 
         autoHeight: false        
    });
    
    $(".accordme").accordion({
         active: false,
         header: 'a.accordlink',  
        
         alwaysOpen: false, 
         autoHeight: false        
    });
       
    
     // SPACER
  
    
    $('h2.art-cat').each(function(){
        font_replace('ottawa23', $(this));
    }); 
    $('h3.title').each(function(){
        font_replace('ottawa16', $(this));
    });   
    $('h3.title2').each(function(){
        font_replace('ottawa16_light', $(this));
    });  
    
  
  
// ACTIVE FUNCTIONS
    
      $("a[rel='email']").each(function(){
  		// Modify the mailto: value
  		var mailtoVal = $(this).attr('href');
  		mailtoVal = mailtoVal.replace("[email]","mailto:");
  		mailtoVal = mailtoVal.replace("[at]","@");
  		mailtoVal = mailtoVal.replace("[dot]",".");
  		// Auto-generate title tags for users
  		var mailtoTitle = mailtoVal.replace("mailto:","Email: ");
  		$(this).attr('title',mailtoTitle);
  		// onClick Event
  		$(this).click(function(){
  			window.location.href = mailtoVal;
  			return false;
  		});
  	});
    
  
    

  
   
  }); 
  
// PASSIVE FUNCTIONS  
function search_swap(option,text){
  var obj = $('#search_field');
 // alert(obj.val());
  if(option){
    if(obj.val()==text){
      obj.val('');
    }
  }else{
    if(obj.val()==''){
      obj.val(text);
    }
  }
}  

function font_replace(font, obj){
    if (fv > 0) {
        var w = parseInt(obj.css('width'));
        var h = parseInt(obj.css('height'))
        //var rel = obj.attr('rel');
        var tekst = obj.text();
        //alert(h);
        
        if (!w) 
            w = parseInt(obj.width());
        if (!w) 
            w = 220;
        if (!h) 
            h = parseInt(obj.height());
        if (!h) 
            h = 35;
        
       // alert(font+ ' , w:'+w + ', h: ' + h);
        var flash = "<object type='application/x-shockwave-flash' data='/public/flash/"+font+".swf' width='" + w + "' height='" + h + "'>";
        flash += "<param name='movie' value='/public/flash/"+font+".swf' />";
        flash += "<param name='flashvars' value='napis=" + tekst + "' />";
        flash += "<param name='wmode' value='transparent' />";
        flash += "<param name='salign' value='TL' /></object> ";
        //  alert(flash);
        obj.html(flash);
        
    }
}


function getBrowserVersion(){
  var browser=navigator.appName;
  var b_version=navigator.appVersion;
  var version=parseFloat(b_version);
  alert(b_version);
  return version;
  
}
function getFlashVersion(){ 
  // ie 
  try { 
    try { 
      // avoid fp6 minor version lookup issues 
      // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ 
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); 
      try { axo.AllowScriptAccess = 'always'; } 
      catch(e) { return '6,0,0'; } 
    } catch(e) {} 
    return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 
  // other browsers 
  } catch(e) { 
    try { 
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ 
        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; 
      } 
    } catch(e) {} 
  } 
  return '0,0,0'; 
} 
 
var fv = getFlashVersion().split(',').shift(); 
//getBrowserVersion();  
  //alert(version); 

