/**
 * @author opher.vishnia
 */


var basePath='';
if (typeof(loadRightNav) == "undefined")
{
    var loadRightNav = '';
}
function pageLoadNew(){
   //load right navigation
	if(loadRightNav){		
		loadXML(approot + "/xml/rightnav.xml",rightNav);
		//loadXML(approot + "/xml/rightnav.xml.aspx",rightNav);
	}	
	
	if(selectBox){
	 window.ComponentArt_Page_Loaded = true;
	}
}

/*
function pageLoad(){		

	//initSelectBox();
	
	//load main flash
	if (flashBanner=="mainpage"){	
		mainFlashload = new SWFObject(PageThemePath + "/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)	
	}
	
	///// removed guy 18/06/07 new Draggable("thePopup");
}
*/
addLoadEvent(pageLoadNew);




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(){
    var len = xmlDoc.getElementsByTagName("bluebutton").length;
	for (X=0;X<len;X++){
		bluerightButtons[X] = new SWFObject(PageThemePath  + "/images/flash/bluemenubutton.swf", "bluebutton"+X, "124", "58", "8", "#ffffff");
		bluerightButtons[X].addParam("wmode", "opaque");
		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)
		}
		
	len = xmlDoc.getElementsByTagName("whitebutton").length;
	for (X=0;X<len;X++){
		whiterightButtons[X] = new SWFObject(PageThemePath + "/images/flash/whitemenubutton.swf", "whitebutton"+X, "124", "42", "8", "#ffffff");
		whiterightButtons[X].addParam("wmode", "opaque");
		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){	
//debugger;
	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=PageThemePath + "/images/nav/tab_inactive_left.jpg";		
		ElementsByName(tabsArray[x],'rightbut','img')[0].src=PageThemePath + "/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=PageThemePath + "/images/nav/tab_active_left.gif";
	ElementsByName(whichtab,'rightbut','img')[0].src=PageThemePath + "/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";	
			
	    }
	    //alert();
	
}

function tabclick2(whichtab,toChangeHeader,toChangeDivContent){	
//debugger;

	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=PageThemePath + "/images/nav/tab_inactive_left.jpg";		
		ElementsByName(tabsArray[x],'rightbut','img')[0].src=PageThemePath + "/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=PageThemePath + "/images/nav/tab_active_left.gif";
	ElementsByName(whichtab,'rightbut','img')[0].src=PageThemePath + "/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 == null)
		return null;	
	
	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");
   }
}


function dispP(id){
	var Obj = document.getElementById(id);
if (Obj.style.display == ''){
                Obj.style.display = 'none';
			}else{
                Obj.style.display = ""; 
            }
			
	}


