function Querystring(qs) {
	this.params = new Object()
	this.get=Querystring_get
	if (qs == null)
		qs=location.search.substring(1,location.search.length)
	if (qs.length == 0) return
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&')
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}
function Querystring_get(key, default_) {
	if (default_ == null) default_ = null;
	var value=this.params[key]
	if (value==null) value=default_;
	return value
}
function createAlertShortCode(showid){
	var clientRnd=Math.round(Math.random()*9999);
	window.open("/common/Sms/alert.php?randcode="+clientRnd+"&smscode="+showid,"smsalert","scrollbars=no,resizable=no,status=no,height=257,width=487");
}
function voteOnThisChart(TrackId,WeekId,ChartId,SuccessPage){
	document.location.href="/common/Charts/vote.php?TrackId="+TrackId+"&WeekId="+WeekId+"&ChartId="+ChartId+"&SuccessPage="+SuccessPage;
}
function goMusicShop(ArtistId,CountryId){
	if(CountryId==1||CountryId==2||CountryId==3||CountryId==4){
		document.location.href='/common/goMusicShop.php?ArtistId='+ArtistId+'&CountryId='+CountryId
	}else{
		alert('No MTV music shop is available in your country.\nSorry for the inconvenience.\n\n/MTVe.com')
	}
}
function checkFormComp(f,q,m){
	if(f.CompEntryName.value==""){
		alert('Your name?');
		f.CompEntryName.focus();
		return false;
	}else if (f.CompEntryEmail.value.indexOf("@", 0)<1||f.CompEntryEmail.value.indexOf(".", 0)<1||f.CompEntryEmail.value.length<5){
		alert('Your email address, please.');
		f.CompEntryEmail.focus();
		return false;
	}else if(f.CompEntryAddress.value==""){
		alert('Your address?');
		f.CompEntryAddress.focus();
		return false;
	}else if(!f.legal.checked){
		alert('You have to read the legal stuff first...');
		return false;
	}else if(f.CompEntryPostadress.value==""){
		alert('Post address?');
		f.CompEntryPostadress.focus();
		return false;
	}else if(f.CompEntryCity.value==""){
		alert('Which city do you live in?');
		f.CompEntryPostadress.focus();
		return false;	
	}else if(f.CompEntryPhone.value==""){
		alert('Phone number?');
		f.CompEntryPhone.focus();
		return false;
	}else if(f.CompEntryCountry.value==""){
		alert('Where are you from?');
		f.CompEntryCountry.focus();
		return false;
	}else if(f.CompEntryBirthyear.value==""){
		alert('When were you born?');
		f.CompEntryBirthyear.focus();
		return false;
	}else if(f.CompEntryGender.value==""){
		alert('Boy or girl?');
		f.CompEntryGender.focus();
		return false;		
	}else if(m==1){
		if(f.CompMotivate.value==""){
			alert('Write something... or else you won\'t win!');
			f.CompMotivate.focus();
			return false;
		}
	}else{
		for(i=1;i<=q;i++){
			if(f.elements["CompQuestion"+i+"Selected"].value==""){
				alert('One or more questions are unanswered!')
				return false;
			}
		}
		return true;
	}
}
function pop(path,width,height,scroll,windowname){
	if(windowname==null){
		windowname="defaultwindowname";
	}
	var x = width, y = height, uri = path;
	var x_off = Math.floor((screen.availWidth - x) / 2), y_off = Math.floor((screen.availHeight - y) / 2);	
	var popwin = window.open(uri,'popwin','toolbar=0,menubar=0,location=0,status=0,width=' + x + ',height=' + y + ',top=' + y_off + ',left=' + x_off + ',scrollbars='+scroll);
}
function launchFlip(path){
	var x = 405, y = 500, uri = '/common/flipbook/index.php?path='+path;
	var x_off = Math.floor((screen.availWidth - x) / 2), y_off = Math.floor((screen.availHeight - y) / 2);	
	var mtvflip = window.open(uri,'mtvflipbook','toolbar=0,menubar=0,location=0,status=0,width=' + x + ',height=' + y + ',top=' + y_off + ',left=' + x_off + ',scrollbars=no');
}
function launchVideo(TrackId){
	var qs = new Querystring();
	var v1 = qs.get("ArticleId");
	var x = 605, y = 455, uri = '/common/mediaplayer/playMedia_big2.php?TrackId='+TrackId+'&ArticleId='+v1;
	var x_off = Math.floor((screen.availWidth - x) / 2), y_off = Math.floor((screen.availHeight - y) / 2);	
	var mtvstream = window.open(uri,'mtvstream','toolbar=0,menubar=0,location=0,status=0,width=' + x + ',height=' + y + ',top=' + y_off + ',left=' + x_off + ',scrollbars=no');
}
function launchVideoNew(TrackId,ArticleId){
	var qs = new Querystring();
	var v1 = qs.get("ArticleId");
	var x = 605, y = 455, uri = '/common/mediaplayer/playMedia_big2.php?TrackId='+TrackId+'&ArticleId='+v1;
	var x_off = Math.floor((screen.availWidth - x) / 2), y_off = Math.floor((screen.availHeight - y) / 2);	
	var mtvstream = window.open(uri,'mtvstream','toolbar=0,menubar=0,location=0,status=0,width=' + x + ',height=' + y + ',top=' + y_off + ',left=' + x_off + ',scrollbars=no');
}
function launchTellUs(ArticleId){
	var x = 500, y = 110, uri = '/common/youtellus/index.php?ArticleId='+ArticleId;
	var x_off = Math.floor((screen.availWidth - x) / 2), y_off = Math.floor((screen.availHeight - y) / 2);	
	var mtvtellus = window.open(uri,'mtvtellus','toolbar=0,menubar=0,location=0,status=0,width=' + x + ',height=' + y + ',top=' + y_off + ',left=' + x_off + ',scrollbars=no');

}
function Poll(Page,QuestionId,OptionId,ArticleId){
	var x = 414, y = 414, uri = '/common/poll/'+Page+'.php?QuestionId='+QuestionId+'&OptionId='+OptionId+'&ArticleId='+ArticleId;
	var x_off = Math.floor((screen.availWidth - x) / 2), y_off = Math.floor((screen.availHeight - y) / 2);	
	var mtvflip = window.open(uri,'mtvflipbook','toolbar=0,menubar=0,location=0,status=0,width=' + x + ',height=' + y + ',top=' + y_off + ',left=' + x_off + ',scrollbars=yes');
	//opener.location.reload(1);
}
function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return "";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;
	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) != w_space){
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	}
	return strTemp;
}
function ShopPrintIframe(type,id){
	var mtve_randomnumber=Math.floor(Math.random()*100000)
	if(type==1){
		document.write('<iframe src="http://www.mtve.com/feeds/shop/bigpush.php?ArticleId='+id+'&r='+mtve_randomnumber+'" style="width: 529px; height: 250px" border="0" frameborder="0" scrolling="no"></iframe>');
	}else if(type==2){
		document.write('<iframe src="http://www.mtve.com/feeds/shop/chartstop.php?ArticleId='+id+'&r='+mtve_randomnumber+'" style="width: 529px; height: 52px" border="0" frameborder="0" scrolling="no"></iframe>');	
	}else if(type==3){
		document.write('<iframe src="http://www.mtve.com/feeds/shop/recommends.php?CountryId='+id+'&r='+mtve_randomnumber+'" style="width: 529px; height: 273px" border="0" frameborder="0" scrolling="no"></iframe>');	
	}
}

