var loaded = false;
function loadImages() {
	if (document.images) {
		b1 = loadImage("images/v6/b1.gif");
//		p1 = loadImage("images/v6/p1.gif");

		p4 = loadImage("images/v6/p4.gif");
		nav1a = loadImage("images/v6/about.gif");
		nav2a = loadImage("images/v6/solutions.gif");
		nav3a = loadImage("images/v6/contact.gif");
		nav4a = loadImage("images/v6/workzone.gif");
		nav5a = loadImage("images/v6/quotes.gif");
		nav6a = loadImage("images/v6/home.gif");
		dot = loadImage("images/v6/dot.gif");
		blank = loadImage("images/blank.gif");
		s0 = loadImage("images/v6/spacing.gif");
		s1 = loadImage("images/v6/spacing11.gif");
		s2 = loadImage("images/v6/spacing22.gif");
		arrow = loadImage("images/arrow3.gif");

   comp1 = loadImage("images/sunStation1.gif");
   comp2 = loadImage("images/sunStation2.gif");
   comp3 = loadImage("images/sunStation3.gif");
   comp4 = loadImage("images/sunStation5.gif");

   //americanOrient1 = loadImage("images/americanOrient1.gif");
   //americanOrient2 = loadImage("images/americanOrient2.gif");
   //rugfinder1 = loadImage("images/rugfinder1.gif");
   rugfinder2 = loadImage("images/rugfinder2.gif");
   bak = loadImage("images/breadandkabob.gif");
   //aceTrans2 = loadImage("images/breadandkabob.gif");
   ar = loadImage("images/zibarugs2.gif");
   // accessLimo1 = loadImage("images/accessLimo1.gif");
   // accessLimo2 = loadImage("images/accessLimo2.gif");
   //accessLimo3 = loadImage("images/accessLimo3.gif");

		loaded = true;
	}
}

function loadImage(img) {
		temp = new Image();
		temp.src = img;
		return temp;
}

function roll(imgid,imgnew) {
	if (document.images && loaded) {
		document.images[imgid].src=eval(imgnew + ".src");
	}
}

function initialize() {
	loadImages();
	//setWindow();
}

//function BrowserDetect() {
	var agent = navigator.userAgent.toLowerCase(); 
	
	// Browser version
	var versionMajor = parseInt(navigator.appVersion); 
	var versionMinor = parseFloat(navigator.appVersion); 
    
	// Browser name
	var ns    = (agent.indexOf('mozilla')!=-1 && agent.indexOf('spoofer')==-1 && agent.indexOf('compatible') == -1 && agent.indexOf('opera')==-1 && agent.indexOf('webtv')==-1); 
	var ns2   = (ns && versionMajor == 2); 
	var ns3   = (ns && versionMajor == 3); 
	var ns4   = (ns && versionMajor == 4); 
	var ns4up = (ns && versionMajor >= 4); 
	var ns6   = (ns && versionMajor == 5); 
	var ns6up = (ns && versionMajor >= 5); 
	var ie    = (agent.indexOf("msie") != -1); 
	var ie3   = (ie && versionMajor < 4); 
	var ie4   = (ie && versionMajor == 4 && agent.indexOf("msie 4.0") != -1); 
	var ie4up = (ie && versionMajor >= 4); 
	var ie5   = (ie && versionMajor == 4 && agent.indexOf("msie 5.0") != -1); 
	var ie55  = (ie && versionMajor == 4 && agent.indexOf("msie 5.5") != -1);
	var ie5up = (ie && !ie3 && !ie4); 
	var ie6   = (ie && versionMajor == 4 && agent.indexOf("msie 6.0") != -1);
	var ie6up = (ie && !ie3 && !ie4 && !ie5 && !ie55); 
	var opera = (agent.indexOf("opera") != -1); 
	var webtv = (agent.indexOf("webtv") != -1); 
	var aol   = (agent.indexOf("aol") != -1);   
//}

//BrowserDetect();
if (!ns6up && !ie5up){
	var msg = "\n\nIncompatible Browser Detected. - "+versionMinor + "\n"+
	"Minimal browser requirements for this Web site is\nIE 5.0 or higher, or Netscape Navigator 6.0 higher\nYour browser will not display this Web-site properly.\nPlease update your browser by downloading the latest version.\n";
	alert(msg);
}

function PrintThis() {
	if (window.print) {
		setTimeout('window.print();',200);
	} else if (agent.indexOf("mac") != -1) {
		alert("Press 'Cmd+p' on your keyboard to print article.");
	} else {
		alert("Press 'Ctrl+p' on your keyboard to print article.")
	}
}

function PrePrint(page) {
	showWin = window.open(page,'viewer','height=300,width=600,status,left=10,screenX=10,top=200,screenY=200,z-lock,scrollbars=yes');
}

