var flag             = 0;
var flagFirst        = 0;
var flagPlay         = 0;

function checkPlay() {
	if (!flagFirst) return;
	if (window.document.demo_10.PercentLoaded() < 100) return;

	if (window.document.demo_10.IsPlaying()) {
		if (window.document.demo_10.TCurrentFrame("/")>=8071-250) {
			closeWin();
			window.document.demo_10.StopPlay();
			window.document.demo_10.GotoFrame(0);
			flagPlay = 0;
		}
		return;
	}
	
	return;
}

function startDiv() {
	clipProntoDiv      = layer("clipPronto");
	clipProntoMinDiv   = layer("minClipPronto");
	
	clipProntoMinDiv.hide();
	
	return true;
}

function screenSize() {
 var w, h; 
 w = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
 h = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
 
 return {w:w, h:h};
}
	 
function fn_resize(e, intWidth, intHeigth) {
	var newW;
  newW = (intWidth == null || intWidth == '' || isNaN(parseInt(intWidth))) ? 800 : parseInt(intWidth);
  var newL = Math.round(screen.width/2 - newW);
  var newH;
  newH = (intHeigth == null || intHeigth == '' || isNaN(parseInt(intHeigth))) ? 800 : parseInt(intHeigth);
  var newT = Math.round(screen.height/2 - newH);
  e.resizeTo(newW,newH); 
}


function moveClip(a) {
	var heightWinIn = screenSize().h;
	clipProntoMinDiv.moveTo(5,heightWinIn - 47);
	
	
	if (!flag) { 
		closeWin(); 
		if (!flagFirst) { 
			clipProntoMinDiv.hide(); 
		} 
		return; 
	}
	
	var widthWinIn  = screenSize().w;
	if (!a) {
		if (widthWinIn < 1030 || heightWinIn < 722) {
			window.resizeTo(widthWinIn + 1030 - widthWinIn + 60,heightWinIn + 722 - heightWinIn + 190);
		} 
	}
	if (widthWinIn > 1030 && heightWinIn > 722) {
		clipProntoDiv.moveTo((widthWinIn - 1030) / 2,(heightWinIn - 722) / 2);
	} 
		
}

function winOpen(url) {
  popupWin = window.open(url, "demoPronto", "width=1024,height=663,scrollbars=no,menubar=no,toolbar=no");
	popupWin.focus();
}

function openWin() {
	clipProntoMinDiv.hide();
  if (!flagFirst) {
		flag = 1;
		flagFirst = 1;
		moveClip(0);

		if (isSafariMac) {
			winOpen("/clip.html");
			flagFirst = 0;
			return;
		}
		
	  if(isMSIE){
			document.getElementById("innerClip").innerHTML = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http:\/\/fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"1024\" height=\"663\" id=\"demo_10\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"movie\" value=\"\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#7bc1ff\" /><embed src=\"\" quality=\"high\" background=\"#7bc1ff\" bgcolor=\"#7bc1ff\" width=\"1024\" height=\"663\" name=\"demo_10\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http:\/\/www.macromedia.com/go/getflashplayer\" /></object>";
		}

		window.document.demo_10.LoadMovie(0, "/c.swf");

	}

	if (!isSafariMac) {
		clipProntoDiv.show();
		if (flagPlay) window.document.demo_10.Play();
		flag = 1;
	}
	
	return;
}

function closeWin() {
  clipProntoDiv.hide();
	if (flagFirst) {
		if (window.document.demo_10.IsPlaying()) flagPlay = 1; else flagPlay = 0;
		window.document.demo_10.StopPlay();
	}
	clipProntoMinDiv.show();
	flag = 0;
}