// IFR START
var required = 6;
var hasFlash = false;
if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Windows") != -1){
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('hasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & required))) \n');  
	document.write('<'+'/scr' + 'ipt\> \n');
	}
else {
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])?navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin:0;
	if (plugin) {
		var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
		var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		hasFlash = flashVersion >= required;
		}
	}
if (hasFlash && document.getElementsByTagName && document.getElementsByTagName('html')[0]) {
	document.getElementsByTagName('html')[0].className += (document.getElementsByTagName('html')[0].className=='')?'hasFlash':' hasFlash';
	}
function SI_normalizeWhiteSpace(txt) {
	var rE = /\s+/gi;
	return txt.replace(rE,' ');
	}
function SI_forceRedraw() {
	var d = document;
	if (d.body && d.body.style) {
		d.body.style.height = "1px";
		d.body.style.height = "auto";
		}
	}
function SI_replaceElement(elem,swf,w,ppr,maxch,afv) {
	var d = document;
	
	if (!hasFlash || !d.getElementsByTagName) return;
	
	var r = new Object();
	r.p = new Object();
	r.e = new Object();
	
	if (elem.indexOf('>')!=-1) {
		elemArray = elem.split('>');
		elem = elemArray[1];
		if (elemArray[0].indexOf('#')!=-1) {
			parentArray = elemArray[0].split('#');
			r.p.id 		  = parentArray[1];
			r.p.tagName	  = parentArray[0];
			r.p.className = false;
			}
		else if (elemArray[0].indexOf('.')!=-1) {
			parentArray = elemArray[0].split('.');
			r.p.id 		  = false;
			r.p.tagName	  = parentArray[0];
			r.p.className = parentArray[1];
			}
		else {
			r.p.id		  = false;
			r.p.tagName	  = elemArray[0];
			r.p.className = false;
			}
		}
	else {
		r.p.id		  = false;
		r.p.tagName	  = false;
		r.p.className = false;
		}
	
	if (elem.indexOf('#')!=-1) {
		elemArray = elem.split('#');
		r.e.id 		  = elemArray[1];
		r.e.tagName	  = elemArray[0];
		r.e.className = false;
		}
	else if (elem.indexOf('.')!=-1) {
		elemArray = elem.split('.');
		r.e.id 		  = false;
		r.e.tagName	  = elemArray[0];
		r.e.className = elemArray[1];
		}
	else {
		r.e.id		  = false;
		r.e.tagName	  = elem;
		r.e.className = false;
		}
	
	if (afv!='') {
		afv = SI_normalizeWhiteSpace(afv);
		afv = '&'+afv;
		}
	
	var elems = d.getElementsByTagName(r.e.tagName);
	var count = elems.length;
	for (var i=0; i<count; i++) {
		e = elems[i];
		if (!r.p.tagName || (((r.p.tagName && !r.p.id && !r.p.className && e.parentNode.nodeName==r.p.tagName.toUpperCase()) || ((r.p.id && e.parentNode.id==r.p.id) || (r.p.className && e.parentNode.className==r.p.className))))) {
			if ((r.e.tagName && !r.e.id && !r.e.className) || (r.e.id && e.id==r.e.id) || (r.e.className && e.className==r.e.className)) {
				var txt;
				txt = SI_normalizeWhiteSpace(e.innerHTML);
				var c = d.createElement('div');
				c.className = 'replaced-'+r.e.tagName;
				e.parentNode.replaceChild(c,e);
				count--;
				i--;

				txt=txt.replace(/"/gi, '\'\'');
				maxchars=maxch;
				lines=0;
				subTextAll = "";
				do
				{
					if(txt.length > maxchars)
					{
						spaceIndex = txt.lastIndexOf(" ", maxchars);
						if(spaceIndex >= 0)
						{
							subText = txt.substring(0, spaceIndex)+"<br/>";
							lines++;
							txt = txt.substring(spaceIndex, txt.length);
						}
						else
						{
							subText = txt;
							txt = "";
						}
					}
					else
					{
						subText = txt;
						txt = "";
					}
					subTextAll += LTrim(subText);
								
				} while(txt.length > 0);
				h=(lines+1)*ppr;


				var fv	= 'txt='+subTextAll+afv;
				var swfHTML;
				
				swfHTML  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+w+'" height="'+h+'">';
				swfHTML += '	<param name="movie" value="'+swf+'" />';
				swfHTML += '	<param name="flashvars" value="'+fv+'" />';
				swfHTML += '	<param name=wmode value="transparent" />';			
				swfHTML += '	<embed src="'+swf+'" flashvars="'+fv+'" width="'+w+'" height="'+h+'" wmode="transparent" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />';
				swfHTML += '<'+'/object>';
				c.innerHTML = swfHTML;
				txt='';
				

				}
			}
		
		}
	}
	
function SI_flashReplacement() {
	// here you can specify other flashfiles to print text within... copy/paste line one and edit
	SI_replaceElement('div#primary-content>h1','http://www.mtve.com/images/flash/h1.swf',323,19,21,''); // args: divname, path to flash, width, rowheight, maxchars per row for font used
	SI_replaceElement('div#primary-content>h2','http://www.mtve.com/images/flash/h2.swf',323,12,40,''); // args: divname, path to flash, width, rowheight, maxchars per row for font used
	SI_replaceElement('div#primary-content>h4','http://www.mtve.com/images/flash/h2.swf',400,12,80,''); // args: divname, path to flash, width, rowheight, maxchars per row for font used
	SI_replaceElement('div#primary-content>h3','http://www.mtve.com/images/flash/h3.swf',323,33,13,''); // args: divname, path to flash, width, rowheight, maxchars per row for font used
	SI_replaceElement('div#primary-content>h5','http://www.mtve.com/images/flash/h5.swf',250,12,40,''); // args: divname, path to flash, width, rowheight, maxchars per row for font used
	SI_replaceElement('div#primary-content>h6','http://www.mtve.com/images/flash/h1.swf',500,19,40,''); // args: divname, path to flash, width, rowheight, maxchars per row for font used
	SI_replaceElement('div#shop-content>h1','http://www.mtve.com/images/flash/h7.swf',217,14,30,''); // args: divname, path to flash, width, rowheight, maxchars per row for font used	
	SI_replaceElement('div#shop-content>h5','http://www.mtve.com/images/flash/h5shop.swf',222,14,37,''); // args: divname, path to flash, width, rowheight, maxchars per row for font used	
	SI_forceRedraw();
}
function SI_onload() {
	SI_flashReplacement();
	} 
window.onload = SI_onload;
// IFR END
