

// 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 topmenulastclassname = null;

function topmenumouseover(obj){
topmenulastclassname = obj.className;
if(obj.className=='topmenucellcurrent'){
obj.className = topmenulastclassname;
}
else
{
obj.className = 'topmenucellover';
}
obj.style.cursor = 'hand';
}

function topmenumouseout(obj){
obj.className = topmenulastclassname;
}
//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;
}

//NEW WAY USING CSS CLASSES
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]+";sidemenucelldefault_1";

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]+";sidemenucelldefault_2";

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]+";sidemenucelldefault_3";

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]+";sidemenucelldefault_4";
}
}

}
}
}
}

}

}








//NEW WAY USING CLASSES
// 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('<tr>');
//document.writeln('<div class="sidemenucellbgdefault_1" style="background-color: #ff0000; filter:alpha(opacity=20)">');
document.writeln('<td id='+menuname+'_menucell_'+sidemenuarray[i].split(";")[1]+' class="'+sidemenuarray[i].split(";")[2]+'"  onmouseover="sidemenumouseover(this)" onmouseout="sidemenumouseout(this)" onclick="sidemenumouseclick(this)">');
document.writeln(sidemenuarray[i].split(";")[0]);
document.writeln('</td>');
//document.writeln('</div>');
document.writeln('</tr>');
}
document.writeln('</table>');
}



//FUNCTIONS FOR SIDE MENU ACTIONS
var sidemenulastclassname = null;


function sidemenusetcurrent(obj){
//alert(obj.id);
thecurrent = obj.id.split("_")[2];
thearray = eval(obj.id.split("_")[0]+'_menuitemarray;');
thearray = traceancestors(thearray,thecurrent);
if(cpc){
for(v in thearray){
//alert(thearray[v])
eval(obj.id.split("_")[0]+'_menucell_'+thearray[v]+'.className="sidemenucellcurrent_1";');
//obj.className = "sidemenucellcurrent_1";
}
}


//alert("kak");


}



/*
function traceancestry(obj,thearray){
//alert(obj.parent);
while(obj.parent){
obj = thearray[obj.parent];
//alert(obj.parent);
}
return obj.id;
}
*/

//**********************MODIFIED IN BARCODE
function traceancestors(thearray,tracevalue){
temparray = new Array();
while(thearray[tracevalue].parent!=-1){
theparent=thearray[tracevalue].id;
temparray[temparray.length]=thearray[theparent].id;
tracevalue=thearray[theparent].parent;
}//end while
return temparray;
} 





function sidemenumouseover(obj){
obj.style.cursor = 'hand';
sidemenulastclassname = obj.className;

if((cpc)&&(obj.id.split("_")[2]==cpc)){
obj.className = sidemenulastclassname;
}
else
{
obj.className = "sidemenucellover_1";
}
}

function sidemenumouseout(obj){
obj.className = sidemenulastclassname;
}

function sidemenumouseclick(obj){
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;
}
}
//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:10;display:block;height:'+height+';" 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>');
			}



//functions for imageset functionality

function imagesetarrownav(imagesetid,imagesetarray,targetimageid,imagesize,targetimagesize,currentkey,navto){
for(i=0;i<imagesetarray.length;i++){
if(currentkey==imagesetarray[i]){
arrayindex=i;
}
}
switch(navto){
case "first":
if(arrayindex!=0){arrayindex = 0;}else{return;}
break;
case "previous":
if(arrayindex>0){arrayindex--;}else{return;}
break;
case "next":
if(arrayindex<imagesetarray.length-1){arrayindex++;}else{return;}
break;
case "last":
if(arrayindex!=imagesetarray.length-1){arrayindex = imagesetarray.length-1;}else{return;}
break;
}
key = imagesetarray[arrayindex];
objid=imagesetid+"_img_"+key;
imagesetdoswap(imagesetid,objid,targetimageid,imagesize,targetimagesize,key,currentkey);
}


