/*
function ret_name($s)
{
$s=preg_replace('/^\d+/','',$s);
$s=str_replace('[','',$s);
$s=str_replace(']','',$s);
$s=str_replace(' ','_',$s);
$s=str_replace('"','',$s);
$s=str_replace('`','',$s);
$s=str_replace("'",'',$s);
return $s;
}
*/
count_fades=0;
timer_fades=0;
timer_resizer=0;
scrollednews_timer=0;
scrolledanimatenews_timer=0;
//preload
cur1=new Image();
cur1.src='./i/left.cur';
cur2=new Image();
cur2.src='./i/right.cur';
cur3=new Image();
cur3.src='./i/right.png';
menus=new Image();
menus.src='./i/main_scroll.gif';
f_img=new Image();
b_img=new Image();
scrolled_timer='';
last_id_news=0;
ignore_next_scroll=false;
top_addthis=0;
var addthis_config = {
 /*services_custom: { 
              name: "more", 
              url: "http://www.addthis.com/bookmark.php?v=250&winname=addthis&pub=xa-4e860d0c53bff47b%23domready%3d1&source=men-250&lng=en&s=more&ate=AT-xa-4e860d0c53bff47b%23%23domready%3d1&url={{url}}&title={{title}}", 
              icon: "http://www.clearspring.com/favicon.png"},*/
   //services_expanded : 'facebook,twitter,linkedin,email,print,more',
   services_compact: 'twitter,facebook,linkedin,email,print,more',
   ui_language : 'en',
  // ui_click : true,
   ui_offset_top:top_addthis,
   ui_offset_left:-160
};

