﻿function openwindow(url,winName,winHeight, winWidth, winToolbars, winScroll, winMenubar)
{
    var strProperties = 'toolbar=no,width=' + Math.round(winWidth) + ',height=' + Math.round(winHeight) + ',left=30,top=150,' + 'status=no,scrollbars=yes,resizable=yes,menubar=no';
    tmpWin = window.open(url,winName,strProperties);
    tmpWin.focus();
}

function setcontrolValue(objId,Value)
{
    document.getElementById(objId).value = Value;
}


function toggleDiv(objID)
{
    var obj = document.getElementById(objID);
        if(obj.style.display == 'none')
            obj.style.display = 'block';
        else
            obj.style.display = 'none';
}


    function doClick(buttonName,e)
    {
        //the purpose of this function is to allow the enter key to 
        //point to the correct button to click.
        var key;

         if(window.event)
              key = window.event.keyCode;     //IE
         else
              key = e.which;     //firefox
    
        if (key == 13)
        {
            //Get the button the user wants to have clicked
            var btn = document.getElementById(buttonName);
            if (btn != null)
            { //If we find the button click it
                btn.click();
                event.keyCode = 0
            }
        }
   }


function hideObj(objID)
{
	document.getElementById(objID).style.display="none";
}
function showObj(objID)
{
	document.getElementById(objID).style.display="block";
}


function showpleasespecify(obj)
{
    if(obj.options[obj.selectedIndex].value == "Other (please specify)")
    {
        showObj('txtotherspecified');
    }
    else
    {
        hideObj('txtotherspecified');
        setcontrolValue('txtotherspecified','');
        
    }
    //alert(obj.options[obj.selectedIndex].value);
}


//SIMPLE AJAX FUNCTIONS #####################################################

var req;
var el;
function loadXMLDoc(url,e) {
	req = false;
	el = e;

    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest && !(window.ActiveXObject)) {

    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {

       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
        
	if(req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send("");
	}
}

function processReqChange() {
//alert(req.readyState);
    // only if req shows "loaded"
    if (req.readyState == 1)
	{
		//document.getElementById(el).innerHTML="<img src='http://www.destinationvenus.co.uk/admin/images/lightboximages/loading.gif'>"
		document.getElementById(el).innerHTML="<img src='/images/loading.gif' alt=''><br />Loading..."
		//You could put a Image here if you wanted
	}
	if (req.readyState == 4)
	{
        // only if "OK"
		document.getElementById(el).innerHTML=req.responseText
        if (req.status == 200) {
            // ...processing statements go here...
        } else {
            document.getElementById(el).innerHTML= "There was a problem retrieving the XML data:\n" + req.statusText;
        }
    }

}

function setSearchbox(textBoxVal,myId)
{
    document.getElementById('txtask').value = textBoxVal;
    document.getElementById('txtqid').value = myId;
    document.getElementById('search_suggest').innerHTML = '';
}

function showmoreinfosearch(url,divId,searchInputId,catId)
{
	//alert(divId);
	//getMouseXY();
	//document.getElementById('test1').style.top=tempY-50;
	//document.getElementById('test1').style.left=tempX+20;
	//document.getElementById('test1').style.display="block";
    document.getElementById('txtqid').value = '0';
	
	if(searchInputId != '')
	{
	    searchCriteria = document.getElementById(searchInputId).value;
	}
	url += '?cat='+catId+'&sc='+searchCriteria;
    //alert(url);
    eval("loadXMLDoc('"+url+"','"+divId+"')");
}

function showmoreinfo(url,divId)
{	
	eval("loadXMLDoc('"+url+"','"+divId+"')");
}


function hidemoreinfo(divId)
{
	document.getElementById(divId).style.display="none";
}
//SIMPLA AJAX FUNCTIONS #####################################################

function doSiteSearch(target)
{
	var searchField = document.getElementById("searchfor");
	
	if (searchField.value == "" || searchField.value == "Enter your search")
	{
			alert("Please enter a search term!");
	}
	else
	{
		location.href = target + "?searchfor=" +escape(searchField.value);
	}
}
