// FUNCTION FOR NO RIGHT CLICK

/*
var message="UNABLE TO ACCESS"; 
function click(e) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;

//END OF NO RIGHT CLICK
*/




//FUNCTIONS USED FOR DATA SORTING 
function sortorder(a,b){
return a - b;
}

function orderbyrank(thearray,theparent,menuitemarray){
var temparray= new Array();
for(var j in thearray){
temparray[thearray[j]] = menuitemarray[thearray[j]].rank;
}
temparray.sort(sortorder);

var outputarray=new Array();
for(var j in temparray){
for(var k in menuitemarray){
if((menuitemarray[k].parent==theparent)&&(menuitemarray[k].rank==temparray[j])){
outputarray[outputarray.length] = k;
}

}
}
return(outputarray);
}

function getsortedsiblings(thearray,theparent,menuitemarray){
var temparray = new Array();
for(var i in thearray){
if(thearray[i].parent==theparent){
temparray[temparray.length]=i;
}
}
return orderbyrank(temparray,theparent,menuitemarray);
}

// END OF DATA SORTING FUNCTIONS


//FUNCTIONS FOR TOP MENU MOUSE ACTIONS
var topmenulastdimcolor = null;
var topmenulastbordercolor = null;
function topmenumouseover(obj){
topmenulastdimcolor = obj.style.backgroundColor;
topmenulastbordercolor = obj.style.borderColor;
obj.style.cursor = 'hand';
obj.style.borderColor = topmenumouseoverbordercolor;
obj.style.backgroundColor = topmenumouseoverbackgroundcolor;
}
function topmenumouseout(obj){
obj.style.borderColor =topmenulastbordercolor;
obj.style.backgroundColor = topmenulastdimcolor;
}
//END OF FUNCTIONS FOR TOP MENU CONTROL


// START OF SIDE MENU FUNCTIONS

// FUNCTION FOR CREATING SIDE MENU OBJECTS (SERVICES & PRODUCTS & ATTRIBUTES MENUS) USES HIERACHY CATS
// REMAINS HERE FOR USE BY SERVICES MENU IF REQUIRED
function menuoptionobject(id,label,parent,rank,menu){
this.id=id;
this.label=label;
this.parent=parent;
this.rank=rank;
this.menu=menu;
}


//FUNCTION FOR BUILDING SIDE MENUS USING CAT HIERACHY
//function buildsidemenu(menuitemarray){

function buildsidemenu(menuname){
//mods for determing array to use within function so only ie 'services' sent as argument instead of 'services_menuitemarray'  
//THESE MODS MAKE THIS FUNCTION DIFFERENT FROM THAT CURRENTLY USED IN VS & LABELMATRIX 
menuitemarray = eval(menuname+"_menuitemarray;");

//get all whose parents are zero
var basearray = new Array();
basearray = getsortedsiblings(menuitemarray,0,menuitemarray);

sidemenuarray = new Array();

//start of main loop
for(var i in basearray){
sidemenuarray[sidemenuarray.length] = menuitemarray[basearray[i]].label.toUpperCase()+";"+basearray[i]+";"+sidemenubgcolorlevel1;

var base2array = getsortedsiblings(menuitemarray,menuitemarray[basearray[i]].id,menuitemarray);
if(base2array.length){
for(var j in base2array){
sidemenuarray[sidemenuarray.length] = menuitemarray[base2array[j]].label+";"+base2array[j]+";"+sidemenubgcolorlevel2;

var base3array = getsortedsiblings(menuitemarray,menuitemarray[base2array[j]].id,menuitemarray);
if(base3array.length){
for(var k in base3array){
sidemenuarray[sidemenuarray.length] = menuitemarray[base3array[k]].label+";"+base3array[k]+";"+sidemenubgcolorlevel3;

var base4array = getsortedsiblings(menuitemarray,menuitemarray[base3array[k]].id,menuitemarray);
if(base4array.length){
for(var m in base4array){
sidemenuarray[sidemenuarray.length] = menuitemarray[base4array[m]].label+";"+base4array[m]+";"+sidemenubgcolorlevel4;
}
}

}
}
}
}

}

}

