
function print_page() {
	window.print();  
}

function findstring(string, start, lenght) {
		return string.substring(start, start+lenght);
	}

function swapImage(imgName,newImg) { 
	eval('document.' + imgName + '.src = "' + newImg + '"'); 
}

function windowOpener(url,width,height,name,scrolls) {
	browserName = navigator.appName;
	browserVer = navigator.appVersion.substring(0,1);
	if (width==null) {width=600;}
	if (height==null) {height=400;}
	if (name==null) {name="globaltPopup"}
	if (scrolls==true) {
		scrollsOption="yes";
	} else {
		scrollsOption="no";
	}
	var topPx = (browserName=="Netscape")?"screenX":"top";
	var leftPx = (browserName=="Netscape")?"screenY":"left";
	if (browserName != "Netscape" || browserVer != 2) {
		controlWindow=window.open(url,name,"toolbar=no,height="+height+",width="+width+",location=no,directories=no,status=no,menubar=no,scrollbars="+scrollsOption+",resizable=no,"+leftPx+"=0,"+topPx+"=0");
	}
}

function nmcPartypics(x) {
	c = x;
	windowOpener('nmcpic.php?koodi='+c,'540','545','nmcpic', false);
	return false;
}


function set_CSS(el_id, CSS_attr, CSS_val) {
	var el = document.getElementById(el_id);
	if (el) el.style[CSS_attr] = CSS_val;
}

function showVideo(id) {
	var videoHTML = "";
	var path = "http://mobiletv.nokia.com/";
	var vel = document.getElementById("video_inner");
	set_CSS('quotebox_videos', "display", 'none');
	set_CSS('video_outer', "display", 'block');
	set_CSS('video_inner', "display", 'block');

	if (id == "iyh") {
		videoHTML += '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="400" height="320" codebase="http://www.apple.com/qtactivex/qtplugin.cab">';
		videoHTML += '<param name="src" value="'+path+'video/06.08.18_IYH_45_final.mov">';
		videoHTML += '<param name="autoplay" value="true">';
		videoHTML += '<param name="controller" value="true">';
		videoHTML += '<param name="bgcolor" value="#141414">';
		videoHTML += '<param name="loop" value="false">';
		videoHTML += '<embed src="'+path+'video/06.08.18_IYH_45_final.mov" width="400" height="320" bgcolor="#222222" autoplay=true controller=true loop=false wmode=transparent pluginspage="http://www.apple.com/quicktime/download/"></embed>';
		videoHTML += '</object>';
	}

	if (id == "n92") {
		videoHTML += '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="400" height="320" codebase="http://www.apple.com/qtactivex/qtplugin.cab">';
		videoHTML += '<param name="src" value="'+path+'video/N92_product.mov">';
		videoHTML += '<param name="autoplay" value="true">';
		videoHTML += '<param name="controller" value="true">';
		videoHTML += '<param name="bgcolor" value="#141414">';
		videoHTML += '<param name="loop" value="false">';
		videoHTML += '<embed src="'+path+'video/N92_product.mov" width="400" height="320" bgcolor="#222222" autoplay=true controller=true loop=false wmode=transparent pluginspage="http://www.apple.com/quicktime/download/"></embed>';
		videoHTML += '</object>';
	}
	
	if (id == "mobiletv") {
		videoHTML += '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="400" height="320" codebase="http://www.apple.com/qtactivex/qtplugin.cab">';
		videoHTML += '<param name="src" value="'+path+'video/n92_ow.mov">';
		videoHTML += '<param name="autoplay" value="true">';
		videoHTML += '<param name="controller" value="true">';
		videoHTML += '<param name="bgcolor" value="#141414">';
		videoHTML += '<param name="loop" value="false">';
		videoHTML += '<embed src="'+path+'video/n92_ow.mov" width="400" height="320" bgcolor="#222222" autoplay=true controller=true loop=false pluginspage="http://www.apple.com/quicktime/download/"></embed>';
		videoHTML += '</object>';
	}
	
	if (id == "primetime") {
		videoHTML += '<object id="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" width="320" height="240">';
		videoHTML += '<param name="fileName" value="'+path+'video/mobiletv_new_prime_times.wmv">';
		videoHTML += '<param name="animationatStart" value="true">';
		videoHTML += '<param name="transparentatStart" value="true">';
		videoHTML += '<param name="autoStart" value="true">';
		videoHTML += '<param name="showControls" value="true">';
		videoHTML += '<param name="Volume" value="-450">';
		videoHTML += '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="'+path+'video/mobiletv_new_prime_times.wmv" name="MediaPlayer1" width=320 height=240 autostart=1 showcontrols=1 volume=-450>';
		videoHTML += '</object>';
	}
	
	if (id == "consumerf") {
		videoHTML += '<object id="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" width="375" height="288">';
		videoHTML += '<param name="fileName" value="'+path+'video/mobiletv_consumer_feedback.mpg">';
		videoHTML += '<param name="transparentatStart" value="true">';
		videoHTML += '<param name="autoStart" value="true">';
		videoHTML += '<param name="showControls" value="true">';
		videoHTML += '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="'+path+'video/mobiletv_consumer_feedback.mpg" name="MediaPlayer1" width=375 height=288 autostart=1 showcontrols=1>';
		videoHTML += '</object>';
	}
	if (id == "industryf") {
		videoHTML += '<object id="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" width="375" height="288">';
		videoHTML += '<param name="fileName" value="'+path+'video/mobiletv_industry_feedback.mpg">';
		videoHTML += '<param name="transparentatStart" value="true">';
		videoHTML += '<param name="autoStart" value="true">';
		videoHTML += '<param name="showControls" value="true">';
		videoHTML += '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="'+path+'video/mobiletv_industry_feedback.mpg" name="MediaPlayer1" width=375 height=288 autostart=1 showcontrols=1>';
		videoHTML += '</object>';
	}
	if (id == "n77") {
		videoHTML += '<object id="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" width="360" height="260">';
		videoHTML += '<param name="fileName" value="'+path+'video/nokia_n77.wmv">';
		videoHTML += '<param name="animationatStart" value="true">';
		videoHTML += '<param name="transparentatStart" value="true">';
		videoHTML += '<param name="autoStart" value="true">';
		videoHTML += '<param name="showControls" value="true">';
		videoHTML += '<param name="Volume" value="-450">';
		videoHTML += '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="'+path+'video/nokia_n77.wmv" name="MediaPlayer1" width=360 height=260 autostart=1 showcontrols=1 volume=-450>';
		videoHTML += '</object>';
	}
	
	function dynamiccontentNS6(elementid,content){
		if (document.getElementById && !document.all){
		rng = document.createRange();
		el = document.getElementById(elementid);
		rng.setStartBefore(el);
		htmlFrag = rng.createContextualFragment(content);
		while (el.hasChildNodes())
			el.removeChild(el.lastChild);
			el.appendChild(htmlFrag);
		}
	}
	
	//dynamiccontentNS6('video_inner',videoHTML);
	//var newHTML	= document.createTextNode(videoHTML);
	//document.getElementById("video_inner").appendChild(newHTML);
	
	
	document.getElementById("video_inner").innerHTML = videoHTML;
	
	
	
	
}

