/** **********************************************************
  *  Filepath: C:/Work/kSolo/Java Project/src/jsp/js/globalJavaScripts.js
  *  Author         : Yadid Ramot
  *  Creation Date  : Thu - Dec 23, 2004
  *  this file contain all the skin requierments(hide stuff, fix positions, etc...)
  * ********************************************************** */

			var maxHeight = 0;
			//window.status = 0;
			var fixPositionTimeout;
			var refreshPositions = 0;

			function fixPositions(sss){			    
					//clearInterval(fixPositionTimeout);					
					//fixEm();					
					//fixPositionTimeout = setInterval("fixEm()", 100);
			}

			function sfixEm(){}
	
			function fixEm(){	
			    /*		    
				var oldMaxHeight = maxHeight;
                
                /*if ($("leftNavigationLinks") == null && $("browseGenres") == null && $("browseSongs") == null
                        && $("searchNavigator") != null) {
                    $("searchNavigator").className = "alternate";                    
                }
                
				if(document.getElementById("leftNavigationLinks") && document.getElementById("browseSongs")){
					fixPositionForElement("leftNavigationLinks","browseSongs");
				}else if(document.getElementById("searchNavigator") && document.getElementById("browseSongs")){
					fixPositionForElement("searchNavigator","browseSongs");
				}
    
				fixPositionForElement("browseSongs","browseGenres");
								
				fixPositionForElement("pageStandartGlobalPromo","bodyContainer");


				if(document.getElementById("bodyContainer") ){				    
				    if (document.searchActionForm != null && document.searchActionForm.action.toLowerCase().indexOf("searchartistallartists") != -1)   //fix the all artist, top artist pages
				        $("bodyContainer").style.height = $("searchResults").offsetHeight - 300 + "px";				    
				    else
					    fixPositionForElement("bodyContainer","searchResults");					    
				}else if(document.getElementById("pageStandartGlobalPromo")){
					fixPositionForElement("pageStandartGlobalPromo","searchResults");
				}

				/*fixPositionForElement("membersLogin","performersShowCase");
                                
				fixPositionForElement("performersShowCase","inviteafriend");
				if(document.getElementById("topPerformers")){
					fixPositionForElement("inviteafriend","topPerformers");
				}else{
					fixPositionForElement("inviteafriend","songList");
				}
				                                
				
				
				
				// only for user profile
				if(
					document.getElementById("globalDetails") && 
					document.getElementById("userTitle") && 
					document.getElementById("userPhotos") && 
					document.getElementById("moreAboutMe") && 
					document.getElementById("profile")
				){
					try{
						fixPositionForElement("globalDetails","userTitle");
						fixPositionForElement("userTitle","userPhotos");
						
						fixPositionForElement("userPhotos","moreAboutMe");
						fixPositionForElement("userPhotos","profile");
						try{fixPositionForElement("userPhotos","showMySpaceProfile");}catch(e){}
		
						
						var sitckWho = "";
						var sitckWhere = "";
		
						if(document.getElementById("myFansContainer")){
							sitckWho = "myFansContainer";
						}else if(document.getElementById("becomeAFan")){
							sitckWho = "becomeAFan";
						}else if(document.getElementById("myFavoriteContainer")){
							sitckWho = "myFavoriteContainer";
						}
		
						if(document.getElementById("moreAboutMe").style.display != "none"){
							sitckWhere = "moreAboutMe";
						}else{
							sitckWhere = "profile";
						}
						if(sitckWho != "" && sitckWhere != ""){
							fixPositionForElement(sitckWhere,sitckWho);
						}
						if(document.getElementById("myFavoriteContainer")){
							if(sitckWho != "myFavoriteContainer"){
								fixPositionForElement(sitckWho,"myFavoriteContainer");
							}
						}
						
						fixPositionForElement("searchResults","toolbar2");
						fixPositionForElement("feedbacksContainer","toolbar3");
						if(document.getElementById("searchNavigator")){
							fixPositionForElement("bodyContainer","searchNavigator");
						}
		
					}catch(e){}
				}
				
				
				
				if(document.getElementById("searchResults2")){
					fixPositionForElement("searchResults","searchResults2");
				}
				if(document.getElementById("searchResults3")){
					fixPositionForElement("searchResults2","searchResults3");
				}

				if(document.getElementById("feedbacksContainer")){
					fixPositionForElement("searchResults","feedbacksContainer");
				}

				if(document.getElementById("searchNavigator")){
					fixPositionForElement("bodyContainer","searchNavigator");
				}
								
                //phong - fix the height of body too short in artist page
                /*if (maxHeight < 1200)
                    maxHeight = 1200;
				document.getElementById("bodyWrapper").style.height = maxHeight - 50 + "px";								

				if(maxHeight==oldMaxHeight){
					refreshPositions++;
				}

				if(refreshPositions>10){
					clearInterval(fixPositionTimeout);
					refreshPositions = 0;
				}
				
				try {
				    if (document.searchActionForm != null && document.searchActionForm.action.toLowerCase().indexOf("searchsongbyartistid") != -1) {  //fix artist by id page
		                $("searchResults2").style.paddingTop = "0px";		        
		                $("searchResults3").style.paddingTop = "0px";		        
		                $("bodyWrapper").style.height = $("bodyWrapper").offsetHeight - 477 - 307 + "px";		            
		            }		        		        
		        } catch(e) {}
		        
				try {document.getElementById("searchNavigator").style.display = "block";} catch(e) {}
				*/				
			}



			function fixPositionForElement(_topElemnt,_bottomElemnt){

				var topElementObj = document.getElementById(_topElemnt);
				var bottomElementObj = document.getElementById(_bottomElemnt);

				try{
					var bottomElementTop = parseInt(topElementObj.offsetHeight) + parseInt(topElementObj.offsetTop);
					if(_bottomElemnt == "searchResults"){
						bottomElementObj.style.paddingTop = bottomElementTop + "px";
					}else if(	_bottomElemnt != "searchResults2" && 
								_bottomElemnt != "searchResults3" &&
								_bottomElemnt != "searchNavigator"
								){
						bottomElementObj.style.top = bottomElementTop + "px";
					}									
				}catch(e){}

				// set the max height for the page
				if(bottomElementObj) maxHeight = Math.max(maxHeight,bottomElementObj.offsetTop + bottomElementObj.offsetHeight);
				if(topElementObj) maxHeight = Math.max(maxHeight,topElementObj.offsetTop + topElementObj.offsetHeight);                
			}



			function fixUpper(){
				str = document.getElementById("bodyWrapper").offsetHeight;
				str += "px";
				if(this.name){
					if (parent.document.getElementById(this.name)){
						parent.document.getElementById(this.name).style.height = str;
						//parent.fixPositions('');
					}
					if (parent.frameLoaded){
						parent.frameLoaded();
					}
				}
			}



			function setFocusOnAfterOperation(){
				top.scrollTo(0,180);
			}
			
			function fixSongListAndInviteYourFriends() {
			    try {					        
                    if ($("topPerformers") != null) {                                        
                        if ($("addThisWidget") != null) {                            
                            $("performersShowCase").style.top = "189px";
                            $("topPerformers").style.top = "252px";
                            //$("inviteafriend").style.top = "734px";                    
                            $("inviteafriend").style.top = $("topPerformers").offsetTop + $("topPerformers").offsetHeight + 4 + "px";                    
                            $("addThisWidget").style.top = "168px";
                        }
                        else {                            
                            $("performersShowCase").style.top = "170px";
                            $("topPerformers").style.top = "233px";
                            //$("inviteafriend").style.top = "714px";     
                            $("inviteafriend").style.top = $("topPerformers").offsetTop + $("topPerformers").offsetHeight + 4 + "px";
                        }                        
                    }
                    else if ($("songList") != null) {
                        if ($("addThisWidget") != null) {                            
                            $("performersShowCase").style.top = "189px";
                            $("songList").style.top = "266px";
                            $("inviteafriend").style.top = $("songList").offsetTop + $("songList").offsetHeight + 4 + "px";
                            //$("inviteafriend").style.top = "748px";                    
                            $("addThisWidget").style.top = "168px";                            
                        }
                        else {                        
                            $("performersShowCase").style.top = "170px";
                            $("songList").style.top = "249px";
                            $("inviteafriend").style.top = $("songList").offsetTop + $("songList").offsetHeight + 4 + "px";
                            //$("inviteafriend").style.top = "728px";                                
                        }
                    }				
                } catch(e) {}
			}
			
			function fixLeftNavMenu() {
			    try {		
			        //my webpage, my recoridngs, my library, my feedback, my fans, my favorites	        
			        if ($("leftNavigationLinks") != null && $("browseGenres") != null && $("browseSongs") != null) {			            
				        $("browseSongs").style.top = "257px";
				        $("browseGenres").style.top = "394px";						        
				    }
				    
				    if (document.searchActionForm != null &&
	                        (document.searchActionForm.action.toLowerCase().indexOf("searchsongtopprebuild.do") != -1 || //this is for Most Popular Song List
	                        document.searchActionForm.action.toLowerCase().indexOf("topartists=1") != -1)) { //this is for Top Artists List
				        $("browseSongs").style.top = $("browseSongs").offsetTop + 92 + "px";
		                $("browseGenres").style.top = $("browseGenres").offsetTop + 92 + "px";			                
				    }
				    
				    if ($("time") == null && $("age") != null) {						        				        
		                $("browseSongs").style.top = $("browseSongs").offsetTop - 88 + "px";
		                $("browseGenres").style.top = $("browseGenres").offsetTop - 92 + "px";		                		                			                	                
		            }
		            else if (document.searchActionForm != null &&
		                        (document.searchActionForm.action.toLowerCase().indexOf("searchperformersfeaturedperformers.do") != -1 ||
		                        document.searchActionForm.action.toLowerCase().indexOf("searchperformers.do") != -1 &&
		                         document.searchActionForm.songname.value == "")) {		        		        		            
		                $("browseSongs").style.top = $("browseSongs").offsetTop - 370 + "px";
		                $("browseGenres").style.top = $("browseGenres").offsetTop - 370 + "px";		                
		            }		    
			    } catch(e) {}
			}


