//frame-busting
if (parent.frames.length > 0) {
  var us = self.document.location.href;
  var query = (us.indexOf("?"));

  if (query)
  {
	us = us.substring(0,query);
  }

    parent.location.href = us;
}
//end frame-busting

function gvpop( type, x, y, url ) {
    var p = window.open( url+'&imid=250', '_blank', 'directories=0,height='+y+',width='+x+',hotkeys=0,location=0,menubar=0,resizable=0,scrollbars=0,toolbar=0' );
    if (p) {	
	if ( type == 'under' ) {
	    p.blur();
	    this.focus();
	} else {
	    p.focus();
	}
    }
    return;
}

//right-side floating advertisement code
floatX=10;
floatY=20;
pixelScoot=7;	//the ad will move by this many pixels at a time (smaller number = smoother movement)
minTop=159;  //offset from top of viewable area (leaves room for header)
minBottom=127;	//offset from bottom of viewable area (leaves room for footer)
offsetCenter=186;	//offset ad from center of page by this many pixels

var isIE = 0;
var isFF = 0;
if (document.all){
	var isIE = 1;
}else if (document.getElementById){
	var isFF = 1;
}

function move() {

	var pointX = (isFF)? window.pageXOffset : document.body.scrollLeft;
	var pointY = (isFF)? window.pageYOffset : document.body.scrollTop;
	var adObject = (isFF)? document.getElementById('ad_box') : document.all['ad_box'];
	var scrollHeight = document.body.scrollHeight;
	var langCode = move.arguments[0];
	
	if (lastX==-1 || pixelScoot==0){
		lastX=pointX + floatX;
		lastY=pointY + floatY;
	}else{
		if (pointY+floatY>lastY) {lastY=lastY+pixelScoot;}
		if (pointY+floatY<lastY) {lastY=lastY-pixelScoot;}
		if (lastY > scrollHeight-minBottom-adObject.offsetHeight){	//stops ad from displaying any lower than our main content area
			lastY=scrollHeight-minBottom-adObject.offsetHeight;
		}
		if (lastY < minTop) lastY = minTop;						//stops ad from displaying any higher than our main content area

		if(langCode == "he")
			adObject.style.right=document.body.clientWidth/2+offsetCenter;
		else
			adObject.style.left=document.body.clientWidth/2+offsetCenter;
		adObject.style.top=lastY;
	} 
	
	setTimeout("move('"+langCode+"')",50);
}

function define(){

	floatX = document.body.clientWidth/2+offsetCenter;
	floatY = ifloatY;

}

//end right-side floating advertisement code

// functions for teaser flash game 
function openTeaserFlash(url) {
	var teaser_window = window.open(url, "teaser_flash", "scrollbars=no,menubar=no,height=768,width=1024,resizable=yes,toolbar=no,location=no,status=yes");
}

function closeTeaserFlash() {
	self.close();
}

function reloadTeaserFlash() {
	window.location.reload();
}

	// the following two functions are used by the teaser flash to open the dload page and (optionally) close the flash game
	// an imid is passed to the dload page in two parts:
	// 		-- the imidPrefix is sent from the template file and contains the first two digits of the imid
	//		-- the imidPostfix is sent from the flash file and contains the final digit of the imid
function openDload(imidPostfix) {
	var dloadLocation = "/dload/?imid=" + imidPrefix + imidPostfix;
	if ( window.opener && !window.opener.closed ) {
		window.opener.location = dloadLocation;
		window.opener.document.focus();
	} else {
		var dload_window = window.open(dloadLocation, "dloadwindow", "");
	}
}

function openDloadCloseFlash(imidPostfix) {
	if ( self.name == 'teaser_flash' ) {
		self.close();
	} 
	openDload(imidPostfix);
}
// end teaser flash