
function openWin(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function openGallery(galId) {
	openWin('gallery/?gid=' + galId, '', 'width=700,height=563');
}

function openGalleryToPic(galId, picId) {
	openWin('gallery/?gid=' + galId + '&pic=' + picId, '', 'width=700,height=563');	
}

function openArticleGallery(galId, picId) {
	openWin('gallery/?gid=' + galId + '&pic=' + picId + '&articlemode=true', '', 'width=700,height=563');
}

function sendByMail(whatId, title) {
	openWin('windows_various/sendbymail/?id=' + whatId + '&title=' + title, '', 'width=450,height=425');
}

function sendByMailToEditor(whatId) {
	openWin('windows_various/sendbymail_toeditor/?id=' + whatId, '', 'width=450,height=425');
}

function getFile(fileId) {
	window.open('/app/getfile/?fid=' + fileId);
}

function getRandomNum(Min, Max) {
	var r;
	r = (Math.floor(Math.random() * ((Max+1) - Min)) + Min)
	return r;
}

function pollVote(a, b) {
	openWin('pollsys/results.aspx?voteid=' + a + '&survey=' + b,'','scrollbars=yes, width=530,height=360');
}

function pollVoteDirect(a, b) {
	location.href = 'results.aspx?voteid=' + a + '&survey=' + b;
}

function saveArticle(aid, title) {
	var url;
	url = 'http://www.listindiario.com/app/article.aspx?id=' + aid;
	var ttl;
	ttl = 'Listin Diario Digital - ' + title;
	if (window.sidebar && window.sidebar.addPanel) { 
		window.sidebar.addPanel(ttl, url,''); 
	} else if(window.external) {
		window.external.AddFavorite(url, ttl);
	} else {
		alert('Su navegador no soporta esta opción. Por favor realícela manualmente.');
	}
}

function TopSrch_Now(SrchString) {

	var s;
	s = SrchString;

	if(s.replace(/\s/gi, "").length < 3) {
		alert('Debe escribir el texto de búsqueda.');
	} else {

		location.href = 'search.aspx?m=1&s=' + escape(s);
	}

	return false;

}

//

function MD_ShowVid(path, w, h) {
	openWin('/serve/videopopup.aspx?1='+w+'&2='+h+'&3='+escape(path),'','width=100,height=100,scrollbars=yes')
}

function MD_ShowVidArt(path, w, h, id, len) {
	
	var vh = '';
	vh += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="224" height="215">';
	vh += '<param name="movie" value="../app/swf/md_playerFLV.swf?f1='+escape(path)+'&f2='+escape(w)+'&f3='+escape(h)+'&f4='+escape(len)+'">';
	vh += '<param name="quality" value="high">';
	vh += '<embed src="../app/swf/md_playerFLV.swf?f1='+escape(path)+'&f2='+escape(w)+'&f3='+escape(h)+'&f4='+escape(len)+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="224" height="215"></embed>';
	vh += '</object>';
	document.getElementById('VidHolderPic_' + id).style.display = 'none';
	document.getElementById('VidHolderBar_' + id).style.display = 'none';
	document.getElementById('VidHolderPlayer_' + id).style.display = 'block';
	document.getElementById('VidHolderPlayer_' + id).innerHTML = vh;
	
}


function MD_ShowAud(path) {
	openWin('/serve/audiopopup.aspx?1='+escape(path),'','width=100,height=100,scrollbars=yes')
}

//

function enUnClick(dc, q) {
	
	var i;
	var current = 0;
	
	q = q - 1;
	
	for(i=0;i<=q;i++) {
		if(document.getElementById('enUnClick'+i)) {
			if(document.getElementById('enUnClick'+i).style.display == '') {
				if(dc=='n') {
					current = i+1;
				} else {
					current = i-1;
				}
			}
			document.getElementById('enUnClick'+i).style.display = 'none';
		}
	}
	
	if(current < 0) { current = q; }
	if(current > q) { current = 0; }	
	
	document.getElementById('enUnClickCurrentNews'+current).innerHTML = current + 1;
	document.getElementById('enUnClick'+current).style.display = '';
	
}

//

function rdPics(dc, q) {
	
	var i;
	var current = 0;
	var prev = 0;
	var currentImg;
	
	q = q - 1;
	
	for(i=0;i<=q;i++) {
		if(document.getElementById('rdPicsDiv'+i)) {
			if(document.getElementById('rdPicsDiv'+i).style.display == '') {
				if(dc=='n') {
					current = i+1;
					prev = i;
					currentImg = document.getElementById('rdPicsImg'+i).src;
				} else {
					current = i-1;
					prev = i;
					currentImg = document.getElementById('rdPicsImg'+i).src;
				}
			}
			document.getElementById('rdPicsDiv'+i).style.display = 'none';
		}
	}
	
	if(current < 0) { current = q; }
	if(current > q) { current = 0; }	
	
	document.getElementById('rdPicsCurrentIndex').innerHTML = current + 1;
	document.getElementById('rdPicsImg'+current).src = currentImg;
	document.getElementById('rdPicsImg'+current).src = rdPicsArray[current];
	document.getElementById('rdPicsDiv'+current).style.display = '';
	
}

function rdPicsAndVids(dc, q) {
	
	var i;
	var current = 0;
	var prev = 0;
	var currentImg;
	
	q = q - 1;
	
	for(i=0;i<=q;i++) {
		if(document.getElementById('rdPicsDiv'+i)) {
			if(document.getElementById('rdPicsDiv'+i).style.display == '') {
				if(dc=='n') {
					current = i+1;
					prev = i;
					//currentImg = document.getElementById('rdPicsImg'+i).src;
				} else {
					current = i-1;
					prev = i;
					//currentImg = document.getElementById('rdPicsImg'+i).src;
				}
			}
			document.getElementById('rdPicsDiv'+i).style.display = 'none';
		}
	}
	
	if(current < 0) { current = q; }
	if(current > q) { current = 0; }	
	
	document.getElementById('rdPicsCurrentIndex').innerHTML = current + 1;
	//document.getElementById('rdPicsImg'+current).src = currentImg;
	//document.getElementById('rdPicsImg'+current).src = rdPicsArray[current];
	
	if(rdPicsArray[current].split('|')[0] == 'img') {
		document.getElementById('rdPicsImg'+current).src = rdPicsArray[current].split('|')[1];
	} else {
		var vW = rdPicsArray[current].split('|')[2].split(',')[0];
		var vH = rdPicsArray[current].split('|')[2].split(',')[1];
		var vT = rdPicsArray[current].split('|')[2].split(',')[2];
		var vidHtml = '';
		vidHtml += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="300" height="300">';
		vidHtml += '<param name="movie" value="swf/md_playerFLV.swf?f1='+(rdPicsArray[current].split('|')[1])+'&f2='+vW+'&f3='+vH+'&f4='+vT+'">';
		vidHtml += '<param name="quality" value="high">';
		vidHtml += '<embed src="swf/md_playerFLV.swf?f1='+(rdPicsArray[current].split('|')[1])+'&f2='+vW+'&f3='+vH+'&f4='+vT+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="300" height="300"></embed>';
		vidHtml += '</object>'
		document.getElementById('rdPicsDivVid'+current).innerHTML = vidHtml;
		
	}
	
	document.getElementById('rdPicsDiv'+current).style.display = '';
	
}

function rdPicsAndVidsInitVid() {
	var current = 0;
	var vW = rdPicsArray[current].split('|')[2].split(',')[0];
	var vH = rdPicsArray[current].split('|')[2].split(',')[1];
	var vT = rdPicsArray[current].split('|')[2].split(',')[2];
	var vidHtml = '';
	vidHtml += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="300" height="300">';
	vidHtml += '<param name="movie" value="swf/md_playerFLV.swf?f1='+(rdPicsArray[current].split('|')[1])+'&f2='+vW+'&f3='+vH+'&f4='+vT+'">';
	vidHtml += '<param name="quality" value="high">';
	vidHtml += '<embed src="swf/md_playerFLV.swf?f1='+(rdPicsArray[current].split('|')[1])+'&f2='+vW+'&f3='+vH+'&f4='+vT+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="300" height="300"></embed>';
	vidHtml += '</object>'
	document.getElementById('rdPicsDivVid'+current).innerHTML = vidHtml;
}

//

function MD_InsertMailLink(p1, p2, htmlTemplate) {

	var emx;
	emx = p1 + '@' + p2;
	
	var genx;
	if(htmlTemplate.indexOf('$emx_here$') == -1) {
		window.status = 'htmlTemplate doesn\'t containe $emx_here$.';
	} else {
		genx = htmlTemplate.replace(/\$emx_here\$/g, emx);
	}

	document.write(genx);
	
}