if (!document.all) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;

var tooltipObject;

var mouseX = 0;
var mouseY = 0;

function getMouseXY(e) {

	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body

	var tempX = 0
	var tempY = 0

	if (document.all) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + iebody.scrollLeft;
		tempY = event.clientY + iebody.scrollTop;
	} else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX
		tempY = e.pageY
	}

	// show the position values in the form named Show
	// in the text fields named MouseX and MouseY

	mouseX = tempX;
	mouseY = tempY;

	return true;
}

/*
function getTooltip(){
	tooltipObject = document.getElementById("toolTip");
}
function showTooltip(_val){
	if(!tooltipObject) getTooltip();

		if(!isTooltipVisible()){
			tooltipObject.className = "visibleTooltip";
			tooltipObject.innerHTML = _val;

			var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
			var winW = 0;
			var winH = 0;
			var scrollx = (document.all) ? iebody.scrollLeft : window.pageXOffset;
			var scrolly = (document.all) ? iebody.scrollTop : window.pageYOffset;

			if (parseInt(navigator.appVersion)>3) { // get window size
				if (navigator.appName=="Netscape") {
					winW = window.innerWidth;
					winH = window.innerHeight;
				}
				if (navigator.appName.indexOf("Microsoft")!=-1) {
					winW = iebody.offsetWidth;
					winH = iebody.offsetHeight;
				}
			}
			winW -= 20-scrollx; //scrolls
			winH -= 20-scrolly;

			var tooltipHeight = parseInt(tooltipObject.offsetHeight);
			var tooltipWidth = parseInt(tooltipObject.offsetWidth);

			var tooltipY = mouseY;
			var tooltipX = mouseX;

			// catch possible negative values in NS4
			if (tooltipX < 0){tooltipX = 0}
			if (tooltipY < 0){tooltipY = 0}
			tooltipX+=20;
			tooltipY+=20;

			if(tooltipY + tooltipHeight > winH) tooltipY = winH-tooltipHeight;
			if(tooltipX + tooltipWidth > winW) tooltipX = winW-tooltipWidth;


			tooltipObject.style.top = tooltipY + "px";
			tooltipObject.style.left = tooltipX + "px";                            
		}

}

function hideTooltip(){
	if(tooltipObject){
		if(isTooltipVisible()){
			tooltipObject.className = "hiddenTooltip";
			tooltipObject.innerHTML = "";
			tooltipObject.style.top = 0;
			tooltipObject.style.left = 0;
		}
	}
}
function isTooltipVisible(){
	if(!tooltipObject) return false;
	if(tooltipObject.className != "visibleTooltip") return false;

	return true;
}
*/