// FUNCTION TO DISPLAY THE SIDE MENU CREATED IN BUILDSIDEMENU
function putsidemenu(menuname){
document.writeln('<table width=100% border=0 cellpadding=2 cellspacing=2>');
for(var i in sidemenuarray){
document.writeln('<tr id='+menuname+'_menuitem_'+sidemenuarray[i].split(";")[1]+' onclick="">');
document.writeln('<td id='+menuname+'_menucell_'+sidemenuarray[i].split(";")[1]+' class="sidemenucell" style="background-Color:'+sidemenuarray[i].split(";")[2]+'" onmouseover="sidemenumouseover(this)" onmouseout="sidemenumouseout(this)" onclick="sidemenumouseclick(this)">');
document.writeln(sidemenuarray[i].split(";")[0]);
document.writeln('</td>');
document.writeln('</tr>');
}
document.writeln('</table>');
}


//FUNCTIONS FOR SIDE MENU ACTIONS
var sidemenulastdimcolor = null;
var sidemenulastbordercolor = null;
function sidemenusetcurrent(obj){
if(cpc){
obj.style.backgroundColor = sidemenucurrentpagecolor;
}
}

function sidemenumouseover(obj){
obj.style.cursor = 'hand';
sidemenulastbordercolor = obj.style.borderColor;
obj.style.borderColor = sidemenumouseoverbordercolor;
if((cpc)&&(obj.id.split("_")[2]==cpc)){
return
}
sidemenulastdimcolor = obj.style.backgroundColor;
obj.style.backgroundColor = sidemenumouseoverbackgroundcolor;
}

function sidemenumouseout(obj){
if((cpc)&& (obj.id.split("_")[2]==cpc)){
return
}
obj.style.borderColor = sidemenulastbordercolor;
obj.style.backgroundColor = sidemenulastdimcolor;
}

function sidemenumouseclick(obj){
//line below had to be altered as php in .js files will not work, prior to this javascript being moved to external file
// system was working fine as mode variable was written by php during processing but since this is in externl file
// this is not happening. javascript mode var must be written to javascript in pagetemplate.
//window.location.href = obj.id.split("_")[0]+".php?cpc="+obj.id.split("_")[2]+"&mode=<?php echo($mode) ?>";

//thepage = obj.id.split("_")[0];
//thecpc = obj.id.split("_")[2];

theredirect = false;
for(var i in redirectarray){
if((redirectarray[i].split(",")[0]==pagename) && (redirectarray[i].split(",")[1]==obj.id.split("_")[2])){
theredirect = redirectarray[i].split(",")[2];
}
}

if(theredirect){
window.location.href = theredirect;
}
else
{
window.location.href = obj.id.split("_")[0]+".php?cpc="+obj.id.split("_")[2]+"&mode="+mode;
}



//window.location.href = obj.id.split("_")[0]+".php?cpc="+obj.id.split("_")[2]+"&mode="+mode;
}
//END OF SIDE MENU MOUSE ACTIONS


// END OF SIDE MENUS FUNCTIONS



//FUNCTIONS FOR MAKE MENU (TREADSAFE STYLE) MOUSEOVERS
// FUNCTIONS FOR MAKE MENU MOUSE ACTIONS
var makemenulastdimcolor = null;
var makemenulastbordercolor = null;
function makemenumouseover(obj){
makemenulastdimcolor = obj.style.backgroundColor;
makemenulastbordercolor = obj.style.borderColor;
obj.style.borderColor = makemenumouseoverbordercolor;
obj.style.backgroundColor = makemenumouseoverbackgroundcolor;
}

function makemenumouseout(obj){
obj.style.borderColor = makemenulastbordercolor;
obj.style.backgroundColor = makemenulastdimcolor;
}
// END OF MAKE ENU MOUSE ACTIONS FUNCTIONS





// FAQ MOUSEOVER FUNCTIONS require id setting of question and answer cells in calling page
//javascript function to display a faq answer on mouseover 
function showfaqa(obj){
eval("faqa_"+obj.id.split('_')[1]+".style.display=''");
}

//javascript function to hide a faq answer on mouseout 
function hidefaqa(obj){
eval("faqa_"+obj.id.split('_')[1]+".style.display='none'");
}


//function to display flash image

			function putflashfile(flashfile,width,height,bgcolor,version){
			document.writeln('<OBJECT style="z-index:-1;display:block;" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+'" WIDTH='+width+' HEIGHT='+height+'>');
            document.writeln('<param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="transparent" />');
			document.writeln('<PARAM NAME=movie VALUE="'+flashfile+'"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE='+bgcolor+'> <EMBED src="'+flashfile+'" quality=high bgcolor='+bgcolor+'  WIDTH='+width+' HEIGHT='+height+' wmode="transparent" allowScriptAccess="sameDomain" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>');
           document.writeln('</OBJECT>');
			}


//function to write out flash string
function writeflashstring(flashstring){
document.writeln(flashstring);
}