function imagesetdoswap(imagesetid,objid,targetimageid,imagesize,targetimagesize,key,currentkey){
//alert(objid);
if(key==currentkey){
return;
}
document.getElementById(targetimageid).src=document.getElementById(objid).src.replace('_'+imagesize+'.jpg','_'+targetimagesize+'.jpg');
document.getElementById("targetimagetitle").innerHTML=((document.getElementById('imagesetinfo_title_'+key)) ? document.getElementById('imagesetinfo_title_'+key).innerHTML:'&nbsp;');
document.getElementById("targetimagedescription").innerHTML=((document.getElementById('imagesetinfo_description_'+key)) ? document.getElementById('imagesetinfo_description_'+key).innerHTML:'&nbsp;');
document.getElementById(objid).style.borderColor='#ff0000';
document.getElementById(imagesetid+'_img_'+currentkey).style.borderColor='#ffffff';
imagesetcurrentid=key;
}




//function to set cookie via ajax
//url comprises the url (proccessor) + cookiename (to set) + cookievalue
    function setajaxcookie(url) {
//alert(url);
		var http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
		
		
        http_request.onreadystatechange = function() { ajaxcookieresponse(http_request); };
			
        http_request.open('GET', url, false);
        http_request.send(null);
       
    }

    function ajaxcookieresponse(http_request) {
            if (http_request.readyState == 4) {
            if (http_request.status == 200) {
			
			responsetext=http_request.responseText;
     				//alert(responsetext);
							
            } 
			else 
			{
                alert('There was a problem with the request.');
            //obj.innerHTML='There was a problem with sending your message.'
			}
        }
		
    }


//MOVED HERE FROM RACETECH PAGETEMLATE
function hidemenu(menuname){
menubutton=menuname.replace(/menu_/,"menubutton_");
document.getElementById(menuname).style.visibility='hidden';
}

function showmenu(menuname){
menubutton=menuname.replace(/menu_/,"menubutton_");
if(typeof(window['timer_'+menuname])!='undefined'){
eval('clearTimeout(timer_'+menuname+');');
}
document.getElementById(menuname).style.visibility='visible';
}

function closemenu(menuname){
eval('timer_'+menuname+' = setTimeout("hidemenu('+"'"+menuname+"'"+')",menuclosetime);');
}


//ADDED IN RACETECH FOR MESSAGE PANEL
/* old way with all panel content and styling in innerHTML
//smp = show message panel
function smp(itemid){
if(typeof(window['timer_messagepanel'])!='undefined'){
clearTimeout(timer_messagepanel);
}
document.getElementById("messagepanel").innerHTML = document.getElementById(messagepanelcontentprefix+itemid).innerHTML;
//document.getElementById("messagepanel").style.visibility='visible';
document.getElementById("messagepanel").style.display='';
}

//hmp = hide message panel
function hmp(){
document.getElementById("messagepanel").style.display='none';
}


//cmp = close message panel
function cmp(){
timer_messagepanel = setTimeout("hmp('messagepanel')",messagepanelclosetime);
}
*/


function smp(itemid){

if(pagename=="products"){
return;
}

if(typeof(window['timer_messagepanel'])!='undefined'){
clearTimeout(timer_messagepanel);
}


document.getElementById("messagepanelheading").innerHTML = document.getElementById("prdn_"+itemid).innerHTML;


if(document.getElementById("prdd_"+itemid)){
if(document.getElementById("prdd_"+itemid).innerHTML){
document.getElementById("messagepaneldescription").innerHTML = document.getElementById("prdd_"+itemid).innerHTML;
}
}


if(document.getElementById("prdi_"+itemid)){
if(document.getElementById("prdi_"+itemid).src){
document.getElementById("messagepanelimage").src = document.getElementById("prdi_"+itemid).src;
}
else
{
document.getElementById("messagepanelimage").src = document.getElementById("prdi_"+itemid).innerHTML;
}

}
document.getElementById("messagepanel").style.display='';
}

//hmp = hide message panel
function hmp(){
document.getElementById("messagepanel").style.display='none';
}


//cmp = close message panel
function cmp(){
timer_messagepanel = setTimeout("hmp('messagepanel')",messagepanelclosetime);
}


//Detect flash moved here in Racetech from pagetemplate
var UseFlash = 0;
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ) {
	// Check for Flash version 5 or greater in Netscape
	var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
	if (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1))>=5)
		UseFlash = 1;
} else if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
	  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	// Assume any Windows IE except for Windows 3.1 supports the OBJECT tag
	UseFlash = 1;
}


//function to preload images
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