/* dynamic navigation */

$(document).ready(function(){
	$('#imenus0 > li').bind('mouseover', function(){
		$(this).addClass('active');
		$('#'+$(this).attr('id')+' ul').css('visibility','visible');
	});
	$('#imenus0 > li').bind('mouseout', function(){
		$(this).removeClass('active');
		$('#'+$(this).attr('id')+' ul').css('visibility','hidden');
	});
	$('li.has-third-level').bind('mouseover', function(){
		$('.'+$(this).attr('class')+' ul').css('display','block');
	});
	$('li.has-third-level').bind('mouseout', function(){
		$('.'+$(this).attr('class')+' ul').css('display','none');
	});
	
});
	

/*var naviPics = new Array();*/

/*function preLoadImages() {
        for(var i = 0; i < 6; i++) {
                naviPics[i] = new Array();
                for(var x = 0; x < 2; x++) {
                        naviPics[i][x] = new Image();
						naviPics[i][x].src = "pics/navi_" + i + "_" + x + ".gif";
				}
		}
		otherPics[1] = new Array();
		otherPics[1][0] = new Image();
		otherPics[1][0].src = "pics/arrow_grey.gif";
		otherPics[1][1] = new Image();
		otherPics[1][0].src = "pics/arrow_w.gif";
		
}*/

//if(document.images) preLoadImages()

/* polls result page*/

var shownresults = new Array();
$(document).ready(function(){
	if (eval($('#poll_olderpolls h5').length) > 0) {
		/* turn the h5's into clickable links and hide the table */
		$('#poll_olderpolls h5').addClass('clickable');
		$('#poll_olderpolls h5').hover(
			function(){
				if( $(this).attr('class') == 'clickable') $(this).children('span').css("text-decoration","underline");
			},
			function(){
				if( $(this).attr('class') == 'clickable') $(this).children('span').css("text-decoration","none");
			}
		);
		$('form p.clickable').hover(
			function(){
				if( $(this).attr('class') == 'clickable') $(this).css("text-decoration","underline");
			},
			function(){
				if( $(this).attr('class') == 'clickable') $(this).css("text-decoration","none");
			}
		);
		$('#poll_olderpolls table').hide();
		/* when the h5 is clicked... */
		$('#poll_olderpolls h5').bind('click', function(){
			if( $(this).attr('class') == 'clickable') {
				$(this).children('span').css("text-decoration","none");
				/* ...all other h5s are turned into links and forms/tables hidden... */
				$('#poll_olderpolls h5').addClass('clickable');
				$('#poll_olderpolls form').hide();
				$('#poll_olderpolls table').hide();
				/* ...now get the id of the question... */
				questionid = $(this).parent().attr('id').split('_')[2];
				/* ...then turn the h5 into non-clickable... */
				$(this).removeClass('clickable');
				/* ...and show the form or the result if the memory variable indicates that it has been viewed before */
				if (shownresults[questionid]) {
					$(this).siblings('table').show();
				}
				else {
					/* show the form and "hijack" the submit event */
					$(this).siblings('form').show().one('submit', function(){
						/* ...register the vote with vote.php... */
						pollId = $(this).parent().attr('id').split('_')[2];
						pollVote = $("input[@name='poll_vote_"+pollId+"']:checked").val();
						if (pollVote) {
							$("div#null_"+pollId).load("vote.php",{vote:pollVote,poll:pollId});
							/* ...then update and show the results */
							$(this).hide();
							$(this).siblings('table').show();
							shownresults[questionid] = true;
						}
						return false;
					});
				}
				/* when the "show results" link is clicked, hide the form and show the table instead + set the memory variable */
				$('#poll_olderpolls li p.clickable').one('click', function(){
					$(this).parent().hide();
					$(this).parent().siblings('table').show();
					shownresults[questionid] = true;
				});
			}
		});
	}
});