//SCANS THE PAGE FROM THIS OBJ FORWORD UNTILL THE NEAR ELEMENT WITH REQUESTE CLASSNAME
function findNextElement(obj,cssClass){

if(obj.nextSibling==null)
		return null;
		
		
			
	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{clearTimeout(timeoutIDClose);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)
	/*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');	
	
	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 openCloseRow(obj,childClassName){
  var theInnerDiv = findMyChild(obj,childClassName)
  var theClassName= "";
  if(obj.className.indexOf('Off') != -1){
     theClassName = obj.className.substring(0, obj.className.lastIndexOf("Off"))
	 obj.className = theClassName + "On";
	 theInnerDiv.style.display = 'inline';
  }else{
    theClassName = obj.className.substring(0, obj.className.lastIndexOf("On"))
	 obj.className = theClassName + "Off";
	 theInnerDiv.style.display = 'none';
  }
}

function findMyChild(obj,childClassName){
  for(i=0;i<obj.childNodes.length;i++){
     if(obj.childNodes[i].className ==  childClassName){
       return obj.childNodes[i];
     }
  }
}



/***********************************  component art dialog (popup) **************************/


function toggleDialogState(theDomId,theFrmSrc,theFrmWidth,theFrmHeight)
    {
    
    	if(Dialog1.get_isShowing())
    	{
    		Dialog1.Close();
    	}
    	else
    	{
$get(Dialog1.Id).className = $get(Dialog1.Id).className.replace("dNone","");
          //var theIframe = $get(Dialog1.Id+"_IFrame")
          var theIframe = $get("theInnerIframe")
          
          if(theIframe != null){
             theIframe.style.display='block';
             theIframe.src = theFrmSrc;
             theIframe.style.border='0px';
             theIframe.width= theFrmWidth + 'px';
             theIframe.height=theFrmHeight + 'px';
          } 
          
          Dialog1.ShowTransition=3;				// Fade
		  Dialog1.CloseTransition=3;				// Fade
		  Dialog1.AnimationSlide=2;	  
          Dialog1.AnimationType='Live';
          Dialog1.AnimationType='Direct';
          
          Dialog1.AnimationDirectionElement = theDomId; 
          Dialog1.ModalMaskImage= PageThemePath + "/Images/bgModal.gif";
          Dialog1.AnimationDuration = 0; //1000
          Dialog1.TransitionDuration = 0; //500
          Dialog1.AnimationSlide = 1; 
          Dialog1.Alignment='MiddleCentre';
    	  Dialog1.Modal=false; //by alx
    	  Dialog1.Show(); 
    	  
    	  var theDialogDiv = $get(Dialog1.Id);
    	  theDialogDiv.style.width = theFrmWidth + 30 +'px';
    	  theDialogDiv.style.top = ((((screen.availHeight)/ 2) - (theDialogDiv.offsetHeight /2)) + document.documentElement.scrollTop + "px");
    	 theDialogDiv.style.left = (screen.availWidth / 2) - (theDialogDiv.offsetWidth /2) + document.documentElement.scrollLeft + "px";
    	}
    }
    function toggleDialogStateCatalog(theDomId,theFrmSrc,theFrmWidth,theFrmHeight){
    if(Dialog1.get_isShowing()){
        Dialog1.Close();
    }
    else{
$get(Dialog1.Id).className = $get(Dialog1.Id).className.replace("dNone","");
        var theIframe = $get("theInnerIframe")
        if(theIframe != null){
             theIframe.src = theFrmSrc;
             theIframe.style.border='0px';
             theIframe.width= theFrmWidth + 'px';
             theIframe.height=theFrmHeight + 'px';
         }   
	  Dialog1.Alignment='MiddleCentre';
	  Dialog1.Modal=true;
	  //alert("433");
	  //debugger;
	  Dialog1.Show(); 
	  
	  var theDialogDiv = $get(Dialog1.Id);
	  theDialogDiv.style.width = theFrmWidth + 30 +'px';
	  theDialogDiv.style.top = ((((screen.availHeight)/ 2) - (theDialogDiv.offsetHeight /2)) + document.documentElement.scrollTop + "px");
	}
}
   
  
  
  function closeIFrame(){
    var theIframe = $get("theInnerIframe")
    if(theIframe != null){
             theIframe.src = "http://www.pelephone.co.il/close.html";
     }
  }
  
  // these functions deal with capturing the CTRL key
var pressedCTRL=false;
function keyHandler(e)
{
	if (!e) e = window.event;	
	pressedCTRL=e['ctrlKey'];
}

  
var theSelectBox;
  
//selectbox functions
function openSelectBox(which){

	theSelectBox=ElementsByName(which.parentNode,'items','div')[0];
 	//alert(theSelectBox.style.display);
	if(theSelectBox.style.display=="none"){
		theSelectBox.style.display="block";		
	} 
	else{
		theSelectBox.style.display="none";
	}
}

function openSearchSelectBox(which){

	theSelectBox=ElementsByName(which.parentNode,'items','div')[0];
 		if(theSelectBox.style.display=="none"){
		theSelectBox.style.display="block";		
	} 
	else{
		theSelectBox.style.display="none";
	}
}


function ClearSearchItemStyle(){

              if(typeof(selectedSearchItem) != "undefined") 
                {
                   if(selectedSearchItem!='')
			        {
			          
			   	        selectedSearchItem.className="selectBoxItemBlank";
			        }
			}

}

function setSearchItemStyle(){
			        if(typeof(selectedSearchItem) != "undefined" &&selectedSearchItem!='')
			        {
			          
			   	        selectedSearchItem.className="selectBoxItemBlank";
			        }
			        event.srcElement.className="searchSelectedItemMenuItem";
			        selectedSearchItem=event.srcElement;
       			
			
}


function BoxItemSelected( insertObjectID,divObjectID){

   document.getElementById(insertObjectID).innerText=event.srcElement.innerText;
   openSearchSelectBox(document.getElementById(divObjectID));
   document.getElementById("searchBox_Value").value =  event.srcElement.ValueText;
  
}

function BoxItemSelectedMultimediaType( insertObjectID,divObjectID,sUrl,Sort){

   document.getElementById(insertObjectID).innerText=event.srcElement.innerText;
   openSearchSelectBox(document.getElementById(divObjectID));
   //alert(Sort);
   //document.getElementById("searchBox_Value").value =  event.srcElement.ValueText;

   window.location = sUrl + "?Sort=" + Sort + "&" + "SortMediaType=" + event.srcElement.ValueText;
  
}
function selectBox(which){

	if (document.all){
	var r = document.body.createTextRange();
	r.moveToElementText(selectme);
	r.select();	}
	if (pressedCTRL){		
		which.className=which.className=="selectBoxItemBlank"?"selectBoxItemSelected":"selectBoxItemBlank";
		}
		else{
		theSelectBox.style.display ="none";
		
        which.parentNode.parentNode.style.display="none";
			var items=ElementsByName(which.parentNode,'item','div');
			for (var x=0;x<items.length;x++)
			items[x].className="selectBoxItemBlank";								
			which.className="selectBoxItemSelected";
		document.getElementById("selectBoxCaption").innerHTML = which.innerHTML;
			
		}
}

function selectBoxSubmit(which){
	var searchString=ElementsByName(which.parentNode,'items','div')[0].style.display='none';
	var searchString=ElementsByName(which.parentNode,'searchstring','input')[0].value;
	var selectedItems=new Array();
	var items=ElementsByName(which.parentNode,'item','div');
	for (var x=0;x<items.length;x++)
		if(items[x].className=="selectBoxItemSelected")
			selectedItems[selectedItems.length]=items[x].innerHTML;
	alert("search string: "+searchString+"\nitems: "+selectedItems);
}

function clearTextBox(which,phrase){
	if (which.value==phrase)
		which.value="";	
}  

/*************************tanya******************/

function closeBanner(obj)
{
    obj.parentNode.style.display="none";
}
function switchOnOff(obj)
{
    
    if(obj.className.indexOf("Off")!=-1)
    {
        obj.className=obj.className.replace("Off","On");
    }
    else
    {
        obj.className=obj.className.replace("On","Off");
    }
}

function switchOffImg(obj, path){
    if(obj.myName != "1"){
        obj.src = path;
     }   
}
function switchOnImg(obj, path){
   if(obj.myName != "1"){
        obj.src = path;
   }
}

function changeToActive(obj)
{ 
    var id = obj.id.substring(obj.id.indexOf("IC"), obj.id.length);
    if(obj.src.indexOf("Off")!=-1)
    {
        if(addToDeviceArray(id.substring(2,id.length))){
            obj.src=obj.src.replace("Off","On"); 
        }
    }
    else
    {
        removeFromDeviceArray(id.substring(2,id.length));
        obj.src=obj.src.replace("On","Off"); 
    }
    
}
function changeToActive1(obj)
{ 
    var origId = obj.id;
    var id = obj.id.substring(obj.id.indexOf("IC"), obj.id.length);
    if(obj.src.indexOf("Off")!=-1)
    {
        if(addToDeviceArray1(id.substring(2,id.length))){
            obj.src=obj.src.replace("Off","On"); 
        }
    }
    else
    {
        removeFromDeviceArray(id.substring(2,id.length));
        obj.src=obj.src.replace("On","Off"); 
    }
    
}
var deviceArray = new Array();
var manufacturer = -1;
function addToDeviceArray(id){
    if(deviceArray.length >3){
        alert("לא ניתן לבחור יותר מ-4 מכשירים להשוואה");
        return false;
    }else{
        deviceArray.push(id);
        //showArray();
        return true;
    }    
    
}
function addToDeviceArray1(id){
    deviceArray.push(id);
    return true;    
}
       

function removeFromDeviceArray(id){
     for(var a=0; a<deviceArray.length; a++){
        if(deviceArray[a] == id){       
            deviceArray[a] = null;
        }
    }
    deviceArray = reloadArray();
    
     //showArray();
}

function reloadArray(){
   var deviceArrayTemp = new Array();
   for(var a=0; a<deviceArray.length; a++){
       if(deviceArray[a] != null){
            deviceArrayTemp.push(deviceArray[a]);
       }
   }
   return deviceArrayTemp;
}
 
function showArray(){
    var text = "";
    deviceArray = reloadArray();
    for(var a=0; a<deviceArray.length; a++){
        text += deviceArray[a] + ",";
    }
    alert(text);
}

function updateManufacturer(obj){
    manufacturer = obj.value;
}
function updateManufacturer1(obj, url){
    manufacturer = obj.value;
    if(manufacturer > 0){
        doGetDevicesToFilter(url);
    }else{
        window.location.reload();
    }
}

function doGetDevicesToCompare(path){
    var ids = "";
     for(var a=0; a<deviceArray.length; a++){
        ids += deviceArray[a] + ",";
    }
    if(deviceArray.length>0){
        window.location.href=path+"&d="+ids;
    }
    else
    {
        var modalPopupBehaviorCtrl = $find('ModalPopupBehaviorID');
        modalPopupBehaviorCtrl.show();
        //alert(".אנא סמן לפחות מכשיר אחד להשוואה");
    }
}
function doGetDevicesToFilter(path){
    var ids = "";
     for(var a=0; a<deviceArray.length; a++){
        ids += deviceArray[a] + ",";
    }
    FilterByProp(path+"&m="+manufacturer+"&d="+ids); 
}
function FilterByProp(path){
    Filter(path);
}
function dump(){}
//picture name must be given by next pattern:   ...+'ColorBlue.jpg' or ...+'ColorRed.jpg'
function switchColor(color,picture,objBorder,paletteHolderId)
{
    if(picture.src.replace(picture.src.substr(picture.src.indexOf('Color')),'Color'+color+'.jpg'))
    {
         picture.src=picture.src.replace(picture.src.substr(picture.src.indexOf('Color')),'Color'+color+'.jpg');
    }
    var divArr=$(paletteHolderId).getElementsByTagName('div'); 
    for( i=0;i<divArr.length;i++)
    {
        if(divArr[i].className.indexOf('On')!=-1)
        {
            divArr[i].className=divArr[i].className.replace('On','Off');
        }
        
    }
    objBorder.className=objBorder.className.replace('Off','On');

}
/*var globPath = '../App_Themes/default/Images/catalog/pics/';*/
function switchColorByImage(picSrc,pic,objBorder,paletteHolderId){
    var picture = document.getElementById(pic);
    picture.src = picSrc;
    var divArr=$(paletteHolderId).getElementsByTagName('div'); 
    for( i=0;i<divArr.length;i++)
    {
        if(divArr[i].className.indexOf('On')!=-1)
        {
            divArr[i].className=divArr[i].className.replace('On','Off');
        }
        
    }
    objBorder.className=objBorder.className.replace('Off','On');
}

function openCloseCharacteristicList(objId,flag)
{
    var obj=$(objId);
    if(flag==0){
        var arrList=obj.getElementsByClassName('listItemOff');
        if(arrList.length > 0){
            for(i=0;i<arrList.length;i++){
                arrList[i].className = "listItemOn";
             }
         }
        var arrList=obj.getElementsByClassName('liOff');
        if(arrList.length > 0){
            for(i=0;i<arrList.length;i++){
                arrList[i].className = "liOn";
             }
         }
         
     }else{
        var arrList=obj.getElementsByClassName('listItemOn');
        if(arrList.length > 0){
            for(i=0;i<arrList.length;i++){
                arrList[i].className = "listItemOff";
             }
         }
        var arrList=obj.getElementsByClassName('liOn');
        if(arrList.length > 0) {
            for(i=0;i<arrList.length;i++){
                arrList[i].className = "liOff";
             }
         }     
   } 
}

function changeFontSize(inc,idText)
{ 
 
    var p = document.getElementsByTagName('div'); 
    var list = document.getElementsByTagName('li');
    var textObj=$(idText);
 
    if(textObj.innerHTML=="הגדל פונט")
    {
  
       
        
      
        
        
        textObj.innerHTML="הקטן פונט";
        for(n=0; n<p.length; n++) 
        {  
             if( p[n].className.indexOf('notToZoom')==-1) {
                if(p[n].style.fontSize)
                {   
                   
                    var size = parseInt(p[n].style.fontSize.replace("px", ""));
                 }
                 else 
                 {       var size = 12;    }    
                 p[n].style.fontSize = size+inc + 'px';   
                 }
        }
        for(n=0; n<list.length; n++) 
        {  
             if( list[n].className.indexOf('notToZoom')==-1) {
                if(list[n].style.fontSize) 
                {       var size = parseInt(list[n].style.fontSize.replace("px", ""));    }
                 else 
                 {       var size = 12;    }    
                 list[n].style.fontSize = size+inc + 'px';   
                 }
        }
    }
    
    else if(textObj.innerHTML=="הקטן פונט")
    {
    
        textObj.innerHTML="הגדל פונט";
        
        for(n=0; n<p.length; n++) 
        { 
             if( p[n].className.indexOf('notToZoom')==-1) {
                if(p[n].style.fontSize) 
                {       var size = parseInt(p[n].style.fontSize.replace("px", ""));    }
                 else 
                 {       var size = 12;    }    
                 p[n].style.fontSize = size-inc + 'px';   
                 }
        }
        for(n=0; n<list.length; n++) 
        { 
             if( list[n].className.indexOf('notToZoom')==-1) {
                if(list[n].style.fontSize) 
                {       var size = parseInt(list[n].style.fontSize.replace("px", ""));    }
                 else 
                 {       var size = 12;    }    
                 list[n].style.fontSize = size-inc + 'px';   
                 }
        }
        
    }
   
   
    
}
function popUpMenuButtons(butId,placeId,lineId)
{
    var placeObj=$(placeId);
    var butObj=$(butId);
    //var lineObj=$(lineId);
    placeObj.innerHTML=butObj.innerHTML;
    placeObj.style.display='inline';
    butObj.style.display='none';
    //lineObj.style.display='inline';
    
}

function openCloseDeviceImage1(objTabsId,objImgId,src){
    var imageFolderImg = document.getElementById('imageFolderImg')
    if(src){
       imageFolderImg.src = src;
    }
    imageFolderImg.style.display = 'block';
    if($(objTabsId).style.display=="none"){
      $(objTabsId).style.display="";
      $(objImgId).style.display="none";
    }
    else{
        $(objTabsId).style.display="none";
        $(objImgId).style.display="";
    } 
}   
function openCloseDeviceImage(objTabsId,objImgId)
{
   
    
    if($(objTabsId).style.display=="none")
    {
        $(objTabsId).style.display="";
        $(objImgId).style.display="none";
    }
    else{
       
        $(objTabsId).style.display="none";
        $(objImgId).style.display="";
    }
    
}  

var tempImage = '';
function openCloseDeviceImage2(objTabsId,objImgId)
{
    if($(imageFolder).style.display == ""){
        $(imageFolder).style.display = "none";
        $(objImgId).style.display= "";
       try{
            tempImage.style.display="";
       }catch(E){}
       tempImage = $(objImgId);
    }else if($(objImgId).style.display == "none"){
       $(objTabsId).style.display="none";
       $(objImgId).style.display= "";
       try{
            tempImage.style.display="none";
       }catch(E){}
       tempImage = $(objImgId);
   }else{
        tempImage = $(objImgId);
   }
}

 
function changeRowAttribute(rowObj,tdStarsId)
{

    
    if(document.getElementById(tdStarsId))
    {
    var starsArr=(document.getElementById(tdStarsId)).getElementsByTagName('img');
    if(rowObj.className.indexOf('On')!=-1)
    {
        rowObj.className=rowObj.className.replace('On','');
        for(i=0;i<starsArr.length;i++)
        { 
            if(starsArr[i].src.indexOf('starOn')!=-1)
            {
               
                starsArr[i].src=starsArr[i].src.replace('starOn','starOff');
               
            }
        }
    }
    else 
    {
        rowObj.className=rowObj.className+'On';
        for(i=0;i<starsArr.length;i++)
        {
            if(starsArr[i].src.indexOf('starOff')!=-1)
            {
                starsArr[i].src=starsArr[i].src.replace('starOff','starOn');
            }
        }
    }
    }
    else{
        if(rowObj.className.indexOf('On')!=-1)
        {
            rowObj.className=rowObj.className.replace('On','');
           
        }
        else 
        {
            rowObj.className=rowObj.className+'On';
           
        }
    
    }
}   
function openDropDown(objId)
{
 
    var Obj=document.getElementById(objId);
    
    if(Obj.style.display=='none')
    {  
        Obj.style.display='inline';
       // document.getElementById('coverSelect').style.display="inline";
    }
    else
    {
        Obj.style.display='none'
       // document.getElementById('coverSelect').style.display="none";
    }
}
 function setChoice(obj,objId)
 {
    document.getElementById(objId).innerHTML=obj.innerHTML;
 }
 function openWindow(url){
    window.open(url);
 }
    
 function checkRow(obj) 
 {
    var arrLine=obj.parentNode.getElementsByTagName('div');
    for(i=0;i<arrLine.length;i++)
    
    {
        if(arrLine[i].className.indexOf('listItem')!=-1)
       {
            
            if(arrLine[i].className.indexOf('Choose')!=-1)
            {
                arrLine[i].className=arrLine[i].className.replace('Choose','Off');
            }
            
       }
    }
  /*  if(obj.className.indexOf('Choose')==-1)
    {
        if(obj.className.indexOf('Off')!=-1)
        {
           obj.className=obj.className.replace('Off','Choose');
         }
        else if(obj.className.indexOf('On')!=-1)
        {
            obj.className=obj.className.replace('On','Choose');
        }
    }
    else{
        obj.className=obj.className.replace('Choose','On');
    }*/
     if(obj.className.indexOf('Off')!=-1)
        {
           obj.className=obj.className.replace('Off','Choose');
         }
        else if(obj.className.indexOf('On')!=-1)
        {
            obj.className=obj.className.replace('On','Choose');
        }
 }
   function CreateBookmarkLink() { 
   
        title = document.title;
        url =  window.location.href;	
        if (window.sidebar){	
            window.sidebar.addPanel(title, url,"");	
        }else if( window.external ){	
            window.external.AddFavorite( url, title); 
        }else if(window.opera && window.print){ 
            return true;
        } 
   } 
 function openCloseSpecLine(objId)
 {
     var Obj=$(objId);
     if(Obj.className.indexOf('On')==-1){
        Obj.className=Obj.className.replace('Off','On');
        var arrList=Obj.getElementsByClassName('listItemOff');
        if(arrList.length > 0){
            for(i=0;i<arrList.length;i++){
                arrList[i].className = "listItemOn";
            }
        }
     }
     else{
        Obj.className=Obj.className.replace('On','Off');
        var arrList=Obj.getElementsByClassName('listItemOn');
        if(arrList.length > 0){
            for(i=0;i<arrList.length;i++){
                arrList[i].className = "listItemOff";
             }
        }
     }
 }
 
 function switchOnOffImage(obj,containerId)
{
    arrLink=$(containerId).getElementsByTagName('img');
    for(i=0;i<arrLink.length;i++)
    {
        if(arrLink[i].src.indexOf('Active')!=-1)
        {
            arrLink[i].src=arrLink[i].src.replace('Active','Off');
        }
    }
    obj.src=obj.src.replace('On','Active');
    
}
function switchOnOffImgRoll(obj)
{
    if(obj.src.indexOf("Off")!=-1)
    {
        obj.src=obj.src.replace("Off","On");
    }
    else
    {
        obj.src=obj.src.replace("On","Off");
    }
}
var GlobalCurrentRow=null;
var currentImgOver=null;
function GridMouseOver(Obj){
    if(GlobalCurrentRow!=null)
    {
    
        GlobalCurrentRow.className=GlobalCurrentRow.className.replace('On','');
    }
    GlobalCurrentRow=Obj;
    Obj.className=Obj.className+'On';
    var imgs = Obj.getElementsByTagName('img');
    
    for (var r = 0; r < imgs.length; r++)
    {
        if (imgs[r].src.indexOf('move3.gif') > -1)
        {
            imgs[r].src = imgs[r].src.replace('move3.gif','move.gif');
            currentImgOver = imgs[r];
            }
    }
    
//Obj.style["background-color:#73AAFF"];

}

function GridMouseOut(){
    if (currentImgOver)
        currentImgOver.src = currentImgOver.src.replace('move.gif','move3.gif');
}

 //****************************XMLHTTP********************************//
var xmlhttp=false;
try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 }catch (E) {
   xmlhttp = false;
  }
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

