// JavaScript Document

function embedDirectPlayer(width, height, vid) {
	host = "demo.vtp.gtomato.com";
	shost = "demo.static.vtp.gtomato.com/streaming";
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height=" ' + height + '"><param name="movie" value="vtppplayer.swf?host=' + host + '&shost=' + shost + '&vid=' + vid + '"><param name="quality" value="high"><embed src="vtpplayer.swf?host=' + host + '&shost=' + shost + '&vid=' + vid + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed></object>');
}
function embedPlayer(width, height, vid) {
	host = "demo.vtp.gtomato.com";
	shost = "demo.static.vtp.gtomato.com/streaming";
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height=" ' + height + '"><param name="movie" value="vp.swf?host=' + host + '&shost=' + shost + '&vid=' + vid + '"><param name="quality" value="high"><embed src="vp.swf?host=' + host + '&shost=' + shost + '&vid=' + vid + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed></object>');
}

function embedBanner(width, height) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height=" ' + height + '"><param name="movie" value="images/temp/blog_girl.swf"><param name="quality" value="high"><embed src="images/temp/blog_girl.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed></object>');
}

function embedAdvertisement(width, height) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height=" ' + height + '"><param name="movie" value="images/temp/adv.swf"><param name="quality" value="high"><embed src="images/temp/adv.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed></object>');
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

//	if (getOpac(id) != '') {
//		opacStart = getOpac(id) *100;
//	}
    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart >= opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart <= opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 
 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}

function getOpac(id) {
    return document.getElementById(id).style.opacity; 
}

function UTRating(ratingElementId, maxStars, objectName, formName, componentSuffix, size, messages)
{
	this.ratingElementId = ratingElementId;
	this.maxStars = maxStars;
	this.objectName = objectName;
	this.formName = formName;
//	this.ratingMessageId = ratingMessageId;
	this.componentSuffix = componentSuffix;
	this.messages = messages;

	this.starTimer = null;
	this.starCount = 0;

	if(size=='L') {
		UT_RATING_IMG      = '/images/d3/ico_star_full_l.gif';
		UT_RATING_IMG_HALF = '/images/d3/ico_star_half_l.gif';
		UT_RATING_IMG_BG   = '/images/d3/ico_star_empty_l.gif';
	} else if (size == 'S') {
		UT_RATING_IMG      = '/images/d3/ico_star_full.gif';
		UT_RATING_IMG_HALF = '/images/d3/ico_star_half.gif';
		UT_RATING_IMG_BG   = '/images/d3/ico_star_empty.gif';
	}
	
	// pre-fetch image
	(new Image()).src = UT_RATING_IMG;
	(new Image()).src = UT_RATING_IMG_HALF;

	function showStars(starNum) {
		this.clearStarTimer();
		this.greyStars();
		this.colorStars(starNum);
//		if(!skipMessageUpdate)
//			this.setMessage(starNum, messages);
	}

//	function setMessage(starNum) {
//		document.getElementById(this.ratingMessageId).innerHTML = this.messages[starNum];
//	}

	function colorStars(starNum) {
		for (var i=0; i < starNum; i++) {
			document.getElementById(this.componentSuffix + "_" + (i+1)).src = UT_RATING_IMG;
		}
	}

	function greyStars() {

		for (var i=0; i < this.maxStars; i++)
			if (i <= this.starCount) {
				document.getElementById(this.componentSuffix + "_"  + (i+1)).src = UT_RATING_IMG_BG;
			}
			else
			{
				document.getElementById(this.componentSuffix + "_"  + (i+1)).src = UT_RATING_IMG_BG;
			}
	}

	function setStars(starNum) {
		this.starCount = starNum;
		this.drawStars(starNum);
		document.forms[this.formName]['rating'].value = this.starCount;
		var ratingElementId = this.ratingElementId;
		addrating(starNum);
		//postForm(this.formName, true, function (req) { replaceDivContents(req, ratingElementId); });
	}


	function drawStars(starNum) {
		this.starCount=starNum;
		this.showStars(starNum);
	}

	function clearStars() {
		this.starTimer = setTimeout(this.objectName + ".resetStars()", 300);
	}

	function resetStars() {
		this.clearStarTimer();
		if (this.starCount)
			this.drawStars(this.starCount);
		else
			this.greyStars();
//		this.setMessage(0);
	}

	function clearStarTimer() {
		if (this.starTimer) {
			clearTimeout(this.starTimer);
			this.starTimer = null;
		}
	}

	this.clearStars = clearStars;
	this.clearStarTimer = clearStarTimer;
	this.greyStars = greyStars;
	this.colorStars = colorStars;
	this.resetStars = resetStars;
	this.setStars = setStars;
	this.drawStars = drawStars;
	this.showStars = showStars;
//	this.setMessage = setMessage;

}

function getElementXY(element, relativeTo)
{
	var elemX = 0;
	var elemY = 0;
	do {
		elemX += element.offsetLeft;
		elemY += element.offsetTop;
		if (element.offsetParent == relativeTo) break;
	} while ( element = element.offsetParent )


	return Array(elemX, elemY);
}

function goto(url)
{
	document.location.href = url;
}

function getRandomNumber(max) {
 return Math.floor(Math.random()*max);
}

function getInnerWindowSize() {
	var innerWidth = 0, innerHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	innerWidth = window.innerWidth;
	innerHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	innerWidth = document.documentElement.clientWidth;
	innerHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	innerWidth = document.body.clientWidth;
	innerHeight = document.body.clientHeight;
	}
	return [innerWidth, innerHeight];
}
