﻿/**
 * @author opher.vishnia
 */

var basePath='';

function closeInformationTopBox()
{
    document.getElementById("divInformationTopBox").style.display="none";
    document.getElementById("ComponentArtInformationTopBox").style.display="none";
}

function pageLoad1(){		
	initSelectBox();
	
	//load main flash
	if (flashBanner=="mainpage"){	
		mainFlashload = new SWFObject("images/flash/mainflash.swf", "mainflash", "901", "217", "8", "#ffffff");
		mainFlashload.addParam("wmode", "opaque");
		mainFlashload.addVariable("XMLsrc", "xml/mainpage_banners.xml");		
		mainFlashload.write("mainFlash")
	} else if (flashBanner=="otherpage"){			
		mainFlashload = new SWFObject("images/flash/secondaryflash.swf", "mainflash", "900", "136", "8", "#ffffff");
		mainFlashload.addParam("wmode", "opaque");
		mainFlashload.addVariable("XMLsrc", theXMLurl);		
		mainFlashload.write("mainFlash")
	}
	
	//load right navigation
	if(loadRightNav){		
		loadXML("xml/rightnav.xml",rightNav);
	}	
	
	//load top navigation
	/*if (loadTopNav){
			topnavigation = new SWFObject("images/flash/mypage_topnav.swf", "navigation", "896", "34", "8", "#ffffff");
			topnavigation.addParam("allowScriptAccess ", "always");
			topnavigation.addParam("wmode", "opaque");
			topnavigation.addVariable("XMLsrc", "xml/mypage_nav.xml");			
			topnavigation.write("navigation");	
										
			navigationMenus=new Array;
			for (var x=0;x<9;x++){
				navigationMenus[x] = new SWFObject("images/flash/topnav_bubble.swf", "menu"+x, "150", "200", "8", "#ffffff");
				navigationMenus[x].addParam("wmode", "transparent");
				navigationMenus[x].addVariable("XMLsrc", "xml/mypage_nav.xml");
				navigationMenus[x].addVariable("navID", x);			
				navigationMenus[x].write("menu"+x+"div")
				document.getElementById("menu"+x+"div").onmouseout=navMouseOut;
				document.getElementById("menu"+x+"div").flashObj=document.getElementById("menu"+x);						
			}		
			
			setInterval(externalInterfacePerform,100)	
	}*/
	
	new Draggable("thePopup");
}

//addLoadEvent(pageLoad);

var xmlDoc;
function loadXML(fileXML, whichfunc)
{
//load xml file
// code for IE
if (window.ActiveXObject)
{
	xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.async=false;	
	xmlDoc.load(fileXML);
	whichfunc();	
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
	xmlDoc=document.implementation.createDocument("","",null);
	xmlDoc.load(fileXML);
	xmlDoc.onload=whichfunc;
}
}

