﻿// JScript File
var jAjax =
{
    indexDisplays: Math.floor(Math.random()*1000)+100,
    indexSale: Math.floor(Math.random()*1000)+100,
    indexBuild: Math.floor(Math.random()*1000)+100,


    getProject : function(parentDiv,type,offset)
    {
        var tempIndex = 100;
    
       switch(type)
       {
       case 'forsale':
        jAjax.indexSale += offset;
        tempIndex = jAjax.indexSale;
       break;
       case 'displays':
        jAjax.indexDisplays += offset;
        tempIndex = jAjax.indexDisplays;
       break;
       case 'build':
        jAjax.indexBuild += offset;
        tempIndex = jAjax.indexBuild;
       break;
       default:
       break;
       }
       
       $(parentDiv + ' .content').html('<span class=\'centerText\'>Laddar projekt...</span>');
                             $.ajax
                             (
                             {
                              type: "GET",
                              url: "/BoendeFb/Templates/Pages/StartPageAjax/GetProject.aspx",
                              data:"index=" +tempIndex + "&type=" + type,
                          
                 success: function(xml)
                  {
                  if(xml.length > 600)
					return;
                $('#jqueryContainer').html('');  
                $('#jqueryContainer').hide();
                $('#jqueryContainer').append(xml);  
                         
                $(parentDiv +' .control .label').html('<a href=\''+$('#jqueryContainer').find('a').attr('href')+'\'>'+$('#jqueryContainer').find('span:first').text()+'</a>').hide().show();
                $(parentDiv+' .content').html('<a href=\''+$('#jqueryContainer').find('a').attr('href')+'\'><img src='+$('#jqueryContainer').find('img[class!=overlay]').attr('src')+' /></a>').hide().fadeIn('slow');
                  if($('#jqueryContainer').find('img[class=overlay]').length > 0)
                  {
               
                      $(parentDiv+' .content').append('<img src=\''+$('#jqueryContainer').find('img[class=overlay]').attr('src')+'\' class=\'overlay\' />');        
                     
                  }
             
                  
                   }
                  });
                  }
                  }

