//for print selected content
function printSelectedContent(contentID)
{
	var documentContent = document.getElementById(contentID);
	
	var WindowObject = window.open('', "Data", "width=420,height=225,top=250,left=345,toolbars=no,scrollbars=no,status=no,resizable=no");

	WindowObject.document.write(documentContent.innerHTML);

	WindowObject.document.close();
	WindowObject.focus();
	WindowObject.print();
	WindowObject.close();
}



//for search tab
function getColor(styleTabID)
{
	for(i=1; i<7; i++)
	{
		var styleTabName = 'styleTab'+i;
		if(styleTabName != styleTabID)
		{
			document.getElementById(styleTabName).style.backgroundColor='';
		}
	}
	document.getElementById(styleTabID).style.backgroundColor = '#ffe552';
}


// ajax generic http object
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
}


// this function is responsible to display sub category
function displaySubCategory(categoryID)
{
	//return;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	var url="./ajax/subcategorylist.php?categoryID="+categoryID;
	//alert(url);
	xmlHttp.onreadystatechange=displaySubCategoryOptions;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function displaySubCategoryOptions() 
{ 
	if (xmlHttp.readyState==4)
	{	
		document.getElementById('hiddenSubCategory').innerHTML=xmlHttp.responseText;		
	}
}



// Password strong , weak  check

function passwordSecurityCheck(passwordval)
{
	//alert(passwordval);
	//return;
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	var url="./ajax/passwordcheck.php?paswordval="+passwordval;
	//alert(url);
	//return;
	xmlHttp.onreadystatechange=PasswordValueResponse;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function PasswordValueResponse() 
{
	if (xmlHttp.readyState==4)
	{	
		document.getElementById('show_message').innerHTML=xmlHttp.responseText;		
	}
	else
	{
		return false;
	}
}

// url check availability

function urlAvailabilityCheck(siteUrl)
{
	//alert(siteUrl);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	var url="./ajax/urlavailabilitycheck.php?siteUrl="+siteUrl;
	//alert(url);
	xmlHttp.onreadystatechange=siteUrlResponse;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}
function siteUrlResponse() 
{
	if (xmlHttp.readyState==4)
	{	
		document.getElementById('hiddenUrlAvailability').innerHTML=xmlHttp.responseText;		
	}
	else
	{
		return false;
	}
}

function subdomainnameavailabilitycheck(SubdomainName)
{
	//alert("<?php echo $_SERVER['DOCUMENT_ROOT'];?>");
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	var url="./ajax/subdomainavailabilitycheck.php?SubdomainName="+SubdomainName;
	//alert(url);
	xmlHttp.onreadystatechange=subDomainResponse;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}

function subDomainResponse() 
{
	if (xmlHttp.readyState==4)
	{	
		document.getElementById('hiddenSubdomainAvailablity').innerHTML=xmlHttp.responseText;		
	}
	else
	{
		return false;
	}
}

function emailavailabilitycheck(Email)
{
	//alert(Email);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	var url="./ajax/emailavailabilitycheck.php?Email="+Email;
	//alert(url);
	xmlHttp.onreadystatechange=EmailResponse;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}

function EmailResponse() 
{
	if (xmlHttp.readyState==4)
	{	
		document.getElementById('hiddenEmailAvailablity').innerHTML=xmlHttp.responseText;		
	}
	else
	{
		return false;
	}
}

// this function is responsible to display payment
function displayPayment(receiveMethodID)
{
	//return;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	var url="./ajax/paymentlist.php?receiveMethodID="+receiveMethodID;
	//alert(url);
	xmlHttp.onreadystatechange=displayPaymentOptions;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function displayPaymentOptions() 
{ 
	if (xmlHttp.readyState==4)
	{	
		document.getElementById('hiddenPayment').innerHTML=xmlHttp.responseText;		
	}
}
//for popup side bar info

// JavaScript for Caption on input filed

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function prepareInputsForHints() {
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++){
		// test to see if the hint span exists first
		if (inputs[i].type == 'text' || inputs[i].type == 'password')
		{
			if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
				// the span exists!  on focus, show the hint
				inputs[i].onfocus = function () {
					this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
				}
				// when the cursor moves away from the field, hide the hint
				inputs[i].onblur = function () {
					this.parentNode.getElementsByTagName("span")[0].style.display = "none";
				}
			}
		}
	}
	// repeat the same tests as above for textareas
	var textareas = document.getElementsByTagName("textarea");
	for (var i=0; i<textareas.length; i++){
		// test to see if the hint span exists first
		if (textareas[i].parentNode.getElementsByTagName("span")[0]) {
			// the span exists!  on focus, show the hint
			textareas[i].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			// when the cursor moves away from the field, hide the hint
			textareas[i].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
	// repeat the same tests as above for selects
	var selects = document.getElementsByTagName("select");
	for (var k=0; k<selects.length; k++){
		if (selects[k].parentNode.getElementsByTagName("span")[0]) {
			selects[k].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			selects[k].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
}
addLoadEvent(prepareInputsForHints);

 // business type Tooltip
 function showToolTip(e,text){
	if(document.all)e = event;
	
	var obj = document.getElementById('bubble_tooltip');
	var obj2 = document.getElementById('bubble_tooltip_content');
	obj2.innerHTML = text;
	obj.style.display = 'block';
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
	var leftPos = e.clientX - 100;
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos + 'px';
	obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
}	
function hideToolTip()
{
	document.getElementById('bubble_tooltip').style.display = 'none';
	
}
	