// this functions reads the rightnav button info from the xml and places the flash in the page
var whiterightButtons=new Array()
var bluerightButtons=new Array()
function rightNav(){				
	for (X=0;X<xmlDoc.getElementsByTagName("bluebutton").length;X++){
		bluerightButtons[X] = new SWFObject("images/flash/bluemenubutton.swf", "bluebutton"+X, "124", "58", "8", "#ffffff");
		bluerightButtons[X].addVariable("theText", xmlDoc.getElementsByTagName("bluebutton")[X].getElementsByTagName("caption")[0].childNodes[0].nodeValue);
		bluerightButtons[X].addVariable("theURL", xmlDoc.getElementsByTagName("bluebutton")[X].getElementsByTagName("url")[0].childNodes[0].nodeValue);
		bluerightButtons[X].addVariable("vidfile", xmlDoc.getElementsByTagName("bluebutton")[X].getElementsByTagName("video")[0].childNodes[0].nodeValue);
		if (xmlDoc.getElementsByTagName("bluebutton")[X].getElementsByTagName("url")[0].childNodes[0].nodeValue==currentURL)
			bluerightButtons[X].addVariable("isActive", true);
		bluerightButtons[X].write("bluebuttonDiv"+X)
		}
		
	for (X=0;X<xmlDoc.getElementsByTagName("whitebutton").length;X++){
		whiterightButtons[X] = new SWFObject("images/flash/whitemenubutton.swf", "whitebutton"+X, "124", "42", "8", "#ffffff");
		whiterightButtons[X].addVariable("theText", xmlDoc.getElementsByTagName("whitebutton")[X].getElementsByTagName("caption")[0].childNodes[0].nodeValue);
		whiterightButtons[X].addVariable("theURL", xmlDoc.getElementsByTagName("whitebutton")[X].getElementsByTagName("url")[0].childNodes[0].nodeValue);		
		whiterightButtons[X].write("whitebuttonDiv"+X)
		}						
}

		
var navmenus=new Array("homepage","ringtones","shirimclipim","picsanimations","games","song","sms","myarea");
function topnav(which,event){
//    debugger
//    alert(which.id.substring(which.id.indexOf('_')+1,which.id.length))
    theName = "homepage";
	theName=which.id.substring(which.id.indexOf('_')+1,which.id.length);
	theSubmenu=document.getElementById("submenu_"+theName);	
	theLinks=document.getElementById("submenulinks_"+theName);	
	topBg=document.getElementById("top_"+theName)
	Bg=document.getElementById("bg_"+theName)
	if (event.type=="mouseover"){
		//hide all other menus but the one mouseoverd
		//for (var x=0;x<navmenus.length;x++)
			//document.getElementById("submenu_"+navmenus[x]).style.display="none";
									
		theSubmenu.style.display="block";
					
		if (!theSubmenu.scrolling){
			theLinks.maxH=theLinks.offsetHeight;		
			theLinks.style.height="1px";					
			topBg.style.width=theSubmenu.offsetWidth-12+"px";
			topBg.style.top="0px";
			theSubmenu.scrolling=true;
			topnavScroll(theName);	
			}				
		} else if (event.type=="mouseout") {
			theSubmenu.style.display="none";
			theSubmenu.scrolling=false;			
			theLinks.style.height=theLinks.maxH+"px";
		}	
}

function topnavScroll(which){			
	theName=which;
	theLinks=document.getElementById("submenulinks_"+theName);
	theSubmenu=document.getElementById("submenu_"+theName);	
	rightBg=document.getElementById("right_"+theName)
	leftBg=document.getElementById("left_"+theName)	
	bottomBg=document.getElementById("bottom_"+theName)
	bottomleft=document.getElementById("bottomleft_"+theName)
	bottomright=document.getElementById("bottomright_"+theName)
	horzBg=document.getElementById("horzBg_"+theName);
	vertBg=document.getElementById("vertBg_"+theName);	
	
	var endHeight=theLinks.maxH;
	var currentHeight=parseInt(theLinks.style.height);	
	var differenceHeight=(endHeight-currentHeight*2);	
	if (differenceHeight>1 && theSubmenu.scrolling){				
		theLinks.style.height=(currentHeight*2)+'px';				
		leftBg.style.height=theSubmenu.offsetHeight-6+"px";			
		rightBg.style.height=theSubmenu.offsetHeight-6+"px";
		bottomBg.style.width=theSubmenu.offsetWidth-12+"px";
		bottomBg.style.top=theSubmenu.offsetHeight+"px";		
		bottomleft.style.top=theSubmenu.offsetHeight+"px";
		bottomright.style.top=theSubmenu.offsetHeight+"px";	
		horzBg.style.height=theLinks.offsetHeight+35+"px";
		vertBg.style.width=theSubmenu.offsetWidth-12+"px";					
		vertBg.style.height=theLinks.offsetHeight+35+"px";
		setTimeout("topnavScroll('"+which+"')",50)				
	} else if (differenceHeight<=1 && theSubmenu.scrolling) { 			
		theLinks.style.height=endHeight+"px";
		leftBg.style.height=theSubmenu.offsetHeight-12+"px";			
		rightBg.style.height=theSubmenu.offsetHeight-12+"px";
		bottomBg.style.top=theSubmenu.offsetHeight-10+"px";		
		bottomleft.style.top=theSubmenu.offsetHeight-10+"px";
		bottomright.style.top=theSubmenu.offsetHeight-10+"px";		
		horzBg.style.height=theSubmenu.offsetHeight-6+"px";
		vertBg.style.height=theSubmenu.offsetHeight-6+"px";				
		theSubmenu.scrolling=false;					
	}		
}

// these functions prevent mouseovers from bubbling up into
function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

