/*Transforms all divs marked as iframes to iframes- 
this way all iframes are loaded after main DOM manipulation in order to avoid their reloading during manipulation */
function setIframes(){ 

  var isIE6=(navigator.userAgent.toLowerCase().indexOf('msie 6')!=-1);
  var isIE=(navigator.userAgent.toLowerCase().indexOf('msie')!=-1);

  var ifs=$(".iframe");

  for(var i=0; i<ifs.length; i++){
    var src=$(ifs[i]).text();
    var classes=$(ifs[i]).attr('class');

    /*checks for height set to parent object, in case that parent object doesn't have the height set, then it checks for height of parent to parent*/   
    var h='';
    var minus=0;
    var p=$(ifs[i]).parent();
    if($(p).attr('style')!=undefined){
      var s=$(p).attr('style');
      s=s.toLowerCase(); 
      if(s.indexOf('height:')==-1){
        minus=parseInt($(p).css('margin-top'))+parseInt($(p).css('margin-bottom'));
        var p=$(p).parent();
      }
    } else {
      minus=parseInt($(p).css('margin-top'))+parseInt($(p).css('margin-bottom'));
      var p=$(p).parent();
    }
  
    if($(p).attr('style')!=undefined){
      var s=$(p).attr('style');
      s=s.toLowerCase(); 
      if(s.indexOf('height:')!=-1){
        var h=$(p).height()-minus;
      }
    } 
 
    /*creates final iframe object*/
    $(ifs[i]).replaceWith('<iframe src="'+src+'" class="'+classes+'"'+(h!=''?' style="height:'+h+'px"':'')+' frameborder="0" scrolling="no"'+(isIE?' allowtransparency="true"':'')+'></iframe>');
     
  }
}