var last = 3;
var c = 0;

$(document).ready(function()
{
c = $('.ads-container div').length;
$("#search-bar").blur(function(){if( $(this).val() == '' ) { $(this).val('جستجو در سایت ...'); }});
$("#search-bar").focus(function(){if( $(this).val() == 'جستجو در سایت ...' ) {$(this).val('');}});
$("#search").submit(function(){ document.location.href = "http://www.takedel.com/search/" + $("#search-bar").val();return false;});
$("#search div.btn").click(function(){document.location.href= "http://www.takedel.com/search/" + $("#search-bar").val();});
$("a[href='http://www.takedel.com/contactus']").click(function(){window.open( $(this).attr("href") , "Contact" , "status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no ,width=400px,height=310px" );return false;});

$('.img').cycle({
fx:     'scrollRight', 
speed:   300, 
timeout: 6000,
pause: 1,
pager : '.bot'
});
$('.ads-container div').hide();
$('.ads-container div').eq( 0 ).show();
$('.ads-container div').eq( 1 ).show();
$('.ads-container div').eq( 2 ).show();
$('.ads-container div').eq( 3 ).show();
check();
$('.btn-l').click(function()
{
if( ( last + 1 ) < c )
{
last++;
var i = last - 4;
$('.ads-container div').eq( i ).hide();
$('.ads-container div').eq( last ).show();
check();
}
});
$('.btn-r').click(function()
{
if( ( last - 4 ) >= 0  )
{
last--;
var i = last - 3;
var j = last + 1;
$('.ads-container div').eq( i ).show();
$('.ads-container div').eq( j ).hide();
check();
}
});
});

function check()
{
if( ( c == last ) || ( ( c - 1 ) == last ) )
{
$('.btn-l').removeClass('ch');
if( ( c - last ) > 0 )
{
$('.btn-r').addClass('ch');
}  else
{
$('.btn-r').removeClass('ch');
}
}  else
if( last == 3 )
{
$('.btn-r').removeClass('ch');
if( c > last )
{
$('.btn-l').addClass('ch');
}  else
{
$('.btn-l').removeClass('ch');
}
}  else
{
$('.btn-l').addClass('ch');
$('.btn-r').addClass('ch');
}
}

function ChangeFontSize( Type )
{
   switch( Type )
   {
      case 0 : $( 'Content' ).style.fontSize = "11px";break
      case 1 : $( 'Content' ).style.fontSize = "12px";break
      case 2 : $( 'Content' ).style.fontSize = "13px";break
      case 3 : $( 'Content' ).style.fontSize = "14px";break
      case 4 : $( 'Content' ).style.fontSize = "15px";break
   };
};
function ChangeLineHeight( Size )
{
   switch( Size )
   {
      case 0 : document.getElementsByTagName( "p" )[1].style.margin="3px 0px";document.getElementsByTagName( "p" )[1].style.lineHeight="1.6em"; break;
      case 1 : document.getElementsByTagName( "p" )[1].style.margin="7px 0px";document.getElementsByTagName( "p" )[1].style.lineHeight="1.8em"; break;
      case 2 : document.getElementsByTagName( "p" )[1].style.margin="9px 0px";document.getElementsByTagName( "p" )[1].style.lineHeight="2em"; break;
   };
};
