// JavaScript Document
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

	function getElementsByClass(searchClass,node,tag) {
		var classElements = new Array();
		if ( node == null )
			node = document;
		if ( tag == null )
			tag = '*';
		var els = node.getElementsByTagName(tag);
		var elsLen = els.length;
		var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
		for (i = 0, j = 0; i < elsLen; i++) {
			if ( pattern.test(els[i].className) ) {
				classElements[j] = els[i];
				j++;
			}
		}
		return classElements;
	}



function popmeup(){
	var ditem = getElementsByClass('d-item');
	var _width = 1024+20;
	var _height = 768+20;
	
	var tv_width = 570;
	var tv_height = 430;
	
	
	


var popUpWin = 0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


	function popup (){
	var url = this.href;
	
	if(this.rel =='tvspot'){
	var wint = (screen.height - tv_height) / 3;
	var	winl = (screen.width - tv_width) / 2;
		popUpWindow(url, winl, wint, tv_width,tv_height);
	}
	else{
	var wint = (screen.height - _height) / 3;
	var winl = (screen.width - _width) / 2;
	popUpWindow(url, winl, wint, _width,_height);
	}
		 

		return false;
		}


		for (var i=0; i<ditem.length; i++){
			var links = ditem[i].getElementsByTagName('a');
			for (var y=0; y<links.length; y++){
				links[y].onclick = popup;
				}
			}
			
}
	
	addLoadEvent(popmeup);
	
	
	//



var popWin=0;
function pWin(URLStr, width, height)
{
var wl = (screen.width-width) / 2;
var wt = (screen.height-height) / 3;
	
  if(popWin)
  {
    if(!popWin.closed) popWin.close();
  }
  popWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+wl+', top='+wt+',screenX='+wl+',screenY='+wt+'');
}

