// JavaScript Document

// Change Background
function clapOn(the_id)
{
var source = document.getElementById(the_id);
source.className = 'on';
}

function clapOff(the_id)
{
var source = document.getElementById(the_id);
source.className = 'off';
}

function clapOn2(the_id)
{
var source = document.getElementById(the_id);
source.className = 'on2';
}

function clapOff2(the_id)
{
var source = document.getElementById(the_id);
source.className = 'off2';
}

function Form() {
	var left = (screen.width/2)-(300/2);
	var top = (screen.height/2)-(310/2);
	window.open('http://www.webnow.co.za/ContactForm.asp', '', 'width=300, height=310, top='+top+', left='+left);
}

//image change
function ImageChanger(imgObject)
{
   if(imgObject.images && "http://www.webnow.co.za/images/expand.gif")
    {
	imgObject.src = "http://www.webnow.co.za/images/collapse.gif"
    }
    else
    {
	imgObject.src = "http://www.webnow.co.za/images/expand.gif"	
    }	
}

function ImgChange(the_id)
{
	var Change
	Change = document.getElementById(the_id);

	//alert(Change);
	
	if (Change.src.indexOf("http://www.webnow.co.za/images/expand.gif") != -1) {
		Change.src = "http://www.webnow.co.za/images/collapse.gif";
	}
	else {
		Change.src = "http://www.webnow.co.za/images/expand.gif";
	}
}

// Show and Hide
function ShowHide(intNo, intMax)
{
 var objElem;
 for (i = 1; i <= intMax; i++)
 {
  objElem = document.getElementById("plan_" + i);
  if (objElem && objElem.style)
  {
   if (intNo == i)
   {
     if (objElem.style.display == "")
     {
       objElem.style.display = "none";
     }
     else
     {
       objElem.style.display = "";
     }
   }
   else
   {
    objElem.style.display = "none";
   }
  }
 }
}

function ShowHideMe(intNo, intMax)
{
 var objElem;
 for (i = 1; i <= intMax; i++)
 {
  objElem = document.getElementById("hosting_" + i);
  if (objElem && objElem.style)
  {
   if (intNo == i)
   {
     if (objElem.style.display == "")
     {
       objElem.style.display = "none";
     }
     else
     {
       objElem.style.display = "";
     }
   }
   else
   {
    objElem.style.display = "none";
   }
  }
 }
}

function ShowHides(intNo, intMax)
{
 var objElem;
 for (i = 1; i <= intMax; i++)
 {
  objElem = document.getElementById("faq_" + i);
  if (objElem && objElem.style)
  {
   if (intNo == i)
   {
     if (objElem.style.display == "")
     {
       objElem.style.display = "none";
     }
     else
     {
       objElem.style.display = "";
     }
   }
   else
   {
    objElem.style.display = "none";
   }
  }
 }
}

function ShowHider(intNo, intMax)
{
 var objElem;
 for (i = 1; i <= intMax; i++)
 {
  objElem = document.getElementById("res_" + i);
  if (objElem && objElem.style)
  {
   if (intNo == i)
   {
     if (objElem.style.display == "")
     {
       objElem.style.display = "none";
     }
     else
     {
       objElem.style.display = "";
     }
   }
   else
   {
    objElem.style.display = "none";
   }
  }
 }
}

//Multi Show/Hide

function MultiToggle(DivArrayIDs, OpenIndex)
{
	if (DivArrayIDs && DivArrayIDs.length > 0)
	{
		var objDiv = false;
		for(dIdx = 0; dIdx < DivArrayIDs.length; dIdx++)
		{
			objDiv = document.getElementById(DivArrayIDs[dIdx]);
			if (objDiv && objDiv.style)
			{
				if (OpenIndex)
				{
					if (OpenIndex == dIdx)
					{
						objDiv.style.display = "";
					}
					else
					{

						objDiv.style.display = "none";
					}
				}
				else
				{
					if (objDiv.style.display == "")
					{
						objDiv.style.display = "none";
					}
					else
					{
						objDiv.style.display = "";
					}
				}
			}
		}
	}
}

// Open Map

function OpenMap()
{
window.open('http://www.webnow.co.za/images/officemap.jpg','map','width=620,height=400,toolbar=0,location=0')
}

