
function popScreenshot(gCode,imgName, imgWidth, imgHeight)
{
    window.open("screenshot.aspx?code=" + gCode + "&src="+imgName, "screenshot", "toolbar=no, status=no, resize, width=" + imgWidth + ", height=" + imgHeight + " ")
    return
}

function CutDownloadCategoryGameNames(arrayGamesID)
{
	var i;
	var game_name_tag, game_tag;
	
	//Get each game name
	var limit = arrayGamesID.length;
	
	for (i = 0; i < limit; i++)
	{
		//Try find tag
		try
		{			
			game_name_tag = arrayGamesID[i];
			game_tag = document.getElementById(game_name_tag);			
		}
		catch(e)
		{
			//Searching faild, lets try enother time
			game_name_tag = null;			
		}
		
		//Change tex
		if(game_name_tag != null)
		{
			CutDownloadGameName(game_tag, game_tag.innerHTML);
		}
	}
}

function CutDownloadGameName(tag, text)
{
	var trunctext = new String(text);
	var i = 0;
	
	while(parseInt(tag.offsetHeight) > 20)
	{
		trunctext = trunctext.slice(0,-1);
		tag.innerHTML = trunctext;

		i++;
		if(i > 100)
		{
			break;
		}	
	}
	
	//Add ...
	if(i != 0)
	{
		trunctext = trunctext.slice(0,-3);
		trunctext = trunctext+'...';
		tag.innerHTML = trunctext;
	}
	
}


function popOnlineExt(gameUrl, gameCode, origin, width, height) {    
	window.open(gameUrl + "?code=" + gameCode + "&origin=" + origin, "online", "width=" + width + ", height=" + height);
    return;
}

function omnitureLogDownload(gameCode, omnitureChannel,gameName,catName,dlDateTime) {
	try
	{
		omnitureLogDownload_Real(gameCode, omnitureChannel,gameName,catName,dlDateTime);
	}
	catch(e){}
}

	
function GetObjectHeight(object_id)
{
	var obj;
	
	//Search
	obj = document.getElementById(object_id);
	
	//Founded
	if(obj)
		return obj.offsetHeight;
		
	//Search faild
	return 0;
	
}

function AlignHomePageCats()
{
			
	var maxHeight =0 ;
	var currRowHeight = 0;
	var downloadsSpacer = 0;
			
	/* Align Containers an data boxes */
	maxHeight = 0;
	/* loop over boxes to find max height */
	for (var i=0;i<6;i++)
	{
		currRowHeight = GetObjectHeight('CatTable_'+i+'TBL');
				
		if (maxHeight < currRowHeight)
		{
			maxHeight = currRowHeight;				
		}
	}
	//alert(maxHeight + ':' + Name);
	//return false;
	/* set max height to all boxes */
	for (var i=0;i<6;i++)
	{
		var oid  = document.getElementById('CatTable_'+i+'TBL');
		if(oid)
		{
			oid.style.height = maxHeight - 10;
		}
		
		var oid  = document.getElementById('CatTable_'+i+'TD');
		if(oid)
		{
			oid.style.height=maxHeight-30;
		}
	}

	//Align Top 10
	var top10TableTag;
	var tableHeight = 0;
	
	//Get Table
	top10TableTag = document.getElementById('top10TableID');
	
	//Set height
	if(top10TableTag)
	{
		//New game
		tableHeight += GetObjectHeight('NewGamesTableId');
		//First Row in categories table
		tableHeight += GetObjectHeight('CatTable_0TBL');
		
		top10TableTag.style.height = tableHeight-2;			
	}
	
	//Get ToolTipsArea
	TipModuleBodyTag = document.getElementById('TipModuleBody');
	if(TipModuleBodyTag){
		areaHeight = GetObjectHeight('CatTable_2TBL') + GetObjectHeight('CatTable_4TBL') - 6;
		TipModuleBodyTag.style.height = areaHeight;
	}
}
		
		
		
function GetElementTop(e)
{
	var res = 0;
	
	while(e)
	{
		res += e.offsetTop;
		e = e.offsetParent;
	}
	
	return res;
}