var MIN_HEIGHT = 640;
var MIN_WIDTH = 960;

var fheight=0;
var fwidth=0;

var olduri="";
var intval=""
var download;
var inner = getInnerSize();
function flashResize() {
    if(document.getElementById("flash_content")!=null && document.getElementById("flash_content").style.display!="none"){
	resizeMin(MIN_WIDTH, fheight);
    }
}
function setViewId(_vid, _uri,_title) {
	_title = unescape(_title);
	if (_title.indexOf("Cayago")>-1) {
		document.title =_title;
		debug('Title '+_title);
  }	else {
		document.title ='Cayago';
	}
  if (isDefined('xcmsSetEditorById'))
	   xcmsSetEditorById(_vid);
  var
   	element = document.getElementById('historyframe');
   
   if (element != null){
  		element.src='/historyframe.html?title='+_title;
   		debug('/historyframe.html?title='+_title);
   }
	if(olduri!=_uri) {
			urchinTracker(_uri);
    	olduri=_uri;
   }
}
function getUrl(_url) {
	document.getElementById('historyframe').src=_url;
}
function setIframe() {
		version=0
		if (navigator.appVersion.indexOf("MSIE")!=-1 && navigator.appVersion.indexOf("SV1")!=-1){
			temp=navigator.appVersion.split("MSIE");
			version=parseFloat(temp[1]);
		}
		if(version>0 &&version<7)
    	document.getElementById('historyframediv').innerHTML = "<iframe height=\"5\" id=\"historyframe\" name=\"historyframe\" src=\"/historyframe.html\" width=\"5\">&nbsp;</iframe>";
}
function flashresize(_height) {
	if (typeof _height != 'number'){
		error('illegal resize value in flashresize: '+_height);
		return;
	}
	_height = parseInt(_height);
	if (_height == 0)
		return;
	resizeMin(MIN_WIDTH, _height);
}
function resizeMin(_minWidth, _minHeight){
	//debug("minw: "+_minWidth+" minh:"+_minHeight+" currenth:"+fheight+" innerh:"+getInnerHeight());

	inner=getInnerSize()		  
	if (_minHeight < MIN_HEIGHT)
		_minHeight = MIN_HEIGHT;
	
	if (_minWidth < MIN_WIDTH)
		_minWidth = MIN_WIDTH;
	if (_minHeight<inner[1])
	    _minHeight=inner[1];
	if (fwidth != _minWidth || fheight != _minHeight){
		fwidth = _minWidth;
		fheight = _minHeight;
		setElementSizeById("flash_content", MIN_WIDTH, fheight);
		setElementSizeById("flash_object", MIN_WIDTH, fheight);

	}

	ml=parseInt((inner[0]-MIN_WIDTH)/4)*2-8;
	
	//alert(inner[0]+":"+ml);
	document.getElementById("flash_content").style.marginLeft=ml+"px";
}

function error(_error){
    //ERROR
}
window.onresize=flashResize;
flashResize();