// Domain Lookup
	var arrDomOffers = new Array();
	arrDomOffers.push(".co.za");
	arrDomOffers.push(".org.za");
	arrDomOffers.push(".com");
	arrDomOffers.push(".net");
	arrDomOffers.push(".org");
	var arrNowOffer = new Array();
	var arrMain = new Array(2);
	var ResHtm = "mainResponse";
	var cmdChk = "cmdCheckAvailability";
	var slotsDiv = "offerSlots";

	function checkTxt(objTxt)
	{
		if (objTxt.value.length > 0)
		{
			document.getElementById(cmdChk).disabled = false;
		}
		else
		{
			document.getElementById(cmdChk).disabled = true;
		}
	}

	function DoMainSearch()
	{
		document.getElementById("rowReserve").style.display = "none";
		arrMain[0] = document.getElementById("txtDomainName").value;
		arrMain[1] = document.getElementById("cboDomainType").value;
		document.getElementById(cmdChk).disabled = true;
		arrNowOffer = new Array();
		if (arrMain[0].length > 0)
		{
			for (iDO = 0; iDO < arrDomOffers.length; iDO++)
			{
				if (arrDomOffers[iDO].toLowerCase() != arrMain[1].toLowerCase())
				{
					arrNowOffer.push(arrDomOffers[iDO]);
				}
			}
			cJaxStatusSet(2, ResHtm);
			document.getElementById(slotsDiv).innerHTML = "";
			DoRequest("ops/domains.aspx?A=1&DN=" + arrMain[0] + "&DT=" + arrMain[1] + "", 0)
		}
		else
		{
			alert("Please provide a domain name to search for.");
		}
		return false;
	}
	
	function RequestStateHandler(objRequest, tskIdx)
	{
		var objMain = document.getElementById(ResHtm);
		obj1 = objMain;
		var needHTML = "";
		var reqID = (tskIdx * 1);
		if (reqID == 0)
		{
			if (objRequest.responseText == "1")
			{
				needHTML = makeCheckBox("resDom0", true, true, arrMain[1], "", "allowReserve()") + "The domain [<b>" + arrMain[0] + arrMain[1] + "</b>] is available!";
				document.getElementById("hidDomName").value = arrMain[0];
				document.getElementById("rowReserve").style.display = "";
				allowReserve();
			}
			else
			{
				//needHTML = objRequest.responseText;
				needHTML = "The domain is already registered...";
				document.getElementById("rowReserve").style.display = "none";
			}
			CheckOffers();
		}
		else
		{
			objMain = document.getElementById("slot" + reqID);
			obj2 = objMain;
			if (objRequest.responseText == "1")
			{
				needHTML = makeCheckBox("resDom" + reqID, false, true, arrNowOffer[reqID - 1], "", "allowReserve()") + " <b>" + arrMain[0] + arrNowOffer[reqID - 1] + "</b> is available!"
				document.getElementById("hidDomName").value = arrMain[0];
				document.getElementById("rowReserve").style.display = "";
			}
			else
			{
				needHTML = makeCheckBox(false, false) + "<s>" + arrMain[0] + arrNowOffer[reqID - 1] + "</s>"
			}
		}
		if (objMain)
		{
			objMain.innerHTML = needHTML;
		}
		else
		{
			alert("Error - response div not existed! [" + obj1 + " : " + obj2 + "], reqID [" + reqID + "]");
		}
		document.getElementById(cmdChk).disabled = false;
	}
	
	function CheckOffers()
	{
		var objOffer = document.getElementById(slotsDiv);
		var needHTML = "";
		for (iNO = 0; iNO < arrNowOffer.length; iNO++)
		{
			var UseNo = iNO + 1;
			needHTML += "<div id='slot" + UseNo + "'></div>";
		}
		objOffer.innerHTML = "<br><div class='Content_SubHeading'>Why not also reserve these?</div>" + needHTML;
		setTimeout("doCallers();", 100);
	}
	
	function doCallers()
	{
		for (iNO = 0; iNO < arrNowOffer.length; iNO++)
		{
			var UseNo = iNO + 1;
			setTimeout("DoRequest(\"ops/domains.aspx?A=1&DN=" + arrMain[0] + "&DT=" + arrNowOffer[iNO] + "\", " + UseNo + ")", 10);
			cJaxStatusSet(4, "slot" + UseNo, "" + arrMain[0] + arrNowOffer[iNO] + "&nbsp;");
		}
	}
	
	function allowReserve()
	{
		var objBtn = GetControl("cmdReserve");
		if (objBtn != null)
		{
			var FoundSelect = false;
			var objChk;
			for (sIdx = 0; sIdx < arrNowOffer.length; sIdx++)
			{
				objChk = document.getElementById("resDom" + sIdx);
				if (objChk && objChk.checked)
				{
					FoundSelect = true;
					break;
				}
			}
			if (FoundSelect)
			{
				objBtn.disabled = false;
			}
			else
			{
				objBtn.disabled = true;
			}
		}
	}

