// JavaScript Document
isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;
var ZINDEX=1;
function GoTo(location){
	if(location)
		document.location = location;
}
function GoToOrderNow(){
	//window.open('Services.php', 'Services', 'width=815,height=600,scrollbars=1,resizable=fals,status=false,top=30,left=100');
	GoTo('DASSCO-Services.php');
}
function ddInit(e){
	  topDog=isIE ? "BODY" : "HTML";
	  if(eve=event.srcElement)
		while(!eve || eve.tagName!='DIV'){
			  if(eve.parentElement)
				eve=eve.parentElement;
			  else
				break;	
		  } 
	  whichDog= eve;  
	  hotDog=isIE ? event.srcElement : e.target;
	  if(hotDog.parentElement && document.getElementById('LayerTitleBar'))
		while (hotDog.id!="LayerTitleBar" && hotDog.tagName!=topDog){
				hotDog=(isIE) ? (hotDog.parentElement) : (hotDog.parentNode);
					
		}  
	  if (hotDog.id=="LayerTitleBar"){
		offsetx=isIE ? event.clientX : e.clientX;
		offsety=isIE ? event.clientY : e.clientY;
		nowX=parseInt(whichDog.style.left);
		nowY=parseInt(whichDog.style.top);
		ddEnabled=true;
		document.onmousemove=dd;
	  }
}

function dd(e){	
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function showMe(){
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.theLayer.visibility="show";
}
if(isIE){
	document.onmousedown=ddInit;
	document.onmouseup=Function("ddEnabled=false");
}
//////////////////////////////////////////////////////////////////////////////
function ContactUs(top){
	if(!top) top = 80;
	ShowDynamicLayer('ContactusLayer', 'Contact us', 'Contactus.htm', 200, top, 600, 300, 'Form');
}
function FreeQuote(top){
	if(!top) top = 100;
	ShowDynamicLayer('QuoteLayer', 'Free quote request', 'FreeQuoteRequest.htm', 350, top, 330, 300, 'Form')
}
function ShowDynamicLayer(id, Subject, FileName, left, top, width, height, folder){
	if(!left)
		left = 200;
	if(!top)
		top = 50;
	if(!width)
		width = 600;
	if(!height)
		height = 300;
	if(!folder)
		folder = 'Pages';		
	ShowLayer(id, Subject, '', left, top, width, height);
	xajax_FillPage(FileName, '', 'Inside'+id, '', folder);
}
function ShowLayer(id, Subject, Body, left, top, width, height){
	scroll(0,0);
	//if(!left)
		left = 200;
	//if(!top)
		top = 50;
	if(!width)
		width = 600;
	if(!height)
		height = 300;
	if(!document.getElementById(id)){
		 var div=document.createElement('div');
		 div.setAttribute('id',id);
		 div.setAttribute('zIndex',ZINDEX);
		 div.style.position = 'absolute';
		 div.style.height = height+'px';
		 div.style.width = width+'px';
		 div.style.left = left+'px';
		 div.style.top = top+'px';
	 	 Scroll = "overflow-y:scroll;";
		 div.innerHTML = '<table cellpadding=0 cellspacing=0 border=1 bordercolor=\'#376596\' class=Form><tr><td><table border="0" cellspacing="0" cellpadding="0" width=100%><tr><td class=\'Move WhiteText BlueBack\' id=\'LayerTitleBar\' width=\''+width+'px\' onMouseover=\'isHot=true;if (isN4) ddN4("'+id+'")\' onMouseout="isHot=false;"><strong>'+Subject+'</strong></td><td class=BlueBack width=\'19px\' height=\'19px\' dir=rtl><img src=Images/close.gif class=Hand onclick=HideLayer(\''+id+'\')></td></tr></table></tr><tr><td id=\'Inside'+id+'\' colspan=2 height='+height+' valign=top style=\'padding=5px\'>'+Body+'</td></tr></table>';
		 document.getElementsByTagName('body')[0].appendChild(div); 
		 ZINDEX++;
	}else{
		document.getElementById(id).style.display = 'block';
		document.getElementById(id).style.visibility = 'visible';
	}
}
function HideLayer(child){
   var div=document.getElementById(child);
   if(!div){return};
   div.parentNode.removeChild(div); 
} 
function ShowSlide(target, interval, loop){
	if(document.getElementById(target)){
		if(SlideImages.length > 0){
			i=0;
			document.getElementById(target).innerHTML = '<img src="'+SlideImages[i++]+'" width=533 height=200>';
			setTimeout('showImage(SlideImages, "'+target+'", '+interval+', '+i+', '+loop+');', interval);			
		}else
			alert('Slide array has not been set properly.');
	}else
		alert('Target has not been set properly.');		
}
function showImage(SlideImages, target, interval, iteration, loop){
	if(!SlideStop){
		fadeIn(document.getElementById(target));
		if(iteration < SlideImages.length){
			document.getElementById(target).innerHTML = '<img src="'+SlideImages[iteration++]+'" width=533 height=200>';
			setTimeout('showImage(SlideImages, "'+target+'", '+interval+', '+iteration+', '+loop+');', interval);		
		}else{
			if(loop)
				setTimeout('showImage(SlideImages, "'+target+'", '+interval+', 0, '+loop+');', 0);
			else
				return;
		}
	}else{
		return;
	}
}
function fadeOut(oDiv) {
	if(isIE){
		oDiv.style.filter="blendTrans(duration=1)";
		// Make sure the filter is not playing.
		if (oDiv.filters.blendTrans.status != 1) {
			oDiv.filters.blendTrans.apply();
			oDiv.style.visibility="hidden";
			oDiv.filters.blendTrans.play();
		}
	}
}
function fadeIn(oDiv) {
	if(isIE){
		oDiv.style.filter="blendTrans(duration=2)";
		// Make sure the filter is not playing.
		if (oDiv.filters.blendTrans.status != 2) {
			oDiv.filters.blendTrans.apply();
			oDiv.style.visibility="visible";
			oDiv.filters.blendTrans.play();
		}
	}
}
function MousePOSX(){
	return event.clientX + document.body.scrollLeft;
}
function MousePOSY(){
	return event.clientY + document.body.scrollTop;
}
function checkbox_check(element){
	if(element){
		if(!element.length) {
			if(element.checked)
				return true;
		} else {
			sizeOfCheck=element.length;
			if(sizeOfCheck==0)
				return false;
			for(i=0;i<sizeOfCheck;i++){
				if(element[i].checked)
					return true;			
			}	
		}
		return false;
	}
}
function FillAddress(){
	document.getElementById('fldDeliveryAddressLine1').value = document.getElementById('fldContactAddressLine1').value;
	document.getElementById('fldDeliveryAddressLine2').value = document.getElementById('fldContactAddressLine2').value
	document.getElementById('fldDeliverySuburb').value = document.getElementById('fldContactSuburb').value;
	document.getElementById('fldDeliveryPostCode').value = document.getElementById('fldContactPostCode').value;
	document.getElementById("fldDeliveryState").options[document.getElementById("fldContactState").selectedIndex].selected = true;
}
function DoRegister(array){
	xajax_Register(array);
}
function ValidateRegister(){
	if(validate('frm_Register')){
		if(document.frm_Register.fld_Confirm_Password.value != document.frm_Register.fld_Password.value){
			alert('Check your password');
			return false;				
		}else{
			DoRegister(xajax.getFormValues('frm_Register'));
			return false
		}
	}else return false	
}