﻿function showPopup(obj, id,type, isHP){
	if(!isHP){
		oParent = obj.offsetParent
		if(oParent.tagName != "LI") oParent = obj.offsetParent.offsetParent
		oParentT = oParent.offsetTop
		oParentL =oParent.offsetLeft	
	}else{
		oParent = obj
		//if(oParent.tagName != "LI") oParent = obj.offsetParent.offsetParent
		oParentT = oParent.offsetTop + 120
		oParentL =oParent.offsetLeft	
		//alert(oParentL)
		
	}
	
	

	if(!isHP){
		if(id > 10  ){
			$('domPop').style.top = (oParentT + 50).toString() + 'px'
			if(oParentL>300) oParentL = 240
			$('domPop').style.left = [oParentL + 10].toString() + 'px'
			
		}else{
			$('domPop').style.top = (oParentT + 70).toString() + 'px'
			$('domPop').style.left ='170px'
			
		}
	}else{
		$('domPop').style.top = (oParentT + 60).toString() + 'px'
		if(oParentL>320) oParentL = 240
		$('domPop').style.left = [oParentL + 10].toString() + 'px'
		
		
	}
	var cf
	switch(type){
		case 'movies':
			cf = "cf_getMovieForDomPop"
		break;
		case 'moviesHP':
			cf = "cf_getMovieForDomPopHP"
		break;
		case 'songs':
			cf = "cf_getSongForDomPop"
		break;
		case "serios":
		
			cf = "cf_getSeriosForDomPop"
		break
		case "seriosHP":
		
			cf = "cf_getSeriosForDomPopHP"
		break
		
	}
	$('domPop').loadData(id, cf)
	
	//alert(obj.offsetParent.offsetParent.offsetHeight)
	
}
function domPopBehavior(){
	var ME = this
	var divs =  ME.getElementsByTagName("DIV")
	closeBut =divs[0]
	var dataHolder = divs[1]
	closeBut.onclick=function(){
		ME.style.display = 'none'	
		dataHolder.innerHTML = ""
		
	}
	
	ME.loadData = function(sId, cf){
		
		
		ME.style.display = 'block'
		var conn = new _service
		conn.synchronic = false
		conn.onLoad = insertHtml
		htm = conn.invoke('test',cf, sId)
		
	}
	function insertHtml(ret){
		dataHolder.innerHTML = ret
		//console.log(ret)
		
	}
	
	
}

$('domPop').startMe = domPopBehavior
$('domPop').startMe()