var search=1;
var press='#press1';

function hide(element_id,speed){
  $(element_id).hide(speed);
}

function show(element_id,speed){
  $(element_id).show(speed);
}

function showAboutUsTeaser(){
  hide("#full_hide","fast");
  hide("#full","slow");
  show("#teaser_more","fast"); 
}

function showAboutUsFull(){
  hide("#teaser_more","fast");
  show("#full","slow");
  show("#full_hide","slow");
}

function showSearch(){
  show("#searchx","slow"); 
}

function hideSearch(){
  hide("#searchx","slow");
}

function toggleSearch(){
  if(search){
    hideSearch();
	search=0;
  }else {
    showSearch();
	search=1;
	}
}


function hidePress(){
  show("#press1","fast");
  hide("#press2","fast");
  hide("#press3","fast");
  hide("#press4","fast");
}

function showPress(showId){
  hide(press,"slow");
  show(showId,"slow");
  press=showId;
}

function popup(mylink, prop)
{
  //if (! window.focus) return true;
  var href;
 
  if (typeof(mylink) == 'string'){
    href=mylink;
  }else{
    href=mylink.href;
  }
  
  window.open(href,'FPVideo',prop); 
  
  return false;
}

function explodeArray(item,delimiter)
{
   var tempArray=new Array(1);
   var Count=0;
   var tempString=new String(item);
   while (tempString.indexOf(delimiter)>0) {
	tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
	tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1);
	Count=Count+1
   }
   tempArray[Count]=tempString;
   return tempArray;
}

function set_xcontent_bg()
{
   if (!document.getElementById) return false;
   
   var MyElement = "xcontent";
   var ImgPath = "File/fp/img/front_images/";
   var random_images = new Array ();
   
   random_images = explodeArray(images,",");
  
   if (!document.getElementById(MyElement)) return false;
   
   var $header = document.getElementById(MyElement);
   var $backgroundurl = $header.style.backgroundImage;
   var ImgURL = "url(" + ImgPath + random_images[rand(random_images.length)] + ")";

   if ($backgroundurl != ImgURL) {
    $header.style.backgroundImage = ImgURL; 
   }
}

/* random number generator */
function rand(n) {
    return ( Math.floor ( Math.random ( ) * n ) );
}