function Filter(url){
//window.location.href = url;
// alert(url);
    xmlhttp.open("GET", url,true);
    xmlhttp.onreadystatechange=function(){
     if (xmlhttp.readyState==4){
        if (xmlhttp.status==200){
            var rep = parent.document.getElementById("rep");
          
            rep.innerHTML = xmlhttp.responseText; 
            try{
                parent.CloseIframePopUp();
            }catch(e){}
            try{            
                parent.$.modal.close();
            }catch(e){}
        }
      }
    }
 xmlhttp.send(null)
}
function Filter1(url){
//window.location.href = url;
// alert(url);
    xmlhttp.open("GET", url,true);
    xmlhttp.onreadystatechange=function(){
     if (xmlhttp.readyState==4){
        if (xmlhttp.status==200){
            var rep = parent.document.getElementById("rep");
            rep.innerHTML = xmlhttp.responseText;
            parent.CloseIframePopUp();  
        }
      }
    }
 xmlhttp.send(null)
}
function FilterUpdate(arg){
   
   var rep = parent.document.getElementById("rep");
   rep.innerHTML = arg;
}

function CreateHTTPREquest()
{
    var xmlhttp = false;
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
     try 
     {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } 
     catch (e) 
     {
        try 
        {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (E) 
        {
            xmlhttp = false;
        }
     }
    
    if (!xmlhttp && typeof(XMLHttpRequest) != 'undefined') 
    {
	    try {
		    xmlhttp = new XMLHttpRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    if (!xmlhttp && window.createRequest) 
    {
	    try {
		    xmlhttp = window.createRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    return xmlhttp;
}


function IsNumeric(sText)
{
    var ValidChars = "0123456789.";
    var IsNumber=true;
    var Char;
 
    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
        Char = sText.charAt(i); 
        if (ValidChars.indexOf(Char) == -1) 
        {
            IsNumber = false;
        }
    }
      
   return IsNumber;   
}    
    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);
  }
}
var isHomepage = false;
var int1,int2;
var scrollWidth1,scrollWidth2;
function changeToOff(obj)
{
    
    obj.className=obj.className.replace('On','Off')
}
function changeToOn(obj)
{
    obj.className=obj.className.replace('Off','On')
}
function SubmitOnEnter(val, SearchUrl, e){
    evt = e || window.event;
    var keyPressed = evt.which || evt.keyCode;
	if (keyPressed == 13) 
        SubmitSearch(val, SearchUrl);                     
}
function SubmitSearch(val, searchUrl){
    if (val != 'חפש באתר')
    {
        GoToUrl(searchUrl, [val]);
    }
}
function GoToUrl(url, params){
    for (var i = 0; i < params.length; i++){        
        url = url.replace("{" + i + "}", params[i].trim());
    }
    window.location.href = url;    
}