function news_fade()
{// alert(news_f);
	if (news_f==false || news_arr==false) return; //if disabled
if (document.getElementById('newsbox_main').style.display=='none') return;
 /* if (msie) 
 {
$('#newsfade_1').css({height:195});
$('#newsfade_2').css({height:195});
$('#newsfeed_fade').css({height:195});
 }*/
$('#newsfade_1').css({height:news_f[0].h});
$('#newsfade_2').css({height:news_f[0].h});
$('#newsfeed_fade').css({height:news_f[0].h});
 /* if (count_fades==0)
   {	
$('#newsfade_1').css({height:news_f[0].h});
$('#newsfade_2').css({height:news_f[0].h});
$('#newsfeed_fade').css({height:news_f[0].h});
  }*/
document.getElementById('newsfade_2').src=document.getElementById('newsfade_1').src;
/*$('#newsfade_2').css({height:$('#newsfade_1').css('height')});
$('#newsfade_1').css({height:news_f[count_fades].h});
$('#newsfeed_fade').css({height:news_f[count_fades].h});*/
$('#newsfade_1').show();
$('#newsfade_2').show();
$('#newsfade_1').css({opacity:0});
  if (news_f[count_fades].u!='')
   {
   	   temp_url_fade=news_f[count_fades].u;
   	 if (news_f[count_fades].u.indexOf('subplot')==-1)
   document.getElementById('newsfade_1').onclick=function() { window.open(temp_url_fade);};
     else
   document.getElementById('newsfade_1').onclick=function() { window.location=temp_url_fade;};
   }
  else
   document.getElementById('newsfade_1').onclick="";
document.getElementById('newsfade_1').src='./cms/data/NEWS FEATURE BOX/images/'+news_f[count_fades].i;
$('#newsfade_1').animate({opacity:1},1200);
count_fades++;
if (count_fades>news_f.length-1 || news_f[count_fades].i=='undefined') count_fades=0;
//alert(news_f.length-1+ ' '+count_fades);
next_fade=new Image();
next_fade.src='./cms/data/NEWS FEATURE BOX/images/'+news_f[count_fades].i;
}
function change_quote()
{
if (!last_quote ) last_quote=0;
$('#text_title_top').animate({opacity:0},299,function(){
document.getElementById('text_title_top').innerHTML=quotes[last_quote];
last_quote++;
if (last_quote>quotes.length-1) last_quote=0;
$('#text_title_top').animate({opacity:1},300);
});



  if (last_quote>quotes.length-1) last_quote=0;
//window.setTimeout("change_quote()",5000);
}
function act_top_addthis()
{
	return;
if (document.getElementById("all_news_box"))
top_addthis=-parseInt(document.getElementById("all_news_box").scrollTop); //top_addthis=0;	
	act_addthis();
}
function act_addthis()
{ 
var script = 'http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4e860d0c53bff47b#domready=1';
if (window.addthis){
    window.addthis = null;
}
$.getScript( script );
 //addthis_share = {url:window.location,title:window.title};
}
function feat_addthis()
{
$("#add_featurebox").attr("addthis:url",window.location);
if (window.addthis)
{
window.addthis.ost = 0;
window.addthis.ready();
}
else act_addthis();
//act_addthis();
/*
window.addthis.ost = 0;
window.addthis.ready();*/	
}
function ret_name(s)
{
s=s.replace(/^\d+/,'');
s=s.replace('[','');
s=s.replace(']','');
s=s.replace('&','');
s=s.replace(/ /g,'_');
s=s.replace(/\"/g,'');
s=s.replace(/`/g,'');
s=s.replace(/\'/g,'');
return s;	
}
//arrows for devices
function arrows_dev()
{
if (!ipad && !iphone) return; //alert('321');
   if (last_ind!=0 && !last_about)
$('#arrows_mobilel').show();
    else $('#arrows_mobilel').hide();

if (last_mainsect[last_ind_plit].sub.length!=1 || (last_mainsect[last_ind_plit].sub.length-1>last_ind || last_about))
      $('#arrows_mobiler').show();
    else $('#arrows_mobiler').hide();
    
}
//cursors for image\video
function curs_im(e,id)
{
var obj = document.getElementById(id).getBoundingClientRect();
var left = obj.left-parseInt($(document.body).scrollLeft());
var clientx=e.clientX-window.pageXOffset;
var left = obj.left;
//  if (parseInt(document.getElementById(id).offsetHeight)+169-parseInt(e.clientY)<40) 
  if (left+730-parseInt(e.clientX)<17) 
   {
   document.getElementById(id).style.cursor='default';
   return;
   } //alert(left+' '+e.clientX)
             
                       
if ((e.clientX-left+20)/parseInt(730)<0.5)
{
   if (last_ind!=0 && !last_about)
document.getElementById(id).style.cursor='url(i/left.cur), e-resize';
    else document.getElementById(id).style.cursor='default';
}
else if (last_mainsect[last_ind_plit].sub.length!=1 || last_mainsect[last_ind_plit].sub.length-1>last_ind || last_about)
       document.getElementById(id).style.cursor='url(i/right.cur), w-resize';
    else document.getElementById(id).style.cursor='default';
}
//click on image\video
function im_click(e,id)
{
  if (!e) e = window.event;
  var t = e.target || e.srcElement;
//	$('#'+id).addClass('unselectable');
var obj = document.getElementById(id).getBoundingClientRect();
var left = obj.left-parseInt($(document.body).scrollLeft());

var clientx=e.clientX;
var clienty=e.clientY;
 if (ipad || iphone)
  {
 var clientx=e.clientX-window.pageXOffset;
var left = obj.left;
 } //alert(t.href);
 else
 {
 var clientx=e.clientX-window.pageXOffset;
var left = obj.left-window.pageXOffset;
 }
 if (msie) 
 {
 var clientx=e.clientX;
var left = obj.left;	 
 }
    document.getElementById(id).style.cursor='default';
 	if (t.href && t.href!='undefined') { return true;}
//if click arrows
if (id=='arrows_mobilel') { left=150; clientx=157; }
if (id=='arrows_mobiler') { left=150; clientx=829; }
//alert(parseInt($(document.body).scrollLeft())+' '+obj.left+' '+parseInt(clientx));
  if (left+730-parseInt(clientx)<17) 
   {
   return false;
   } 
 //  if (event) event.preventDefault(); 
   document.getElementById(id).style.cursor='default';
	if ((clientx-left+20)/parseInt(730)<0.5) //left arrow
	{    if (last_ind==0 || last_about) return false;
	if (last_about) var temp_ind=last_mainsect[last_ind_plit].sub.length-1;  //var temp_ind=0;
	else temp_ind=parseInt(last_ind)-1;
	draw_section(last_mainsect,temp_ind,last_ind_plit,'left',false,true);
	//alert($('#main_div').css('scrollLeft'));
//	if (document.getElementById('fbox_main_div'))
	//$('#fbox_main_div').animate({opacity:0}, 500);
	$('#arrows_mobilel').hide();
    $('#arrows_mobiler').hide();
		if (document.getElementById('fbox_main_div_temp'))
$('#fbox_main_div_temp').animate({opacity:1}, 750, function() {
	 /*$('#fbox_main_div').hide();
	 $('#fbox_main_div_temp2').hide();
	 $('#fbox_main_div').attr('id','');
	 $('#fbox_main_div_temp').attr('id','f_box_main_div');*/
	 ignore_url=false; 
	 ignore_next_scroll=true;
     window.location='#'+ret_name(last_mainsect[last_ind_plit].owner)+'/'+ret_name(last_mainsect[last_ind_plit].t)+'/'+(last_ind)+'/'
window.setTimeout("arrows_dev();",80);
	window.setTimeout("feat_addthis();",60);
});
	}
	else //right arrow
	{  //if (!(last_mainsect[last_ind_plit].sub.length-1>last_ind || last_about)) return false;
	if (last_about) var temp_ind=0;
	else temp_ind=parseInt(last_ind)+1; //alert(temp_ind);
	if (!(last_mainsect[last_ind_plit].sub.length-1>last_ind || last_about)) var temp_ind=0;
	 draw_section(last_mainsect,temp_ind,last_ind_plit,'right',false,true);
            /*	if (safar)
       		 {
       	   f_img=new Image();
       	   f_img.src=last_mainsect[last_ind_plit].sub[temp_ind].pic;
       	     }*/
  //  	if (document.getElementById('fbox_main_div'))
//	$('#fbox_main_div').animate({opacity:0}, 500);
			if (document.getElementById('fbox_main_div_temp2'))
			 {
	$('#arrows_mobilel').hide();
    $('#arrows_mobiler').hide();
$('#fbox_main_div_temp2').animate({opacity:1}, 750, function() {
	// $('#fbox_main_div').hide();
	/* $('#fbox_main_div').attr('id','');
	 $('#fbox_main_div_temp').hide();
	 $('#fbox_main_div_temp2').attr('id','f_box_main_div');
	 	 $('#fbox_main_div').show();
	 	  $('#fbox_main_div').css({opacity:1});*/
	 ignore_next_scroll=true;
	 	  draw_section(last_mainsect,temp_ind,last_ind_plit,false,false,true);
arrows_dev();
	 ignore_url=true; 
     window.location='#'+ret_name(last_mainsect[last_ind_plit].owner)+'/'+ret_name(last_mainsect[last_ind_plit].t)+'/'+(last_ind)+'/';
	window.setTimeout("feat_addthis();",60);
     //ignore_url=false; 
});
		    }
	}
return false;
}

function draw_section(mainsect,ind,ind_plit,direction,about_bool,addbool) //draw featurefox and title box
{
var path_main=ret_name(mainsect[ind_plit].owner)+'/'+ret_name(mainsect[ind_plit].t)+'/';
var s='';
//TOP
 if (mainsect[ind_plit].sub[ind].title_plate && mainsect[ind_plit].sub[ind].title_plate!='') //all slide in section may contain the title of featurebox
 	 var temp_title=mainsect[ind_plit].sub[ind].title_plate;
 else if (mainsect[ind_plit].sub[0].title_plate) var temp_title=mainsect[ind_plit].sub[0].title_plate;
      else temp_title='';

var top_table='<table class="fbox_title_box" cellpadding="0px" cellspacing="0px"><tr><td valign="bottom"><div id="fbox_title_left">'+temp_title+'</div></td><td valign="bottom"><div id="fbox_title_right"><span id="fbox_title_r">';
var about='';
//contain about?
//if (mainsect[ind_plit].sub[0].about && mainsect[ind_plit].sub[0].about!='') 
var temp=mainsect[ind_plit].sub.length-1;
if (mainsect[ind_plit].sub[temp].about && mainsect[ind_plit].sub[temp].about!='')
 if (about_bool || (ind==mainsect[ind_plit].sub.length-1)) 
  var about='<a style="color:#ffffff;" href="#" onclick="return false;">about</a>';
 else
 var about='<a href="#'+path_main+temp+'/about/">about</a>';
 
 //addthis button
// $('#add_featurebox').attr('id','');
//about='<a id="add_featurebox" class="addthis_button_expanded" addthis:url="'+window.location.host+window.location.pathname+window.hash+'" href="http://www.addthis.com/bookmark.php?v=250&amp;pubid=xa-4e860d0c53bff47b">share<img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="1" height="1" alt="Bookmark and Share" style="border:0;opacity:0.01"/></a>'+about;

//contain title?
var temp_title=about;
  if (mainsect[ind_plit].sub[0].title && mainsect[ind_plit].sub[0].title!='')  
   { temp_title=temp_title+'<span style="margin-left:17px;">';
     for (var i=0; i<mainsect[ind_plit].sub.length;i++)
     {
     var temp='';
     if (i==ind && about_bool==false) temp='color:#ffffff;';
     temp_title=temp_title+'<a style="margin-left:0px; !important;'+temp+'" href="#'+path_main+i+'/">'+mainsect[ind_plit].sub[i].title+'</a>'; 
      if (i!=mainsect[ind_plit].sub.length-1 && !(i==mainsect[ind_plit].sub.length-2 && mainsect[ind_plit].sub[i].about && mainsect[ind_plit].sub[i].about!=undefined )) temp_title=temp_title+'<div style="display:inline;color:#ffffff;margin-left:8px;margin-right:8px;">/</div>';
     }
     temp_title=temp_title+'</span>';
   }
  else
   { 
     if (mainsect[ind_plit].sub.length!=1) 
     {
var temp2=mainsect[ind_plit].sub.length-1;
   	if ((!about_bool || about_bool==false) && (!mainsect[ind_plit].sub[ind].about || mainsect[ind_plit].sub[ind].about=='')) var temp=' style="color:#ffffff;"'; else var temp='';
    if (mainsect[ind_plit].sub[ind].about && mainsect[ind_plit].sub[ind].about!='')  
         var temp4=parseInt(ind);
    else var temp4=(parseInt(ind)+1);
    if (mainsect[ind_plit].sub[temp2].about && mainsect[ind_plit].sub[temp2].about!='')  
          var temp3=(mainsect[ind_plit].sub.length-1);
    else  var temp3=(mainsect[ind_plit].sub.length);
    temp_title=temp_title+'<a'+temp+' href="#'+path_main+parseInt(temp4-1)+'/">'+temp4+' of '+temp3+'</a>';
     }
   }
temp_title=temp_title+'</span>';

//if (mainsect.length>8) //thumbnails button
temp_title=temp_title+'<img id="grid" src="./i/grid.png" onmouseover="grid_over(this,\'over\')" onmouseout="grid_over(this,\'out\')"  onclick="grid_over(this,\'click\')" />';
 
 //addthis button
 $('#add_featurebox').attr('id','');
var addthis_button='<a id="add_featurebox" class="addthis_button" addthis:url="'+window.location+'" href="http://www.addthis.com/bookmark.php?v=250&amp;pubid=xa-4e860d0c53bff47b"><img src="./i/share_buttons2.png" width="100" height="27" alt="Bookmark and Share" id="feature_add_this" style="border:0;"/></a>';

top_table=top_table+temp_title+'</div></td></tr><tr><td height="10px"></td></tr></table>'+addthis_button;
//END OF TOP
//MIDDLE
      var temp_bg='';
       if (mainsect[ind_plit].sub[ind].pic && mainsect[ind_plit].sub[ind].pic!='')
        temp_bg='style="background: #ffffff url(\''+mainsect[ind_plit].sub[ind].pic+'\')"';
       var temp_txt='';
     /*   if (about_bool) 
        {  
        temp_txt=mainsect[ind_plit].sub[0].about;
        temp_bg='style="background:url(\''+mainsect[ind_plit].sub[0].pic2+'\')"'; 
        }
        else    */        temp_txt=mainsect[ind_plit].sub[ind].text
        	if (temp_bg=='style=" #ffffff background:url(\'\')"') temp_bg=''; 
if (!direction) var temp_id='fbox_main_div'; else 
  if  (direction=='left') var temp_id='fbox_main_div_temp';
  else var temp_id='fbox_main_div_temp2';
var middle_table='<div class="fbox" id="'+temp_id+'" onmousemove="curs_im(event,this.id)"  onclick="return im_click(event,this.id)"  '+temp_bg+'>'+temp_txt+'</div>';
//END OF MIDDLE
//BOTTOM
var bottom_table='<div class="thumbmainbox">';
var i2=4;
if (!ipad && !iphone) var preloar_thumb=new Array();
     for (var i=0; i<mainsect.length;i++)
     { 
     	if (!ipad && !iphone) //preloader thumb
         {
preloar_thumb[i]=new Image();
preloar_thumb[i].src=mainsect[i].pic2;
         }
     	 if (i2!=4 /*&& i!=ind_plit*/)
     	  {
     	  	   bottom_table=bottom_table+'<div class="spacer"></div>';
     	  } //alert(ind_plit);
   /*  if (i!=ind_plit)
       {*/
      if (i2==4) i2=0;
      i2++;
      var temp_bg='style="background-color:#ffffff";height:131px;width:175px;';
       if (mainsect[i].pic && mainsect[i].pic!='')
    temp_bg=' style="background:url(\''+mainsect[i].pic+'\');height:131px;width:175px;" ';
            if (i==ind_plit)   temp_bg=' style="background:url(\''+mainsect[i].pic2+'\') !important;height:131px;width:175px;" ';
     //       else temp_bg=temp_bg+'"'; //alert(temp_bg);
          var pic=mainsect[i].pic.replace(/ /g, '%20');
          var pic2=mainsect[i].pic2.replace(/ /g, '%20');
      bottom_table=bottom_table+'<div onclick=\'grid_over("openit","click");window.location="#'+ret_name(mainsect[ind_plit].owner)+'/'+ret_name(mainsect[i].t)+'/'+'";\' class="thumbbox" style="background-color:#000000"><div class="thumb_ov" '+temp_bg+' onmouseover=\'$(this).css("backgroundImage", "url('+pic2+')")\' onmouseout=\'$(this).css("backgroundImage", "url('+pic+')")\'></div><span onmouseover=\'$(this).parent().children().eq(0).css("backgroundImage", "url('+pic2+')")\' onmouseout=\'$(this).parent().children().eq(0).css("backgroundImage", "url('+pic+')")\'>'+mainsect[i].t+'</span></div>';
    /*   }*/
     } 
bottom_table=bottom_table+'</div>'; 
//END OF BOTTOM
if (safar) bottom_table+='&nbsp;';
//top_table='<img src="./i/right.png" id="right_image" />'+top_table;
  if (direction==false)
   {
if (document.getElementById('content_div'))
{
//document.getElementById('content_div').innerHTML='';
document.getElementById('content_div').innerHTML='<div id="main_table" style="width:730px;min-width:730px;">'+top_table+'</div><div id="scroller_gal"><div id="main_div">'+middle_table+'<img src="./i/right.png" id="right_image" /><img src="./i/arrowsformobiler.png" id="arrows_mobiler"  onclick="return im_click(event,this.id)" /><img src="./i/arrowsformobilel.png" id="arrows_mobilel"  onclick="return im_click(event,this.id)" />'+'</div><div id="main_bottom">'+bottom_table+'</div></div>';
act_addthis();
	$('#arrows_mobilel').hide();
    $('#arrows_mobiler').hide();
window.setTimeout("arrows_dev();",20);
}
          
             /*   $(".thumb_ov").click(function() {
 $(this).css({opacity:1});
                });*/
                /*
$('.thumb_ov').bind('mouseover',function(){
 $(this).css({opacity:1});
 //grayscale.reset($(this));
 }); 
 $('.thumbbox span').bind('mouseover',function(){
 $(this).parent().children().eq(0).css({opacity:1});
  //grayscale.reset($(this).parent().children().eq(0));
 }); 
$('.thumb_ov').bind('mouseout',function(){
	if ($(this).attr('id')=='filter_ie_op') return; //fix ie bug
// grayscale($(this));
 $(this).css({opacity:0.15});

 });
 $('.thumbbox span').bind('mouseout',function(){
 	 	if ($(this).attr('id')=='filter_ie_op') return; //fix ie bug
 //grayscale($(this).parent().children().eq(0));
$(this).parent().children().eq(0).css({opacity:0.15});
 });                 */
 
  if (msie) //23:50 03.07.2011 fix ie bug,
  {
  // i_resize();
  	//  $('#main_table').css({height:'auto'});
  	    	 // $('#main_table').show();
 // $('.thumb_ov').css({height:131,top:44});
  //$('#main_bottom').css({width:'auto'});
  }
   }
 else   if (direction=='left' || direction=='right') 
        {
document.getElementById('main_table').innerHTML=top_table;
act_addthis();
 if (addbool) 
 {
 	 if (direction) document.getElementById('main_div').innerHTML+=middle_table;
 /*if (direction=='right') document.getElementById('main_div').innerHTML+='<div style="position:relative;top:-421px;left:730px;float:right !important;">'+middle_table+'</div>';
 if (direction=='left')
  { 
 document.getElementById('main_div').innerHTML=middle_table+'<div style="position:relative;top:-421px;left:730px;float:right !important;">'+document.getElementById('main_div').innerHTML+'</div>';	 
  //document.getElementById('main_div').innerHTML+='<div style="position:relative;top:-421px;left:730px;float:right !important;">'+middle_table+'</div>';
  $('#main_div').scrollLeft(730);
 // document.getElementById('main_div').scrollLeft='730px';
  }*/
 }
 else document.getElementById('main_div').innerHTML=middle_table;
 // document.getElementById('main_div').innerHTML+=middle_table;
        }
last_mainsect=mainsect;
last_ind=ind;
last_ind_plit=ind_plit;
last_about=about_bool;
i_resize();
//if (!ipad && !iphone)
if (/*$('#main_div').css('opacity')!=1 ||*/ !document.getElementById('main_div') || document.getElementById('main_div').style.display=='none' || document.getElementById('main_div').style.display=='') time_scrolled=1100; else time_scrolled=100;
if ( (direction=='left' || direction=='right')) time_scrolled=100;
if ( ignore_next_scroll==true) time_scrolled=1;
//alert(direction);
//alert($('#main_div').css('opacity')+' '+document.getElementById('main_div').style.display+' '+time_scrolled);
window.clearTimeout(scrolled_timer);
//if (ignore_next_scroll==true)
$('.fbox_type7, .fbox_type14, .fbox_type19').css({overflow:'hidden'});
scrolled_timer=window.setTimeout(function() {
	$('.fbox_type7, .fbox_type14, .fbox_type19').css({overflow:'auto'});
$('.fbox_type7, .fbox_type14, .fbox_type19').jScrollPane({verticalDragMinHeight: 252,verticalDragMaxHeight: 252,showArrows:false});
},time_scrolled);
ignore_next_scroll=false;
//gray
/*
window.setTimeout(function() {
grayscale($('.thumbbox'));
grayscale.reset($('#filter_ie_op'));
},100);*/
//cache
     if (mainsect[ind_plit].sub[ind+1] && mainsect[ind_plit].sub[ind+1].pic && mainsect[ind_plit].sub[ind+1].pic!='')
      {
       f_img=new Image(); 
       f_img.src=mainsect[ind_plit].sub[ind+1].pic;
	 }
     if (mainsect[ind_plit].sub[ind-1] && mainsect[ind_plit].sub[ind-1].pic && mainsect[ind_plit].sub[ind-1].pic!='')
      {
       b_img=new Image(); 
       b_img.src=mainsect[ind_plit].sub[ind-1].pic;
	 }
  if (ipad || iphone)
  {
  	 
  	  /*
$('.fbox_type7').bind('touchstart', function (evt) {
	alert('');
if(evt.touches.length == 1)
				{
         var touch = evt.touches[0];
         dragging=touch.pageY;
   
          }
});
$('.fbox_type7').bind('touchmove', function (evt) {
 	 evt.preventDefault();
				if(evt.touches.length == 1)
				{
         var touch = evt.touches[0];
         //this.scrollTop=-(touch.pageY-dragging)+this.scrollTop;
         var temptop=$(this).scrollTop();
         $(this).scrollTop(-(touch.pageY-dragging)+temptop);
         dragging=touch.pageY;
				}
});
*/
  }
/*
 document.getElementById('touchme').ontouchstart= function(e){
if(e.touches.length == 1)
				{
         var touch = e.touches[0];
         dragging=touch.pageX;
          }
 }
 document.getElementById('touchme').ontouchmove= function(e){
 	 e.preventDefault();
				if(e.touches.length == 1)
				{
         var touch = e.touches[0];
         document.getElementById('touchme').scrollLeft=-(touch.pageX-dragging)+document.getElementById('touchme').scrollLeft;
         dragging=touch.pageX;
				}
			} 	  
			*/

return;
//document.getElementById('content_div').innerHTML='<textarea>'+top_table+middle_table+bottom_table+'</textarea>';
 /*if (direction)
  {
	if (direction=='right')
	 {
$('#fbox_main_div').hide("slide", { direction: "left" }, 1000);
$('#fbox_main_div').show("slide", { direction: "right" }, 1000);
 	 }
	if (direction=='left')
	 {
$('#fbox_main_div').hide("slide", { direction: "right" }, 1000);
$('#fbox_main_div').show("slide", { direction: "left" }, 1000);
 	 }
  }*/
}
function print_news(category,it)
{
var show_one=false;
  if (category.substr(0,4)=='news' && category.substr(4,99)==parseInt(category.substr(4,99))) show_one=true;
//  alert(parseInt(category.substr(4,99)));
  if (news_arr==false) return;
document.getElementById("all_news_box").scrollTop=0;
var s='';
var first=true;
 for (var i=0; i<news_arr.length;i++)
  {
   if (category=='all' || news_arr[i].cat.indexOf('|'+category)!=-1
   	   || (show_one && parseInt(category.substr(4,99))==news_arr[i].myid) /*not optimal code, i know, but simply and clever*/
   	   // || (category=='random' && Math.random()>0.5)
   	   )
    { 
if (first) { last_id_news=news_arr[i].myid; first=false};  // define id of first news for scroll and location
  if (news_arr[i].pic) 
  {
   if (news_arr[i].pic.toLowerCase().indexOf('.png')<1)
    var pic='<center><img class="news_image" src="'+news_arr[i].pic+'" onclick="show_one_news_2(this,\'image\')" /></center>';
   else
    var pic='<img class="news_image2" src="'+news_arr[i].pic+'" onclick="show_one_news_2(this,\'image2\')" />';
   }
   else var pic='';
//<!--<span class="news_date">'+news_arr[i].d+'</span><br />-->
s+='<div class="news" idnews="'+news_arr[i].myid+'">'+pic+'<div class="news_title"><span onclick="show_one_news_2(this,\'image\')">'+news_arr[i].t+'</span><br /><a href="#open" class="news_shower" idnews="'+news_arr[i].myid+'" onclick="return show_one_news(this,'+news_arr[i].myid+')">read more</a></div><div class="news_text">'+news_arr[i].txt+'<br><a style="margin-top:5px;margin-bottom:21px;display:block;width:100px;" class="addthis_button_expanded addthis_button"  addthis:url="'+window.location.host+window.location.pathname+'#newsfeed/news'+news_arr[i].myid+'/" href="http://www.addthis.com/bookmark.php?v=250&amp;pubid=xa-4e860d0c53bff47b"><img src="./i/share_buttons1.png" width="100" height="20" alt="Bookmark and Share" style="border:0" /></a><a href="#close" class="news_closer" onclick="return hide_one_news2(this,'+i+');">close</a></div><img class="line_news" src="./i/dotted_line.png" /></div>';
/*
	s+='<div class="news" idnews="'+news_arr[i].myid+'">'+pic+'<div class="news_title"><span onclick="show_one_news_2(this,\'image\')">'+news_arr[i].t+'</span><br /><a href="#open" class="news_shower" idnews="'+news_arr[i].myid+'" onclick="return show_one_news(this,'+news_arr[i].myid+')">read more</a></div><div class="news_text">'+news_arr[i].txt+'<br><a style="margin-top:5px;margin-bottom:21px;display:block;" class="addthis_button_expanded"  addthis:url="'+window.location.host+window.location.pathname+'#newsfeed/news'+news_arr[i].myid+'/" href="http://www.addthis.com/bookmark.php?v=250&amp;pubid=xa-4e860d0c53bff47b"><img src="./i/share_buttons1.png" width="100" height="20" alt="Bookmark and Share" style="border:0" /></a><a href="#close" class="news_closer" onclick="return hide_one_news2(this,'+i+');">close</a></div><img class="line_news" src="./i/dotted_line.png" /></div>';
*/
    }
     if (it) 
      {
      last_cat_news=it.innerHTML;
      document.getElementById('menu_news_title').innerHTML=it.innerHTML;
      }
     else
      {
      document.getElementById('menu_news_title').innerHTML='SORT: ALL NEWS';
      last_cat_news='ALL NEWS';
      }
     if (parseInt($('#menu').css('height'))>20) show_news();
  }
s+='<div style="width:100% !important;height:30px !important;" class="line_news">&nbsp;</div>';
document.getElementById('all_news_box').innerHTML='<div style="width:341px;min-width:341px;">'+s+'</div>';
  if (show_one)
   {
$('.news_shower').hide();
$('.news_closer').hide();
$('.news_text').show();
   }
act_addthis();
window.setTimeout('act_addthis()',100);
  // document.getElementById('addthisw').src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4e860d0c53bff47b";
i_resize();
/*  <div class="news">
  <img class="news_image" src='temp_news1.jpg' />
    <div class="news_title">
<span class="news_date">01/06/2011</span>
<br />Level Ground Trading wins "Outstanding" top honours with HOW Internetional Awards. <a href="#open" class="news_shower" onclick="return show_one_news(this)">read more</a>
    </div>
   <div class="news_text">
Aquo et, que quodio doluptas entorpo restia ilit etustis as soluptio. Os ressuatat. Aquo et, que quodio doluptas entorpo restia ilit etustis as soluptio. Os ressuatat. Aquo et, que quodio doluptas entorpo restia ilit etustis as soluptio. Os ressuatat. Aquo et, que quodio doluptas entorpo restia ilit etustis as soluptio. Os ressuatat. <a href="#close" onclick="return hide_one_news(this)">close</a>
   </div>
<img class="line_news" src="./i/line_news.gif" />
  </div>*/
}
function show_one_news_animate(it,newsid)
{
var temp_object=$(it).parent().parent().prev().find('.line_news');
var temp_open=$(it).parent().next();
  if(!iphone && !ipad && temp_object.hasClass('line_news')) 
  {
    $('#all_news_box').scrollTo( temp_object, 400);
  window.setTimeout(function(){temp_open.show(600);});
 }
  else
  {
   $(it).parent().next().show(600);
  window.setTimeout(function(){$(it).hide();},400);
  }
  $(it).hide();
window.clearTimeout(scrolledanimatenews_timer);
var temp_func2=function(){ignore_url=true; $(it).hide();
window.location='#newsfeed/news'+newsid+'/';
//window.setTimeout("act_addthis();",100);
//document.getElementById('addthisw').src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4e860d0c53bff47b";
 };

scrolledanimatenews_timer=window.setTimeout(temp_func2,1000);
 if (msie) //23:28 03.07.2011 fix ie bug, don`t now khow, but any way it work.
  {
  $('#main').hide();
  $('#main').css({width:1280});
  $('#main').show();
  $('#main').css({width:'auto'});
  }
}
function show_one_news(it,newsid)
{
 if (it.innerHTML!='read more') return false;

  if (hide_one_news(false)==true) //2:07 14.06.2011
   {
window.clearTimeout(scrollednews_timer);
var temp_func=function(){show_one_news_animate(it,newsid); };
scrollednews_timer=window.setTimeout(temp_func,600);
   }
   else
   {
show_one_news_animate(it,newsid);
   }
//$(it).hide(); 

//$(it).parent('.news_title').addClass('news_title_act');
 if (msie) //23:28 03.07.2011 fix ie bug, don`t now khow, but any way it work.
  {
  $('#main').hide();
  $('#main').css({width:1280});
  $('#main').show();
  $('#main').css({width:'auto'});
  }
/*$(it).parent().next().css({opacity:0});
$(it).parent().next().show();
$(it).parent().next().animate({opacity:1},300);*/
//$(it).css({opacity:0});


//$(it).click(function(){return show_one_news(this)}); //jq some bug
return false;
}
function show_one_news_2(it,com)
{
	if ( !(ipad || iphone) ) return;
if (com=='image') var i_vis=$(it).parent().nextAll('.news_text:first').css('display');
if (com=='image2') var i_vis=$(it).nextAll('.news_text:first').css('display');
 //hide_one_news(false); //2:07 14.06.2011
  if (com=='image' && i_vis=='none') 
    { 
   $(it).parent().children('.news_shower').hide(); 
   $(it).parent().next().children('.news_shower').hide(); 
   $(it).parent().nextAll('.news_text:first').show(600,function() {
  // 	var temp_object=$(it).parent().prev().find('.line_news'); 
   // if(temp_object) $('#all_news_box').scrollTo( temp_object, 200);
   });
    }
  if (com=='image2' && i_vis=='none') 
   { 
   $(it).parent().children('.news_shower').hide(); 
   $(it).next().children('.news_shower').hide(); 
   $(it).nextAll('.news_text:first').show(600);  
//   	var temp_object=$(it).prev().find('.line_news');
   // if(temp_object) $('#all_news_box').scrollTo( temp_object, 200);
   }
//$(it).parent('.news_title').addClass('news_title_act');
 if (msie) //23:28 03.07.2011 fix ie bug, don`t now khow, but any way it work.
  {
  $('#main').hide();
  $('#main').css({width:1280});
  $('#main').show();
  $('#main').css({width:'auto'});
  }
return false;
}
function hide_one_news(it,scrollme)
{ if (it==false) return false;
	$('.news_shower').show();
	if ($('.news_shower').parent().next().is(':visible')==true) 
	{
	 var bool_vis=true;
	 if (scrollme)
	 {
	 	 var temp_object=$(it).parent().parent().prev().find('.line_news');
	 	 if (temp_object.is(':visible')==false) temp_object=$(it).parent().parent();
	 	if (ipad || iphone) $('.news_shower').parent().next().hide(600);
	 	else
	 	 $('#all_news_box').scrollTo( temp_object, 200,function(){
	 	 $('.news_shower').parent().next().hide(600);
	 	 });
	 /*$('.news_shower').parent().next().hide(600,function(){
	 var temp_object=$(this).parent().find('.line_news');
       if(!iphone && !ipad && temp_object.hasClass('line_news')) $('#all_news_box').scrollTo( temp_object, 200);
     });*/
     }
     else
       {
        /* var temp_object=$('.news_shower:visible').parent().next().find('.line_news');
		 if (temp_object.is(':visible')==false) temp_object=$('.news_shower:visible').parent().next();
	  	  $('#all_news_box').scrollTo( temp_object, 200,function(){*/
	 $('.news_shower').parent().next().hide(600,function(){
	 var now_scroll=parseInt(document.getElementById("all_news_box").scrollTop);
	 document.getElementById("all_news_box").scrollTop=document.getElementById("all_news_box").scrollTop+1;
	                                                    });
	                                                      /*    });*/
	  }
	}
	else
	 {
      var bool_vis=false;
	 }
 if (ipad || iphone) var bool_vis=false;
 if (msie) //23:28 03.07.2011 fix ie bug, don`t now khow, but any way it work.
  {
  $('#main').hide();
  $('#main').css({width:1280});
  $('#main').show();
  $('#main').css({width:'auto'});
  }
	return bool_vis;
}

function hide_one_news2(it)
{ 
$(it).parent().parent().find('.news_shower').show();
	 	 var temp_object=$(it).parent().parent().prev().find('.line_news');
	 	 if (temp_object.is(':visible')==false) temp_object=$(it).parent().parent();
	 	if (ipad || iphone) 
	 	     {
//	$(it).parent().parent().find('.news_shower').parent().next().hide(600);
      //  $('#main').hide();
    // if (e) e.preventDefault(); 
	 	$(window).scrollTo( temp_object,10, {'axis':'y'}/*,function(){ //$('#main').show();
	 	
	 	 }*/
	 	 );
$(it).parent().parent().find('.news_shower').parent().next().hide(600);
	 	     }

	 	else
	 	 $('#all_news_box').scrollTo( temp_object, 200,function(){
	 	 $(it).parent().parent().find('.news_shower').parent().next().hide(600);
	 	 });
 if (msie) //23:28 03.07.2011 fix ie bug, don`t now khow, but any way it work.
  {
  $('#main').hide();
  $('#main').css({width:1280});
  $('#main').show();
  $('#main').css({width:'auto'});
  }
return false;
}

/*
function hide_one_news(it,scrollme)
{
	$('.news_shower').show();
	//$('.news_title').removeClass('news_title_act');
		if (scrollme)
		$(it).parent().hide(600,function(){
		var temp_object=$(this).parent().find('.line_news');
       if(!iphone && !ipad && temp_object.hasClass('line_news')) $('#all_news_box').scrollTo( temp_object, 200);
	 });
	 else 
	  $('.news_shower').parent().next().hide(600);
 if (msie) //23:28 03.07.2011 fix ie bug, don`t now khow, but any way it work.
  {
  $('#main').hide();
  $('#main').css({width:1280});
  $('#main').show();
  $('#main').css({width:'auto'});
  }
	return;
	if (scrollme)
		$(it).parent().hide(300,function(){
		var temp_object=$(this).parent().prev().prev();
       if(!iphone && !ipad && temp_object.hasClass('line_news'))  $('#all_news_box').scrollTo( temp_object, 200);
	 });
   else $(it).parent().hide(300);
//$(it).parent().animate({opacity:0},300, function() { $(this).hide();} );
$(it).prev('.news_shower').show();
//$(it).parent().parent().find('.news_shower').css({opacity:0.95});
//$(it).parent().prev().children('.news_shower').css({opacity:1});
$(it).parent().prev().children('.news_shower').show();
return false;
}*/
function show_news()
{// alert(parseInt($('#menu').css('height')));
	if (parseInt($('#menu').css('height'))==16 || parseInt($('#menu').css('height'))==17 || parseInt($('#menu').css('height'))==15)
	 { 
document.getElementById('menu').style.height='auto';
var temp=document.getElementById('menu').clientHeight;
//alert(temp);
//$('#menu').css({height:15});
$('#menu').css({height:15});
if (msie) $('#menu').css({height:17});
$('#menu').stop();
$('#menu').animate({height:temp},300);

document.getElementById('menu_news_title').innerHTML='ALL NEWS';
     }
     else
     {
     // if (!msie)	$('#menu').animate({height:15},300);
      //else      
      $('#menu').stop();
      if (!msie)
      $('#menu').animate({height:15},300);
      else       $('#menu').animate({height:17},300);
      if (last_cat_news=='ALL NEWS')
       document.getElementById('menu_news_title').innerHTML='SORT: '+last_cat_news;
      else
       document.getElementById('menu_news_title').innerHTML='SORT: '+last_cat_news;
     }
return false;
}
function all_news()
{
if (news_arr==false) return;
  if (parseInt($('#menu').css('height'))<18) show_news();
  else print_news('all');
  return false;
}
function grid_over(it,evt)
{
	if (evt=='click')
	 if (it!='openit' && it.className!='clicked')
	  {
	  it.className='clicked';
      it.src='./i/grid_act.png';
 //     $('#fbox_title_left,#fbox_title_r,#fbox_main_div').animate({opacity:0},300,function() { $(this).hide(); });
       $('#fbox_title_left,#fbox_title_r').animate({opacity:0},300,function() { $(this).hide(); });
       $('#main_div').hide(300);
      $('.thumbmainbox').css({marginTop:'-1px'});
      return;
	  }
	  else
	  { 
	  	if (document.getElementById('main_div').style.display!='none') return;
	  	if (it=='openit') it=document.getElementById('grid');
	  it.className='';
      it.src='./i/grid.png';
  /*    $('#fbox_title_left,#fbox_title_r,#fbox_main_div').show();
      $('#fbox_title_left,#fbox_title_r,#fbox_main_div').animate({opacity:1},300);*/
      $('#fbox_title_left,#fbox_title_r').show();
      $('#fbox_title_left,#fbox_title_r').animate({opacity:1},300);
      $('#main_div').show(300);
      $('.thumbmainbox').css({marginTop:'10px'});
      return;
	  }
if (it.className!='clicked')
 if (it.src.indexOf('./i/grid.png')!=-1 || (evt=='out') ) 
  it.src='./i/grid.png';
 else 
  it.src='./i/grid_act.png';
}
function scroll_it2(to)
{
if (ipad || iphone) return;
document.getElementById("all_news_box").scrollTop=parseInt(document.getElementById("all_news_box").scrollTop)+to;
}
function scroll_it(to)
{
//window.scrollBy(0,to);	
if (ipad || iphone) return;
document.getElementById("all_news_box").scrollTop=parseInt(document.getElementById("all_news_box").scrollTop)+to;
if (document.getElementById("scroller_gal")) document.getElementById("scroller_gal").scrollTop=parseInt(document.getElementById("scroller_gal").scrollTop)+to;
//$('#all_news_box').css({scrollTop:'+='+to});
//$('#all_news_box').animate({scrollTop:'+='+to},100);
}
function location_news(newsid)
{
window.clearTimeout(scrolledanimatenews_timer);
var temp_func2=function(){ignore_url=true;
window.location='#newsfeed/news'+newsid+'/';};
scrolledanimatenews_timer=window.setTimeout(temp_func2,200);
}
function scroll_line(up)
{
if (news_arr==false) return;
	if (iphone || ipad) return;
var now_scroll=parseInt(document.getElementById("all_news_box").scrollTop);
//var temp_top=$('#all_news_box').children('.line_news').eq(1).offset();
//alert($('#all_news_box').find('.line_news').eq(0).css('offsetTop'));
$('#all_news_box').stop();
if (up==false)
  for (var i=0; i<$('#all_news_box').find('.line_news').length;i++)
  {
  	  var temp=$('#all_news_box').find('.line_news').eq(i).offset().top-parseInt($('#all_news_box').find('.line_news').eq(i).css('marginTop'))+now_scroll-10;
  	//  alert(i+' '+now_scroll+' '+temp);
  	if (news_f) var temp_scrl=154+238;
  	else        var temp_scrl=154;
     if (temp>now_scroll+temp_scrl)
      {
     // var temp=$('#all_news_box').find('.line_news').eq(i).position().top;
     //  alert(i+' '+now_scroll+' '+temp);
     // $('#all_news_box').animate({scrollTop:temp},200);
     var temp_object=$('#all_news_box').find('.line_news').eq(i);
      $('#all_news_box').scrollTo( temp_object, 200);
         if (temp_object.parent().next().attr('idnews'))
         location_news(temp_object.parent().next().attr('idnews'));
  	  break;
      } 
    }
else 
{  //var temp_break2=false;
  for (var i=$('#all_news_box').find('.line_news').length-1; i>-1;i--)
  { //var temp_break=i;
  	  var temp=$('#all_news_box').find('.line_news').eq(i).offset().top-parseInt($('#all_news_box').find('.line_news').eq(i).css('marginTop'))+now_scroll-10;
  	 //  alert(temp+' '+now_scroll);
  	if (news_f==true) var temp_scrl=139;
  	else        var temp_scrl=138; 
     if (temp<now_scroll+temp_scrl)
      {
     var temp_object=$('#all_news_box').find('.line_news').eq(i);
       $('#all_news_box').scrollTo( temp_object, 200);
        if (temp_object.parent().next().attr('idnews'))
         location_news(temp_object.parent().next().attr('idnews'));
  	 // var temp_break2=true;
  	  break;
      } 
    } //alert(i+' '+($('#all_news_box').find('.line_news').length-1));
 if (i==-1) { $('#all_news_box').animate({scrollTop:0},200); location_news(last_id_news);}
}
 if (msie) //23:28 03.07.2011 fix ie bug, don`t now khow, but any way it work.
  {
  $('#main').hide();
  $('#main').css({width:1280});
  $('#main').show();
  $('#main').css({width:'auto'});
  }
}
function detectEvent(e) {
	var evt = e || window.event;
	if (!evt) return;
 if (evt.keyCode==40) 
  {
//scroll_it(scroll_amount);
$('#at15s').hide();
if (last_cat=='newsfeed') scroll_line(false); else scroll_it(scroll_amount);
return false; 
  }
  if (evt.keyCode==38) 
   { 
//scroll_it(-scroll_amount);
$('#at15s').hide();
if (last_cat=='newsfeed') scroll_line(true); else scroll_it(-scroll_amount);
return false; 
   }
	return false;
}
function blockEvent(event)
{
    if (!event)
     {
event = window.event;
     }
    if(event.stopPropagation) event.stopPropagation();
    else event.cancelBubble=true;
    if(event.preventDefault) event.preventDefault();
    else event.returnValue=false;
}
function wheel(event)
{
   var wheelDelta = 0;
    if (!event) 
     {
event = window.event;
     }
    if (event.wheelDelta) 
     wheelDelta = event.wheelDelta/120;
     else 
      if (event.detail) 
       {
wheelDelta = -event.detail/3;
       }
    if (wheelDelta) scroll_it(-wheelDelta*scroll_amount);
    if (event.preventDefault) event.preventDefault();
event.returnValue = false;
blockEvent(event);
}
function scrollUp(s)
{
scroll_it(-s);
}

function scrollDown(s)
{
scroll_it(s);
}
 if (document.body.addEventListener)
  {
document.body.addEventListener('DOMMouseScroll', wheel, false);
  }
function i_resize()
{
	  	/*  $('body').css({overflow:'hidden'});
	  	  $('html').css({overflow:'hidden'}); */
var client_width=parseInt(document.body.clientWidth);
var client_height=parseInt(document.body.clientHeight);// alert(client_height);
$('#copyr').show();
//$('#copyr').css({top:client_height-58});
 /* if ( !(ipad || iphone) ) 
   $('#copyr').css({top:client_height-58});
  else
   {
    $('#copyr').css({top:96});
    //$('#copyr').css({left:30});
   }*/
/*if (ipad || iphone)
document.getElementById('login').style.width=client_width-27+'px';*/
if (msie && news_f==false)
{
$('#all_news_box').css({top:-17});
//$('.newsbox_main').css({paddingTop:17});
$('#line_to2').css({top:-4});
}
 if (!ipad && !iphone)
  {
 if (news_f==false || news_arr==false) document.getElementById('all_news_box').style.height=client_height-178+'px';
 else 
   {
 document.getElementById('all_news_box').style.height=client_height-166-news_f[0].h-19+'px';
 
   }
 //document.getElementById('all_news_box').style.height=client_height-166-214+'px';
if (document.getElementById("scroller_gal")) document.getElementById("scroller_gal").style.height=client_height-176+'px';
  }
 if (ipad || iphone) 
 {
  if (iphone)
  {
 	  $('#login').css({width:10});
 	    	   //$('#login').css({width:parseInt($('#main').width())+37});
 	  if (last_cat=='newsfeed')
  	   $('#login').css({width:840+21+22});
  	  else
  	   $('#login').css({width:1230+21+22});
  window.clearTimeout(timer_resizer);
  timer_resizer=window.setTimeout('i_resize()',1000);
  }
  if (ipad /*|| iphone*/) 
  { 
  	  $('#login').css({width:10});
  	  var client_width=parseInt(document.body.clientWidth);
  	  if (client_width+parseInt($(document.body).scrollLeft())<1265)
  	  $('#login').css({width:client_width+parseInt($(document.body).scrollLeft())});
  	  else   	  $('#login').css({width:1265});
  //	  alert(client_width+parseInt($(document.body).scrollLeft()));
  window.clearTimeout(timer_resizer);
  timer_resizer=window.setTimeout('i_resize()',1000);
  }
 }
  else
  {
  	  $('#login').css({width:10});
  	  var client_width=parseInt(document.body.clientWidth);
  	  $('#login').css({width:client_width+parseInt($(window).scrollLeft())});
  //	  alert(client_width+parseInt($(document.body).scrollLeft()));
  window.clearTimeout(timer_resizer);
  timer_resizer=window.setTimeout('i_resize()',1000);
  }

 // if (1==2) 
  /*	  if (ipad || iphone)
  {
  	  if (document.getElementById('scroller_gal'))
  	   {
document.getElementById('scroller_gal').ontouchstart= function(e){
if(e.touches.length == 1)
				{
         var touch = e.touches[0];
         dragging=touch.pageY;
          }
 }
 document.getElementById('scroller_gal').ontouchmove= function(e){
 	 e.preventDefault();
				if(e.touches.length == 1)
				{
         var touch = e.touches[0];
         //document.getElementById('scroller_gal').scrollTop=-(touch.pageY-dragging)+document.getElementById('scroller_gal').scrollTop;
         var temptop=$(this).scrollTop();
         $(this).scrollTop(-(touch.pageY-dragging)+temptop);
         dragging=touch.pageY;
				
				}
			} 	  
  	  }	
  	  //document.getElementById('all_news_box')
document.getElementById('scroller_gal').ontouchstart= function(e){

if(e.touches.length == 1)
				{
         var touch = e.touches[0];
         dragging=touch.pageY;
          }
 }
document.getElementById('scroller_gal').ontouchmove= function(e){
				if(e.touches.length == 1)
				{
         var touch = e.touches[0];
         var temptop=$(this).scrollTop();
         $(this).scrollTop(-(touch.pageY-dragging)+temptop);
         //var temp=$('#all_news_box').css('scrollTop');
         //  $('#all_news_box').css({scrollTop:-(touch.pageY-dragging)+temp});
      //   document.getElementById('all_news_box').scrollTop=(touch.pageY-dragging)+document.getElementById('all_news_box').scrollTop;
         dragging=touch.pageY;

				}
	 e.preventDefault();
			} 	  
			
  }*/
}

  function set_item(iitem)
{ //alert(iitem);
  for (var i=0; i<$('.word_act').length;i++)
  {
  	  var temp=$('.word_act').eq(i);   	 
  	  $('.word_act').eq(i).css('background-image','url("./menu/'+temp.attr('id').toLowerCase()+'.png")');
  }
//$('.word_act').css({background:'./menu/'+$(this).attr('id').toLowerCase()+'.png'});
//alert($('#'+iitem).css('background'));
$('.word_act').removeClass("word_act");
$('#'+iitem).addClass("word_act");
$('#'+iitem).css('background-image','url("./menu/'+iitem.toLowerCase()+'_over.png")');
}
function set_item_over(iitem,iout)
{ 
  for (var i=0; i<$('.word_over').length;i++)
  {
  	  var temp=$('.word_over').eq(i);
  	  if (!temp.hasClass("word_act"))
  	  $('.word_over').eq(i).css('background-image','url("./menu/'+temp.attr('id').toLowerCase()+'.png")');
  }
   $('.word_over').removeClass("word_over");
   if (iout) return;
   $('#'+iitem).addClass("word_over");
$('#'+iitem).css('background-image','url("./menu/'+iitem.toLowerCase()+'_over.png")');
}

 function i_load()
 {
 if (document.getElementById('all_news_box').innerHTML=='')
  {
print_news('Latest News');
last_cat_news='Latest News';
document.getElementById('menu_news_title').innerHTML='SORT: LATEST NEWS';
 }
set_events();
  if (window.location.hash=='')
   {
// $('#newsfeed').addClass("word_act");
  if (news_f)
   {
$('#newsfade_1').css({height:news_f[0].h});
$('#newsfade_2').css({height:news_f[0].h});
$('#newsfeed_fade').css({height:news_f[0].h});
  }
 set_item('newsfeed');
//  $('#newsfeed').children().addClass("word_act");
//window.setTimeout("window.location='#newsfeed/';",20);
window.location='#newsfeed/';
   }
  /*
   // news_left=document.getElementById('menu').style.left;	
            document.getElementById('menu').style.left='22px';
   $('#newsbox_main').css({width:0});
   $('#newsbox_main').show();
   $('#newsbox_main').animate({width:341}, 400,"easeOutCubic",function() { 
   	     $('#menu').removeClass('menu_scroll');
   	  //  document.getElementById('menu').style.left=news_left;
   });*/
i_resize();
window.setInterval("change_quote()",4500);
window.setInterval("news_fade()",5000);
news_fade();
$('#menu').css({height:15});
if (msie) $('#menu').css({height:17});
//if (ipad || iphone) document.getElementById('copyr').src='./i/copyright_ipad.png';
//window.setTimeout("change_quote()",5000);
//draw_section(discover,0,1,false,false);
 }
 
function set_events()
{
$(".word").click(function() {

var ihave=$(this).hasClass("word_act");
 if (!ihave) 
  {
 //$('.word_act').removeClass("word_act");
 //$(this).addClass("word_act");
 set_item_over($(this).attr('id'),true);
 set_item($(this).attr('id'));
 //$(this).children().addClass("word_act");
 }
                });
                
                $(".word").bind('mouseover',function() {
var ihave=$(this).hasClass("word_over");
 if (!ihave) 
  {
 //$('.word_over').removeClass("word_over");
// $(this).addClass("word_over");
 set_item_over($(this).attr('id'),false);
 //$(this).children().addClass("word_act");
 }
                });
$(".word").bind('mouseout',function() {
 set_item_over($(this).attr('id'),true);
                });

}
function show_arrow_an()
{
	if (ipad || iphone) return;
	window.setTimeout(function() {
$('#right_image').css({opacity:0});
$('#right_image').show();
$('#right_image').animate({opacity:1},300,function(){
$('#right_image').animate({opacity:0},300,function() { $('#right_image').hide(); });
   });
                      },350);	
}
function find_index(section,find)
{
  for (var i=0; i<section.length;i++)
   if (ret_name(section[i].t)==find) { return i; break; }
}
function check_url(res)
{
  if (res.length==2 && res[0].substr(0,res[0].length-1)=='newsfeed') 
  {
print_news(res[1].substr(0,res[1].length-1));
  }
  if (res.length==2 && res[0].substr(0,res[0].length-1)!='newsfeed') 
  {
  	var temp_sect=eval(res[0].substr(0,res[0].length-1));
    var temp_ind=find_index(temp_sect,res[1].substr(0,res[1].length-1));
//draw_section(temp_sect,0,temp_ind,false,false,false);
        $('#fbox_title_left,#fbox_title_r').animate({opacity:0},300,function() { $(this).hide(); });
       $('#main_div').hide(300,function(){
  draw_section(temp_sect,0,temp_ind,false,false,false);
  $('#main_div').hide();
      $('#fbox_title_left,#fbox_title_r').show();
      $('#fbox_title_left,#fbox_title_r').animate({opacity:1},300);
      $('#main_div').show(300,function(){
      //animation
if (temp_sect[temp_ind].sub.length>1) 
{
show_arrow_an();
}
      });
});
  }
  if (res.length==3) 
  {
  	var temp_sect=eval(res[0].substr(0,res[0].length-1));
    var temp_ind=find_index(temp_sect,res[1].substr(0,res[1].length-1));
   draw_section(temp_sect,res[2].substr(0,res[2].length-1),temp_ind,false,false,false);
  }
  if (res.length==4) 
  {
  	var temp_sect=eval(res[0].substr(0,res[0].length-1));
    var temp_ind=find_index(temp_sect,res[1].substr(0,res[1].length-1));
   draw_section(temp_sect,res[2].substr(0,res[2].length-1),temp_ind,false,true,false);
  }	
}
function monitoring() //i monitoring url
{
var my_hash=window.location.hash.replace('#','');
  //if (my_hash=='') { menu();  return; }
  if (my_hash==last_url) return; else last_url=my_hash;
	 if (ignore_url)
	 { 
	 ignore_url=false;
	 return;
	 }
var pattern=/.+?\//g;
var res=my_hash.match(pattern);
 if (!res || !res[0]) return;
 window.setTimeout("feat_addthis();",400);
var temp=res[0].substr(0,res[0].length-1); 
  if (res.length>=1) 
  { //alert(last_cat+' '+$(last_cat).next().attr('id'));
  $('*').stop(true,true);
          if (($('#'+res[0].substr(0,res[0].length-1)).next().is(':visible'))==false)
            {
            	if (document.getElementById('menu'))
            	{
            news_left=document.getElementById('menu').style.left;	
            document.getElementById('menu').style.left='22px'; //easeOutCubic easeOutQuad
            	}
 //$('#'+last_cat).next().animate({width:1},1100);
	if (document.getElementById('menu')) $('#menu').addClass('menu_scroll');
 if (!msie && news_f!=false ) 
 {
 $('#newsfeed_fade').addClass('newsfeed_fade_scroll');
 $('#newsfade_1').hide();
 $('#newsfade_2').hide();
 }
 if (msie) $('#menu').addClass('menu_ie');
  //19:17 10.07.2011 
 $('iframe').hide();
 			if (last_cat=='newsfeed') var speed_a=400; else speed_a=856; 
  $('#'+last_cat).next().animate({width:0}, speed_a,"easeOutCubic",function(){
  	  if (document.getElementById('menu')) document.getElementById('menu').style.left=news_left;
  	  if (document.getElementById('content_div'))
  	   {
document.getElementById('content_div').innerHTML='';
 $('#content_div').attr('id','');  
       }
 	  if (res[0].substr(0,res[0].length-1)!='newsfeed')
 	   {
 if (!document.getElementById('content_div'))
   $('#'+res[0].substr(0,res[0].length-1)).next().attr('id','content_div');
		  
  if (res.length==1 || ($('#'+res[0].substr(0,res[0].length-1)).next().is(':visible'))==false) 
  { 
 /*if (document.getElementById('fbox_main_div_temp2')) $('#fbox_main_div_temp2').attr('id','');
 if (document.getElementById('fbox_main_div_temp')) $('#fbox_main_div_temp').attr('id','');
 if (document.getElementById('fbox_main_div')) $('#fbox_main_div').attr('id','');*/
  draw_section(eval(res[0].substr(0,res[0].length-1)),0,0,false,false);
   }
  check_url(res);
 	   } $('#'+last_cat).next().hide();
 	   if (document.getElementById('menu'))
 	   {
 	        news_left=document.getElementById('menu').style.left;	
            document.getElementById('menu').style.left='22px';
       }
$('#'+res[0].substr(0,res[0].length-1)).next().css({width:0});
          /*  $('#'+res[0].substr(0,res[0].length-1)).next().css({width:'auto'});
 			var temp=$('#'+res[0].substr(0,res[0].length-1)).next().width();*/
 			if (res[0].substr(0,res[0].length-1)=='newsfeed') var tempr=341; else var tempr=730;
 			if (res[0].substr(0,res[0].length-1)=='newsfeed') var speed_a=400; else speed_a=856;
 			 $('#'+res[0].substr(0,res[0].length-1)).next().show();
            $('#'+res[0].substr(0,res[0].length-1)).next().css({width:0});
          //  $('#'+res[0].substr(0,res[0].length-1)).next().animate({width:temp},1000);
          if (res[0].substr(0,res[0].length-1)!='newsfeed') $('#main_div').hide();
          $('.thumbmainbox').css({marginTop:'-1px'});
   $('#'+res[0].substr(0,res[0].length-1)).next().animate({width:tempr}, speed_a,"easeOutCubic",function() { 
   	    
   	     $('#menu').removeClass('menu_scroll');
 if (!msie && (news_f!=false)) 
 {
 $('#newsfeed_fade').removeClass('newsfeed_fade_scroll');
 $('#newsfade_1').show();
 $('#newsfade_2').show();
 }
   	   if (document.getElementById('menu')) document.getElementById('menu').style.left=news_left;
   last_cat=res[0].substr(0,res[0].length-1);
    //19:17 10.07.2011 
 $('iframe').show();
 //3:11 05.08.2011
 	if (last_cat!='newsfeed')
 	 {
   	var temp_sect=eval(res[0].substr(0,res[0].length-1));
   	 $('.thumbmainbox').css({marginTop:'10px'});
      $('#main_div').show(300,function(){
      //animation
if (temp_sect[0].sub.length>1) 
{
show_arrow_an();
}
window.setTimeout('$("#add_featurebox").attr("addthis:url",window.location);feat_addthis();',20);
      });
     }
   });
  });
  //$('.word_act').removeClass("word_act");
  set_item(res[0].substr(0,res[0].length-1));
 //$('#'+res[0].substr(0,res[0].length-1)).addClass("word_act");
 //$('#'+res[0].substr(0,res[0].length-1)).children().addClass("word_act");
          }
  }
check_url(res)
}
window.setTimeout("window.setInterval('monitoring()',100);",100);
//window.setTimeout("window.setInterval('act_top_addthis();',1000);",100);
  if (!ipad && !iphone) 
   {
document.body.onmousewheel = wheel;
   }
  if (ipad || iphone) 
   {
document.body.onkeydown = null;   
   }
//by ALaKO, 2011

//dinesh
$(document).ready(function() {
	$('.news_text a.addthis_button, .news_text a.addthis_button img').live('hover', function(event){
		var addThisElementOnHover = $('#at15s');
		var targetEvent =  event;  
		var y = $(this).offset().top + 20;

		addThisElementOnHover.css({
			//top: '50%', 
			top: y+'px',
			//left: '50%'
			left: $(this).offset().left+'px'
		});
	});
});
//end of code dinesh