function checkMouseEnter (element, evt) {
  if (element.contains && evt.fromElement) {
    return !element.contains(evt.fromElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}
// mouseovers for tabs, got disabld per client request 25/3/07
function tabover(which,e){	
	/*	 
	 if(e.type=="mouseover" && which.className!="activetab")			
		which.getElementsByTagName('div')[3].style.display="block";
	else
	if(e.type=="mouseout")
		which.getElementsByTagName('div')[3].style.display="none";
		*/			
}

// this function parses the DOM and returns elements by name or by another optional attribute
function ElementsByName(rootElement,ElementName,ElementType,optionalAttribute){
	var optAtt=optionalAttribute?optionalAttribute:'name';
	var elementsArray=new Array();	
	var theElements=rootElement.getElementsByTagName(ElementType);	
	for (var x=0;x<theElements.length;x++)
		if (theElements[x].getAttribute(optAtt)==ElementName)
			elementsArray[elementsArray.length]=theElements[x];
	return elementsArray;
}


//returns an array of elements that match full or partial (indexOf) classname
function ElementsByClass(rootElement,ElementClass,ElementType,partialMatch){        
            var elementsArray=new Array();
            var theElements=rootElement.getElementsByTagName(ElementType);                  

            for (var x=0;x<theElements.length;x++){
				      if(partialMatch){
					       if (theElements[x].className.indexOf(ElementClass)>-1){ 
							    elementsArray[elementsArray.length]=theElements[x];
						    }
					  }else{
	                        if (theElements[x].className==ElementClass){ 
							    elementsArray[elementsArray.length]=theElements[x];
						    }
					  }
				}                          

	            return elementsArray;
	}




// in the future, this will hold the AJAX functions for each of the tabs
// functions refer to the value attribute of each of the tabs
var tabsFunctions=new Array();
tabsFunctions["ringtones"]=function(){
	//alert("ringtones AJAX");
}

tabsFunctions["realtones"]=function(){
	//alert("realtones AJAX");
}

function tabclick(whichtab,toChangeHeader,toChangeDivContent){	
	ActivetabsArray=ElementsByClass(whichtab.parentNode,'activetab','div');
	InactivetabsArray=ElementsByClass(whichtab.parentNode,'inactivetab','div');
	
	//join the two arrays of tabs
	tabsArray=ActivetabsArray.concat(InactivetabsArray);
	// turn all buttons to inactive
	for(x=0;x<tabsArray.length;x++)
		{
		tabsArray[x].className="inactivetab";								
		ElementsByName(tabsArray[x],'leftbut','img')[0].src="images/nav/tab_inactive_left.jpg";		
		ElementsByName(tabsArray[x],'rightbut','img')[0].src="images/nav/tab_inactive_right.jpg";		
//		ElementsByName(tabsArray[x],'caption','img')[0].src=ElementsByName(tabsArray[x],'caption','img')[0].src.replace(/on.jpg/,'off.jpg')
		}		
		
	whichtab.className="activetab";	
	//change the header, but only if passed as a parameter
	if (toChangeHeader){
		ElementsByName(whichtab.parentNode.parentNode,'header','img')[0].src=basePath+'images/titles/generalbox_'+whichtab.getAttribute('id')+'.jpg';
		}
	ElementsByName(whichtab,'leftbut','img')[0].src="images/nav/tab_active_left.gif";
	ElementsByName(whichtab,'rightbut','img')[0].src="images/nav/tab_active_right.gif";
//	ElementsByName(whichtab,'caption','img')[0].src=ElementsByName(whichtab,'caption','img')[0].src.replace(/off.jpg/,'on.jpg')	
//	ElementsByClass(whichtab,'tabMouseOver','div')[0].style.display="none";	
	if (tabsFunctions[whichtab.getAttribute('value')]!=null)		
		tabsFunctions[whichtab.getAttribute('value')]();

	//change the div content, true or false
	if(toChangeDivContent){
		   ActiveContentArray=ElementsByClass(whichtab.parentNode.parentNode,'contentActive','div');
		   InActiveContentArray=ElementsByClass(whichtab.parentNode.parentNode,'contentInActive','div');
		   
		   //join the two arrays of content
			contentArray=ActiveContentArray.concat(InActiveContentArray);
			
			for(x=0;x<contentArray.length;x++)
				{
				   contentArray[x].className="contentInActive";								
				}	
				
		   theContentId= document.getElementById(whichtab.id+"_content")
		   theContentId.className="contentActive";	
			
	    }
	
}





// this functions cut the string and add ...
function trimStr3Dots(theStr,amount) {
	var savedname;
	if (theStr.length>amount)
		savedname=theStr.substring(0,amount)+"..."
	else
		savedname=theStr;
		
	return savedname;
}



var globalNavItem ="";

function menuItemHover(obj,siblingClassName){
	var theNavObj = findNextElement(obj,siblingClassName);
	////if(theNavObj.className=='rightNavOff'){
	if(theNavObj.className.indexOf("Off") > -1){
		changeClass(obj);
	  
	  if(obj.className.indexOf("Main") > -1){
		  if( document.getElementById("navTopCap").src.indexOf("On")>-1){
			  document.getElementById("navTopCap").src = document.getElementById("navTopCap").src.replace("On","Off")
			 }else{
			  document.getElementById("navTopCap").src = document.getElementById("navTopCap").src.replace("Off","On")
			 }
	   }
	   
	}	
}


//call it in the html changeClass(this)
function changeClass(obj){
 var trObj
 trObj = obj
   if(trObj.className.indexOf("Off") > -1){
	   trObj.className = trObj.className.replace("Off","On");
   }else{
      trObj.className = trObj.className.replace("On","Off");
   }
}




//SCANS THE PAGE FROM THIS OBJ FORWORD UNTILL THE NEAR ELEMENT WITH REQUESTE CLASSNAME
function findNextElement(obj,cssClass){
	var strClass = new String(obj.nextSibling.className)
	if(strClass.indexOf(cssClass) >-1){
		 return obj.nextSibling;
	}else{
		 return findNextElement(obj.nextSibling,cssClass);
	}
}


	function ChangeImg(theObj){
		    if(theObj.src.indexOf("Off")>-1){
				theObj.src=theObj.src.replace("Off","On");				
			}
			else {										
			    theObj.src=theObj.src.replace("On","Off");
			}		
		}
		




var global_leftHeigth = 0;
var global_leftHeigthClose = 0;
var global_theNavObjToOpen = "";
var global_theNavObjToClose = "";
function openCloseNav(navobj,siblingClassName){

//close the open one when clicked the first time the page is loaded
if(findNextElement(navobj,siblingClassName).className.indexOf('On')>-1)
globalNavItem = findNextElement(navobj,siblingClassName);


	var allNavObj = ElementsByClass(navobj.parentNode,'rightNavO','Div',true);
    var theHeight = 0;
	var theHeightClose = 0;
	
    //closes all the open childes
	var tempCloseObj ="";
	for(i=0;i<allNavObj.length;i++){
		
		if (allNavObj[i].className.indexOf('On')>-1){
			tempCloseObj = allNavObj[i];
			if( document.getElementById("navTopCap").src.indexOf("On")>-1){
			  document.getElementById("navTopCap").src = document.getElementById("navTopCap").src.replace("On","Off")
			 }
			////alert(i)
			
			////alert(theHeight)
		}
		//////allNavObj[i].className = 'rightNavOff';
	}
	theHeightClose = findChildsHeight(tempCloseObj);
	global_leftHeigthClose = theHeightClose;
	global_theNavObjToClose =tempCloseObj;
	animateNavClose(0);
	////tempCloseObj.className = 'rightNavOff';
	
	
	
	
	
	
	
	//alert(findChildsHeight(navobj))
	
	//reset all the open fatehers
	allNavObj = ElementsByClass(navobj.parentNode,'navO','Div',true);
	for(i=0;i<allNavObj.length;i++){
		if(allNavObj[i].className.indexOf("On")>0){
			//allNavObj[i].className = 'navOff';
			if(allNavObj[i].className.indexOf("Main")>0){
			  allNavObj[i].className = 'navOffMain';
			  document.getElementById("navTopCap").src=document.getElementById("navTopCap").src.replace("On","Off");				
			  }else{
			  changeClass(allNavObj[i]);
			  }
		}
	}
	
	////navobj.className = 'navOn';
	//alert(navobj.className)
	//changeClass(navobj) (cant be don)
	if(navobj.className.indexOf("Main")>0){
      navobj.className = 'navOnMain';
	  ChangeImg(document.getElementById("navTopCap")) // FOR THE IMG ON TOP OF THE FIRST MENU ITEM (CUSTOMER REQUEST)
	}else{
      navobj.className = 'navOn';
	}
	

	//open the one clicked
	var theNavObj = findNextElement(navobj,siblingClassName);
    
    
		if(theNavObj.className=='rightNavOff' && globalNavItem != theNavObj){
			theNavObj.className = 'rightNavOn';
			
			//get the child height for the animation
			theHeight = findChildsHeight(theNavObj);
			global_leftHeigth =0;
			global_theNavObjToOpen =theNavObj;

            //removed this. - opher. fade();
			animateNav(theHeight)

			globalNavItem = theNavObj;
		}else{
			theNavObj.className = 'rightNavOff';
				globalNavItem = '';
		}
		
		//alert(navobj.className)
}


function animateNav(theObjHeight,theNavObjToOpen){	
	var theObjHeightLocal = theObjHeight;	
	if(global_leftHeigth<theObjHeightLocal){		
		timeoutID = setTimeout("animateNav('"+theObjHeightLocal+"')", 10);
		global_leftHeigth = global_leftHeigth + (global_leftHeigth / 2) + 1;
		if(global_leftHeigth<theObjHeightLocal){
		 global_theNavObjToOpen.style.height = global_leftHeigth + 'px';
		 //fades the background color
		 global_theNavObjToOpen.style.backgroundColor="#"+gradientBypercent("EDEDED","D8D8D8",getPercents(theObjHeightLocal,global_leftHeigth));		 
		}else{
		   global_theNavObjToOpen.style.height = theObjHeightLocal + 'px';
		   global_theNavObjToOpen.style.backgroundColor = "#D8D8D8";
		}
	}else{if(typeof(timeoutID)!="undefined")clearTimeout(timeoutID)}
}



function animateNavClose(theObjHeight,theNavObjToOpen){
	var theObjHeightLocal = theObjHeight;
	if(global_leftHeigthClose>theObjHeightLocal){
		timeoutIDClose = setTimeout("animateNavClose('"+theObjHeightLocal+"')", 10);
		global_leftHeigthClose = global_leftHeigthClose - (global_leftHeigthClose / 2) - 1;
		if(global_leftHeigthClose>theObjHeightLocal){
		 global_theNavObjToClose.style.height = global_leftHeigthClose + 'px';
		}else{global_theNavObjToClose.style.height = theObjHeightLocal + 'px';}
	}else{
	//alert(111)
	//alert(typeof(timeoutIDClose))
	 if(typeof(timeoutIDClose)!="undefined"){
	 //alert(222)
	  clearTimeout(timeoutIDClose);
	 // alert(333)
	  }
	  global_theNavObjToClose.className = 'rightNavOff';
	}
	
}



function findChildsHeight(theOpend){
	//findes how many chids in the opend pressed
	var theChilds = ElementsByClass(theOpend,'rightNavInner','Div',false);
	
	//gets the height of the child elements
	var theChildsHeight = 0;
	for (i=0;i<theChilds.length;i++){
	 theChildsHeight = theChildsHeight + theChilds[i].offsetHeight
	}
	
    return theChildsHeight;
	
}


function getStyle(el,styleProp)
{
	var x = el;//document.getElementById(el);
	if (x.currentStyle)//IE
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)//FF
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;	
}


	// returns hex string of the relative color by percent between startcolour and endcolour // startColour and endColour should be in hex, EG 292929 
function gradientBypercent(startColour,endColour,percentValue){
	//get decimal values from startcolour and end colour
	var startColourRed=h2d(startColour.substring(0,2));
	var startColourGreen=h2d(startColour.substring(2,4));
	var startColourBlue=h2d(startColour.substring(4,6));

	var endColourRed=h2d(endColour.substring(0,2));
	var endColourGreen=h2d(endColour.substring(2,4));
	var endColourBlue=h2d(endColour.substring(4,6));	

	// calculate new colour based on percents
	var newColourRed=startColourRed+getPartialValue(endColourRed-startColourRed,percentValue)	
	var newColourGreen=startColourGreen+getPartialValue(endColourGreen-startColourGreen,percentValue)
	var newColourBlue=startColourBlue+getPartialValue(endColourBlue-startColourBlue,percentValue)
	// if the length of the hex colour is 1, add 0
	var redString=new String(d2h(newColourRed));
	if (redString.length==1)redString="0"+redString;
	var greenString=new String(d2h(newColourGreen));
	if (greenString.length==1)greenString="0"+greenString;
	var blueString=new String(d2h(newColourBlue));
	if (blueString.length==1)blueString="0"+blueString;
		
	var theNewColour = redString+greenString+blueString;

	return theNewColour;
}

//percent functions
function getPercents(totalValue,partialValue){
	return Math.round(100/totalValue*partialValue)
}
function getPartialValue(totalValue, Percentage){
	return Math.round(Percentage*totalValue/100)
}
function h2d(h) {return parseInt(h,16);}

// transform hex numbers to decimals
var hD="0123456789ABCDEF";
function d2h(d) {
	var h = hD.substr(d&15,1);
	while(d>15) {d>>=4;h=hD.substr(d&15,1)+h;} return h; 
}


/*
 * new flash menu functions
 */

	function navMouseOut(){				
		this.flashObj.closeMenu();		
	}
	
	function navMouseOver(navID,flashXmouse,flashYmouse){								
		var navigationX=document.getElementById("navigation").offsetLeft;
		var navigationY=document.getElementById("navigation").offsetTop;
		menuPosX=Math.floor(navigationX+flashXmouse);
		menuPosY=Math.floor(navigationY+flashYmouse);
		var menuDiv=document.getElementById("menu"+navID+"div");
		var menuObj=document.getElementById("menu"+navID);				
		menuDiv.style.left=(menuPosX-130)+"px";
		menuDiv.style.top=(menuPosY-5)+"px";			
		
		/*if (!document.getElementById('tabdiv'+navID)){
			tabdiv = document.createElement('div'); // create dynamically div tag
			tabdiv.setAttribute('id',"tabdiv"+navID);
			tabdiv.style.width="50px";
			tabdiv.style.height="30px";
			//tabdiv.style.backgroundColor="black";
			tabdiv.style.position="absolute";
			tabdiv.style.top="0px";
			tabdiv.style.left="0px";
			menuDiv.appendChild(tabdiv);  
		}		*/
		externalInterfaceAdd(menuObj.id,"openMenu");
	}
	
	function hideMenu(navID){
		var menuDiv=document.getElementById("menu"+navID+"div");
		menuDiv.style.left="-1000px";
	}				
	
	var externaInterfaceQueue=new Array();			
	function externalInterfacePerform(){
		if (externaInterfaceQueue.length>0){
			eval("document.getElementById('"+externaInterfaceQueue[0][0]+"')."+externaInterfaceQueue[0][1]+"()");
			externaInterfaceQueue.shift();										
		}
	}
	
	function externalInterfaceAdd(objId,funcName){
		externaInterfaceQueue.push([objId,funcName]);
	}
	
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}



 
 function dragShow(dragObj,theEvent){
 	if (theEvent.type=="mouseover"){
		///dragObj.style.border="1px solid #1c91ce";
		dragObj.style.backgroundColor="#b1eaf3";
	}
 	else if (theEvent.type=="mouseout"){
		dragObj.style.backgroundColor="";		
		//dragObj.style.border="0px solid black";
	}		
 }
 
 function centerAndResizePopup(theWidth,theHeight){
 	var thePopup=document.getElementById('thePopup');
	var HdistanceLeft=theWidth-thePopup.offsetWidth;
	var VdistanceLeft=theHeight-thePopup.offsetHeight;
	var Hmove=Math.round(HdistanceLeft/4);
	var Vmove=Math.round(VdistanceLeft/4);
	
	//make sure the pop up is visible
	if (thePopup.offsetWidth>0){			
		if (HdistanceLeft>20){		
			setTimeout('centerAndResizePopup('+theWidth+','+theHeight+')',40)		
			resizePopup(thePopup.offsetWidth+Hmove,thePopup.offsetHeight);				
			if (thePopup.offsetLeft>0){
				thePopup.style.left=thePopup.offsetLeft-Hmove/2+'px';	
			}
		} else if (VdistanceLeft>20){		
			setTimeout('centerAndResizePopup('+theWidth+','+theHeight+')',40)
			resizePopup(thePopup.offsetWidth,thePopup.offsetHeight+Vmove);
			if (thePopup.offsetTop>0){
				thePopup.style.top=thePopup.offsetTop-Vmove/2+'px';			
			}		
		} else{
			resizePopup(theWidth,theHeight);
			var thumbnailDiv=document.getElementById('imageDiv');
			var closeBut=document.getElementById('thumbCloseButton');	
			new Effect.Appear(thumbnailDiv, { duration: 0.4, queue: 'end' });
			closeBut.style.display='block';
			thePopup.style.top = eval("'" + (((browserHeight + document.documentElement.scrollTop)/2) - 70) + "px" + "'")	
	
			thePopup.style.left = eval("'" + (((browserWidth)/2) - (theWidth/2)) + "px" + "'")	

	
		}
	}
	else{
		setTimeout('centerAndResizePopup('+theWidth+','+theHeight+')',1000)
	}
 }
 
 function resizePopup(theWidth,theHeight){
 	var thePopup=document.getElementById('thePopup');		
	pt=document.getElementById('Ptop');
	pb=document.getElementById('Pbottom');
	pl=document.getElementById('Pleft');
	pr=document.getElementById('Pright');
	pc=document.getElementById('Pcontent');	
	
		
	thePopup.style.width=theWidth+'px';
	thePopup.style.height=theHeight+'px';
	pl.style.height=(theHeight-14*2)+'px';
	pr.style.height=(theHeight-14*2)+'px';
	pt.style.width=(theWidth-15*2)+'px';
	pb.style.width=(theWidth-15*2)+'px';
	
	pc.style.width=(theWidth-15*2)+'px';
	pc.style.height=(theHeight-14*2)+'px';
 }
 
 
 
 
 globaFrmWidth = "";
 globalFrmHeight = "";
 globalFrmSrc = "";
 
 //(3)
 function openPopUp(theWidth,theHeight,endFunc){
 
 	centerAndResizePopup(globalFrmWidth,globalFrmHeight)
 	
 	var thePopup=document.getElementById('thePopup');
	/*EWAVE*/
	hi = document.getElementById('grayHider');
	
	browserWidth=window.innerWidth?window.innerWidth:document.body.clientWidth;
	browserHeight=window.innerHeight?window.innerHeight:document.body.clientHeight;
	//browserHeight=(document.body.clientHeight + document.body.scrollTop)
	
	thePopup.style.left=browserWidth/2-theWidth/2+100+'px';
	thePopup.style.top=browserHeight/2-theHeight/2+'px';	
	
	hi.style.height = eval("'" + (browserHeight + document.documentElement.scrollHeight) + "px" + "'")

	new Effect.Appear('grayHider', { duration: 0.3, from:0.0, to: 0.7, queue: 'end' });
	
    ////alert(document.getElementById("theFrame").contentWindow.document.documentElement.offsetHeight)
    
	new Effect.Appear(thePopup.id, { duration: 0.4, queue: 'end' , afterFinish: endFunc});
	
 }
 
 function closePopup(){
 	var thePopup=document.getElementById('thePopup');
	new Effect.Fade(thePopup.id, { duration: 0.4, queue: 'end'});
	new Effect.Fade('grayHider', { duration: 0.5, from:0.7, to: 0.0, queue: 'end' });
	
	/*Guy*/
 	globalFrmWidth = "200";
	globalFrmHeight = "200";
	globalFrSrc = "";
	setTimeout('resizePopup('+globalFrmWidth+','+globalFrmHeight+')',1000)
	
	var comboArr = document.getElementsByTagName('SELECT');
	for(i=0;i<comboArr.length;i++){
	  comboArr[i].style.display='inline';
	}
	/*End Guy*/	 
	
		
 }  
 
 function confirmPopup(Question,trueActionFunction){
 	var pc=document.getElementById('Pcontent');
	var originalContent=document.getElementById('confirmContent');
	document.getElementById('confirmText').innerHTML=Question;
	document.getElementById('confirmAction').onclick=trueActionFunction;	
	pc.innerHTML=originalContent.innerHTML;
	openPopUp(231,141);
 }
 
 function infoPopup(info){
 	var pc=document.getElementById('Pcontent');
	var originalContent=document.getElementById('infoContent');
	document.getElementById('infoText').innerHTML=info;	
	pc.innerHTML=originalContent.innerHTML;
	openPopUp(251,141);
 }
 
 function helpPopup(help){
 	var pc=document.getElementById('Pcontent');
	var originalContent=document.getElementById('helpContent');
	document.getElementById('helpText').innerHTML=document.getElementById(help).innerHTML;	
	pc.innerHTML=originalContent.innerHTML;
	openPopUp(500,300);
 }
 
 
 
 ///(1)
 ///function showThumbnail(imgURL){ //ORIGINAL FUNCTION	
 function showThumbnail(frmSrc,frmW,frmH){
 
	var pc=document.getElementById('Pcontent');
	var originalContent=document.getElementById('thumbnailContent');	
	
	var comboArr = document.getElementsByTagName('SELECT');
	for(i=0;i<comboArr.length;i++){
	  comboArr[i].style.display='none';
	}
	
	pc.innerHTML=originalContent.innerHTML;						
	///globalimgURL=imgURL;
	globalFrmSrc = frmSrc;
	globalFrmWidth = frmW;
	globalFrmHeight = frmH;
    
    resizeIframe();
	openPopUp(globalFrmWidth,globalFrmHeight,thumbnailCallback);

	//guy add:
	///centerAndResizePopup(globalFrmWidth,globalFrmHeight)	
 }
 
 //(2)
 //GUYS FUNCTION
 function resizeIframe(){
   var frmObj = document.getElementById('theFrame');
    frmObj.width = globalFrmWidth - 28;
    frmObj.height = globalFrmHeight - 55;
   }
 var globalFrmParent ="";
 
 
 //THIS FUNCTION OCCURS AFTER THE IFRAME SRC IS FINNISHED LOADING
 function showIFrame(frmObj){
    var loadDiv=document.getElementById('loadingDiv');	
    loadDiv.style.display='none';
	///alert(document.getElementById("theFrame").contentWindow.document.documentElement.offsetHeight)
	//alert('131313')
 }
 
 function thumbnailCallback(){
 	var thumbnailDiv=document.getElementById('imageDiv');
 	//thumbnailDiv.innerHTML='<img src="'+globalimgURL+'" onload="thumbLoaded(\''+globalimgURL+'\')">';

	var frmObj = document.getElementById('theFrame');
	frmObj.src = globalFrmSrc
	frmObj.onLoad = showIFrame(frmObj);
	
	//thumbnailDiv.innerHTML = '<iframe src="frameSrc.html" width="123" height="123" bordercolor="red" frameborder="1" id="theFrame2"></iframe>'
	////alert(frmObj.src)
	
	
	////alert(globalFrmParent)
	
	/*OR PUT AN IFRAME TO LOAD A PAGE IN IT*/ 
 }
 
 function thumbLoaded(imgURL){ //CHANGE THIS FUNCTION TO GET THE WIDTH AND HEIGHT FROM IFRAME
		var thumbnailDiv=document.getElementById('imageDiv');
		var loadDiv=document.getElementById('loadingDiv');
		var closeBut=document.getElementById('thumbCloseButton');
		
		thumbnailDiv.innerHTML='';		
		thumbnail=document.createElement('img');			        
        thumbnail.setAttribute('src',imgURL)
		thumbnail.setAttribute('id','theThumbnail')			
		thumbnailDiv.appendChild(thumbnail);
		var thumbnailImage=document.getElementById('theThumbnail');
		
		loadDiv.style.display='none';
		closeBut.style.display='none';
		
		////LEAV THIS FUNCTION, JUST GIVE IT A FIX SIZE FOR THE POPUP
		///centerAndResizePopup(getImgSize(thumbnail)[0]+40,getImgSize(thumbnail)[1]+100) ; ORIG CALL
		
		
		centerAndResizePopup(getImgSize(thumbnail)[0]+40,getImgSize(thumbnail)[1]+100)							
 }
 
 function getImgSize(img)
{
	var newImg = new Image();
	newImg.src = img.src;
	var height = newImg.height;
	var width = newImg.width;
	return new Array(width,height);
}

function CheckKeys(strCode)
	{
		var numVals = "1234567890";
		var counter;
	
		if(arguments.length>0 && event.keyCode == strCode)
			return true;
			
		if ((event.keyCode == 46)||(event.keyCode == 12)||(event.keyCode >= 34 && event.keyCode <= 40)||(event.keyCode >= 16 && event.keyCode <= 18))	{return true;}
		//alert(event.keyCode +' 1=='+numVals.charCodeAt(0) )
			if (event.keyCode != 8 && event.keyCode != 13)
			{
				if (event.keyCode == 9)
				{
					return true;
				}
				for (var counter = 0; counter < numVals.length; counter++)
						if (event.keyCode == numVals.charCodeAt(counter) || event.keyCode == numVals.charCodeAt(counter)+48)
							return true;
							
				//alert();
			return false;
			}
	
		return true;
	}
	
	function doCheckData(){
	
	}