function focus (){
	if (document.forms.length > 0){
		document.forms[0].elements[0].focus();
	}
}

//---------------
var delay = 1000 * 5;
var images = new Array ( "blank", "bak", "rugfinder2", "ar");
var size = images.length;
var index = 0;
function doAutoSlide() {
	if (document.images)
		setInterval("autoSlide()", delay);
}

function autoSlide() {
    index++;
	if (index == size)
		index = 0;
	roll('compScreen', images[index]);
}


var msg = "\t\t\t\n\n\n\nILLEGAL OPERATION !\t\n\n\n\n";
function click(e) {
	if (document.all) {
		if (event.button == 2) {
			alert(msg);
			return false;
		}
	} else {
		if (e.which == 3) {
			alert(msg);
			return false;
		}
	}
}
if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;


function setTexStatus() {
	if (document.quote.c2.selectedIndex > 4 ){
		document.quote.c3.selectedIndex=1;
		document.quote.c3.disabled=true;
	} else {
		document.quote.c3.selectedIndex=0;
		document.quote.c3.disabled=false;
	}
}
function setImageStatus() {
	if (document.quote.c5.selectedIndex > 3){
		document.quote.c6.selectedIndex = 1;
		document.quote.c6.disabled=true;
	} else {
		document.quote.c6.selectedIndex=0;
		document.quote.c6.disabled=false;
	}
}
function setLogoStatus() {
	if (document.quote.c5.selectedIndex > 3){
		document.quote.logoStatus.selectedIndex=1;
		document.quote.logoStatus.disabled=true;
	} else {
		document.quote.logoStatus.selectedIndex=0;
		document.quote.logoStatus.disabled=false;
	}
}

function setUrl() {
	if (document.quote.task.selectedIndex > 2 && document.quote.task.selectedIndex > 6 ){
		document.quote.url.value="Type the URL of current site here.";
		//document.quote.logoStatus.disabled=true;
	} else {
		//document.quote.logoStatus.selectedIndex=0;
		//document.quote.logoStatus.disabled=false;
	}
}

function setThisUrl() {
	if (document.quote.url.value="Type the URL of current site here."){
		document.quote.url.value="www.";
		//document.quote.logoStatus.disabled=true;
	} else {
		//document.quote.logoStatus.selectedIndex=0;
		//document.quote.logoStatus.disabled=false;
	}
}

function sendIt (){
	if (document.forms.length > 0){
		document.forms[0].submit();
	}
}

function setWindow(){
	if (screen.width > 800){
		alert("The interface of this website has been optimized for display resolution of 800 x 600.\nYour monitor resolution is " + screen.width +" x "+ screen.height + ".\nYou may experience difficulties in viewing this Website as intended to display." );
		window.resizeTo(800,600);
	}
}


//----- WebColorizer functions --
function selectColor (color) {
	var action = document.Swatch.act.selectedIndex;
	var what = document.Swatch.act.options[action];
	var imgName = 'im' + color ;
	var color1 = color;
	color = '#' + color ;

//alert (imgName);
	roll(document.Swatch.prevClick.value,'blank');
	roll(imgName, 'cross1');
	document.Swatch.prevClick.value = imgName;
	window.status = 'Apply on ' + "what";
	if ( action == 0) {
	    document.Swatch.back.value = color;
	    document.bgColor= color;
	    //alert ('Three colors are selected already.If you would like to select another one,you must clear a selected color first.';
	} else if ( action == 1) {
	    document.Swatch.titleText.value = color;
	    if (document.all)
	      document.all.titleTextColor.color = color;
	} else if ( action == 2) {
	    document.Swatch.bodyText.value = color;
	    if (document.all)
	      document.all.bodyTextColor.color = color;
	} else if ( action == 3) {
	    document.Swatch.link.value = color;
	    if (document.all)
	      document.all.linkColor.color = color;
	} else if ( action == 4) {
	    document.Swatch.top.value = color;
	    if (document.all)
	      document.all.topBg.bgColor = color;
	}
	//window.status = 'Apply on ' + what;
}


function clearColor1 () {
	if (document.Swatch.back.value != '' ) {
		document.Swatch.back.value = '';
		if (document.all)
			document.all.sample1.bgColor = '#FFFFFF';
	}
}

function clearColor2 () {
	if (document.Swatch.webColor2.value != '' ) {
		document.Swatch.webColor2.value = '';
		if (document.all)
			document.all.sample2.bgColor = '#FFFFFF';
	}
}
function clearColor3 () {
	if (document.Swatch.webColor3.value != '' ) {
		document.Swatch.webColor3.value = '';
		if (document.all)
			document.all.sample3.bgColor = '#FFFFFF';
	}
}