/***********************************************
* Ultimate Fade-In Slideshow (v1.51): © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
 
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=["http://www.webnow.co.za/images/WebHosting.jpg", "", ""] //plain image syntax
fadeimages[1]=["http://www.webnow.co.za/images/domainName.jpg", "", ""] //image with link syntax
fadeimages[2]=["http://www.webnow.co.za/images/adsl.jpg", "", ""] //image with link syntax
fadeimages[3]=["http://www.webnow.co.za/images/resellers.jpg", "", ""] //image with link syntax
 
var fadebgcolor=""

////NO need to edit beyond here/////////////
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
 
var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div></div>')
else
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
else if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
obj.tempobj.style.opacity=obj.degree/101
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(){
if (this.pausecheck==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseovercheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=this.degree/100
else if (crossobj.style.opacity&&!crossobj.filters)
crossobj.style.opacity=this.degree/101
}
 
 
fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
}
this.rotateimage()
}

//Chrome Drop Down Menu v2.01- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated: November 14th 06- added iframe shim technique

var cssdropdown={
disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseout
disablemenuclick: true, //when user clicks on a menu item with a drop down menu, disable menu item's link?
enableswipe: 1, //enable swipe effect? 1 for yes, 0 for no
enableiframeshim: 1, //enable "iframe shim" technique to get drop down menus to correctly appear on top of controls such as form objects in IE5.5/IE6? 1 for yes, 0 for no

//No need to edit beyond here////////////////////////
dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, swipetimer: undefined, bottomclip:0,

getposOffset:function(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
},

swipeeffect:function(){
if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight)){
this.bottomclip+=10+(this.bottomclip/10) //unclip drop down menu visibility gradually
this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"
}
else
return
this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 10)
},

showhide:function(obj, e){
if (this.ie || this.firefox)
this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
if (this.enableswipe==1){
if (typeof this.swipetimer!="undefined")
clearTimeout(this.swipetimer)
obj.clip="rect(0 auto 0 0)" //hide menu via clipping
this.bottomclip=0
this.swipeeffect()
}
obj.visibility="visible"
}
else if (e.type=="click")
obj.visibility="hidden"
},

iecompattest:function(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
},

clearbrowseredge:function(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset
var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ //move up?
edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
},

dropit:function(obj, e, dropmenuID){
if (this.dropmenuobj!=null) //hide previous menu
this.dropmenuobj.style.visibility="hidden" //hide menu
this.clearhidemenu()
if (this.ie||this.firefox){
obj.onmouseout=function(){cssdropdown.delayhidemenu()}
obj.onclick=function(){return !cssdropdown.disablemenuclick} //disable main menu item link onclick?
this.dropmenuobj=document.getElementById(dropmenuID)
this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}
this.dropmenuobj.onmouseout=function(e){cssdropdown.dynamichide(e)}
this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}
this.showhide(this.dropmenuobj.style, e)
this.dropmenuobj.x=this.getposOffset(obj, "left")
this.dropmenuobj.y=this.getposOffset(obj, "top")
this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
this.positionshim() //call iframe shim function
}
},

positionshim:function(){ //display iframe shim function
if (this.enableiframeshim && typeof this.shimobject!="undefined"){
if (this.dropmenuobj.style.visibility=="visible"){
this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px"
this.shimobject.style.left=this.dropmenuobj.style.left
this.shimobject.style.top=this.dropmenuobj.style.top
}
this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")? "block" : "none"
}
},

hideshim:function(){
if (this.enableiframeshim && typeof this.shimobject!="undefined")
this.shimobject.style.display='none'
},

contains_firefox:function(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
},

dynamichide:function(e){
var evtobj=window.event? window.event : e
if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
this.delayhidemenu()
else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
this.delayhidemenu()
},

delayhidemenu:function(){
this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden'; cssdropdown.hideshim()",this.disappeardelay) //hide menu
},

clearhidemenu:function(){
if (this.delayhide!="undefined")
clearTimeout(this.delayhide)
},

startchrome:function(){
for (var ids=0; ids<arguments.length; ids++){
var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
for (var i=0; i<menuitems.length; i++){
if (menuitems[i].getAttribute("rel")){
var relvalue=menuitems[i].getAttribute("rel")
menuitems[i].onmouseover=function(e){
var event=typeof e!="undefined"? e : window.event
cssdropdown.dropit(this,event,this.getAttribute("rel"))
}
}
}
}
if (window.createPopup && !window.XmlHttpRequest){ //if IE5.5 to IE6, create iframe for iframe shim technique
document.write('<IFRAME id="iframeshim"  src="" style="display: none; left: 0; top: 0; z-index: 90; position: absolute; filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')
this.shimobject=document.getElementById("iframeshim") //reference iframe object
}
}

}

// 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];}}
}
