var divurl = "./ClickCall/";
var div_width = "770";
var div_height = "450";
var div_x = "100";
var div_y = "100";

/***** AJAX PSUEDO-CLASS OBJ *****/
function AJAXDIV()
{
	this.divurl = divurl;
	this.div_width = div_width;
	this.div_height = div_height;
	this.div_x = div_x;
	this.div_y = div_y;
	
	/**
	Sets up the XMLOBJ Request Object
	**/
	this.GetXMLObj = function()
	{
		var xmlHttpReq = false;
		var self = this;

		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		return self.xmlHttpReq;

	}

	/** used for ajax request initiation **/
	this.Request = function(strURL)
	{
		var self = this; 
		xmlHttpReq = this.GetXMLObj();
		xmlHttpReq.open('GET', strURL, true);
		xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttpReq.onreadystatechange = function()
		{
			if (xmlHttpReq.readyState == 4)
			{
				self.CreateDiv("callcenter", xmlHttpReq.responseText, "770", "450", "100", "100");
			}
		}
		xmlHttpReq.send(null);
	}

	/*
		Pass in the parameters by which you'd like to specify the
		div constraints.
	*/
	this.CreateDiv = function(id, html, width, height, left, top)
	{
		var obj= document.getElementById("callcenter");
		if(typeof obj != "undefined" && obj != null)
		{
			obj.style.visibility = "visible";
			return;
		}	

		var newdiv = document.createElement('div');
		newdiv.setAttribute('id', id);

		if (width) 
		{
			newdiv.style.width = width;
		}

		if (height) 
		{
			newdiv.style.height = height;
		}

		if ((left || top) || (left && top)) 
		{
			newdiv.style.position = "absolute";

			if (left) 
			{
			   newdiv.style.left = left;
			}

			if (top) 
			{
			   newdiv.style.top = top;
			}
		}

		newdiv.style.border= "1px solid #cccccc";

		if (html) 
		{
			newdiv.innerHTML = html+"<br /><a href='javascript:new AJAXDIV().CloseDivWindow();' style='font-size: 12px; font-family: Arial; line-height: 15px; padding-left: 100px; text-decoration: none; color: #666666'>Close Window</a>";
		} 
		else 
		{
			newdiv.innerHTML = "nothing";
		}

		document.body.appendChild(newdiv);

	}
	this.CloseDivWindow = function()
	{
		var obj= document.getElementById("callcenter");
		if(typeof obj != "undefined" && obj != null)
		{
			obj.style.visibility = "hidden";
		}
	}
	this.GetCallDiv= function()
	{	
		var url = this.divurl+"callformdiv.html";
		this.Request(url);
	}
}

/***** END AJAX REQUEST *****/


/** DIALPAD FUNCTIONS **/
function DialPad()
{
	this.divurl = divurl;
	this.div_id=  "dialpad";
	this.phone_id = "phone";
	
	this.AddNumber = function(num)
	{
		var obj= document.getElementById(this.phone_id);
		if(typeof obj != "undefined" && obj != null)
		{
			obj.value += num;
		}
	}
	this.FadeNumber = function(obj_name)
	{
		var obj= document.getElementById(obj_name);
		if(typeof obj != "undefined" && obj != null)
		{
			if(IsIE())
				obj.style.filter = "alpha(opacity=70)";
			else
				obj.style.MozOpacity = "0.7";
		}
	}
	this.UnFadeNumber = function(obj_name)
	{
		var obj= document.getElementById(obj_name);
		if(typeof obj != "undefined" && obj != null)
		{
			if(IsIE())
				obj.style.filter = "alpha(opacity=100)";
			else
				obj.style.MozOpacity = "1";
		}
	}

	this.OpenDialPad = function(tmp_url)
	{
		var thispath = (tmp_url!="undefined" && tmp_url!=null)?tmp_url:this.divurl;
		var html = "<table>";
		for(i=0; i<10; i++)
		{
			if(i!=0)
			{
				html+= "<td><a style='cursor:pointer;' onclick=\"new DialPad().AddNumber('"+i+"');\" border='0' onmouseover=\"new DialPad().FadeNumber('img"+i+"');\" onmouseout=\"new DialPad().UnFadeNumber('img"+i+"');\" ><img width='71' height='25' id='img"+i+"' src='"+thispath+"images/"+i+".gif' border='0'  /></a></td>";
			}
			if(i%3==0)
			{
				html+=(html=="")?"<tr>":"</tr><tr>";
			}
		}
		html+= "<tr><td><img src='"+thispath+"images/star.gif' width='71' height='25' border='0' /></td><td><a style='cursor:pointer;' onclick=\"new DialPad().AddNumber('0');\" border='0' onmouseover=\"new DialPad().FadeNumber('img0');\" onmouseout=\"new DialPad().UnFadeNumber('img0');\"  ><img width='71' height='25' id='img0' src='"+thispath+"images/0.gif' border='0'  /></a></td><td><img width='71' height='25' src='"+thispath+"images/pound.gif' border='0' /></td></tr>";
		html+= "</table>";


		var obj= document.getElementById(this.div_id);
		if(typeof obj != "undefined" && obj != null)
		{
			obj.style.left = "500px";
			obj.style.top = "150px";
			obj.style.border = "1px solid #cccccc";
			obj.style.backgroundColor = "#eeeeee";
			obj.innerHTML = html;
		}
	}
	this.CloseDialPad = function()
	{
		var obj= document.getElementById(this.div_id);
		if(typeof obj != "undefined" && obj != null)
		{
			obj.style.visibility = "hidden";
		}
	}
}
/** END DIALPAD FUNCTIONS **/
