/* - - - - - - - - - - - - - - - - - - - - - - -
 JavaScript
 20 June 2010 14:07:45
 HAPedit 3.1.11.111
 - - - - - - - - - - - - - - - - - - - - - - - */

function getADiv(_pid, _pid2, _type, _grp) {

if (!_pid) {return;}

if (_type == 1) { 
     
// Put an animated GIF image insight of content
  $('#catalogue').empty().html('<img src="js/loading.gif" />');

      $('#catalogue').load('index.php?option=com_content&task=view&id=126&Itemid=108&byclick=1&pid='+_pid + ' #catalog', function(response, status, xhr) {
 
 if (status == "error") { 
    var msg = "Sorry but there was an error: ";
    $("#error").html(msg + xhr.status + " " + xhr.statusText);
    }  
  else 
{   
         parseScript(document.getElementById('catalog').innerHTML,'catalogue');

}  
}); 
} 

else if (_type == 2) {
    
    //alert(_pid );
     //alert(_pid2 );
   _pid = _pid.replace(' ', '%20');
   _pid2 = _pid2.replace(' ', '%20');
   _pid = _pid.replace('+', '__yj21__');
   _pid2 = _pid2.replace('+', '__yj21__');
   _pid = _pid.replace('&', '__yj22__');
   _pid2 = _pid2.replace('&', '__yj22__');
   
// Put an animated GIF image insight of content
  $('#cbox').empty().html('<img src="js/loading.gif" />');
  $('#catalogue').empty().html('<img src="js/loading.gif" />');

    $('#thumbnails').load( 'index.php?option=com_content&task=view&id=125&Itemid=107&cat=' + _pid + '&sub=' + _pid2 + '&grp=' + _grp + ' #thumb2', function(response, status, xhr) {
 
 if (status == "error") { 
    var msg = "Sorry but there was an error: ";
    $("#error").html(msg + xhr.status + " " + xhr.statusText);
    } 
  else 
    {
       try {
              parseScript(document.getElementById('thumb2').innerHTML,'thumbnails');
        }
    catch(err)
        {
              alert(err);
              return;
        }

    // Load also the first item in this category
    try {
              var pid3 = document.getElementById('first').innerHTML;
              //alert(pid3);
        }
    catch(err)
        {     pid3 = 0;
              alert(err);
              return;
        }

// Put an animated GIF image insight of content

    $('#catalogue').load('index.php?option=com_content&task=view&id=126&Itemid=108&pid='+ pid3 + ' #catalog', function(response, status, xhr) { 
 
 if (status == "error") { 
    var msg = "Sorry but there was an error: ";
    $("#error").html(msg + xhr.status + " " + xhr.statusText);
    } 
  else { 

  try {
             parseScript(document.getElementById('catalog').innerHTML,'catalogue');
        }
    catch(err)
        {     pid3 = 0;
              alert(err);
              return;
        }

} 
});

// Put an animated GIF image insight of content
  //$('#thumbnails').empty().html('<img src="js/loading.gif" />');

    $('#hotthumb2').load('index.php?option=com_content&task=view&id=164&Itemid=148&cat=' + _pid + ' #hotthumb3', function(response, status, xhr) {
 
 if (status == "error") { 
    var msg = "Sorry but there was an error: ";
    $("#error").html(msg + xhr.status + " " + xhr.statusText);
    } 
});
}   
});
}

if (_type == '3') {
     
// Put an animated GIF image insight of content
  $('#applemenu').empty().html('<img src="js/loading.gif" />');

      $('#productmenu').load('index.php?option=com_content&task=view&id=155&Itemid=146&grp='+_pid + ' #productmenux', function(response, status, xhr) {
 
 if (status == "error") { 
    var msg = "Sorry but there was an error: ";
    $("#error").html(msg + xhr.status + " " + xhr.statusText);
    }  
  else 
{        // alert(document.getElementById('productmenu').innerHTML);
         //parseScript(document.getElementById('productmenu').innerHTML,'ignorethis');

}  
}); 
}  

else {return;}

}

//888888888888888888888888888888888888888888888888888888

function parseScript(_source, _div) {

    var source = _source;
    var scripts = new Array();
    var foundit =0;
    
    // Strip out tags
    while(source.indexOf("<scrept") > -1 || source.indexOf("</scrept") > -1) {
      var s = source.indexOf("<scrept");
      var s_e = source.indexOf(">", s);
      var e = source.indexOf("</scrept", s);
      var e_e = source.indexOf(">", e);
      
      // Add to scripts array
      scripts.push(source.substring(s_e+1, e));
      // Strip from source
      source = source.substring(0, s) + source.substring(e_e+1);
                        foundit =1;
    }

     if (!foundit) {
      while(source.indexOf("<SCREPT") > -1 || source.indexOf("</SCREPT") > -1) {
      var s = source.indexOf("<SCREPT");
      var s_e = source.indexOf(">", s);
      var e = source.indexOf("</SCREPT", s);
      var e_e = source.indexOf(">", e);
      
      // Add to scripts array
      scripts.push(source.substring(s_e+1, e));
      // Strip from source
      source = source.substring(0, s) + source.substring(e_e+1);
                        foundit =1;
    }

}      


                // Loop through every script collected and eval it

    for(var i=0; i<scripts.length; i++) {
      try {
              var browserName=navigator.appName; 
                                if (browserName=="Microsoft Internet Explorer")
                                    {           //window.execScript("alert('IE sucks')");
                                                window.execScript(scripts[i]);
                                      }
                                 else
                               {
                                    window.eval(scripts[i]);
                                
                               }                  
             }                   
      catch(ex) {
        // do what you want here when a script fails
      }
     }
                 
   

    // Return the cleaned source
    return;
  }


  //888888888888888888888888888888888888888888888888888888

  function reloadmenu()
  {
     var reload = document.getElementById('reloadby');
     if (!reload.value) {return;}
     location.href = 'index.php?option=com_content&task=view&id=127&Itemid=105&grp=' + reload.value;
  }
