﻿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 showPagingPage(iPageNum)
{
    //alert(iPageNum);
    for(iCount = 1;iCount<=pagedpages;iCount++)
    {
        //alert(document.getElementById("paging_" + iCount).style.display);
        //alert(document.getElementById("paging_" + iCount).style.display + " , " + iCount);
        document.getElementById("paging_" + iCount).style.display = "none";
    }
    
    //alert(document.getElementById("paging_" + iPageNum).style.display = "block");
    document.getElementById("paging_" + iPageNum).style.display = "block";
    
    return false;
    
}

function hideShowObject(objID)
{
    var obj = document.getElementById(objID);
        if(obj.style.display == 'none')
            obj.style.display = 'block';
        else
            obj.style.display = 'none';
}


function openrelatedwindow(strFile, strName)
{
    // opens popup window
    var strProperties = 'toolbar=no,width=550,height=450,left=30,top=150,' + 'status=no,scrollbars=yes,resizable=yes,menubar=no';
    tmpWin = window.open(strFile,strName,strProperties);
    tmpWin.focus();
}


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();

    //window.open("leia-01.html",null,"height=400,width=550,status=yes,toolbar=no,menubar=no,location=no");
    //alert(url+' : '+winName);
    //alert("height="+winHeight+",width="+winWidth+",toolbar="+winToolbars+",scrollbars="+winScroll+",menubar="+winMenubar);
    //window.open("'"+url+"'", "'"+winName+"'", "height="+winHeight+",width="+winWidth+",toolbar="+winToolbars+",scrollbars="+winScroll+",menubar="+winMenubar);
    //window.open(url, winName, "height="+winHeight+", width="+winWidth+",toolbar='"+winToolbars+"',scrollbars='"+winScroll+"',menubar='"+winMenubar+"'");    
}

//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'><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 #####################################################

//Menu functions
function showSources(sel, ddlId)
{
    ddl = document.getElementById(ddlId);
    
    while (ddl.hasChildNodes())
    {
        ddl.removeChild(ddl.childNodes[0]);
    }
    
    if (sel == 0)
    {
        ddl.options[0] = new Option("N/A", "Not Selected");
    }
    else
    {
        if (sel == 1)
        {
           ddl.options[0] = new Option("Please Select.......", "Magazine - Not Selected");
           ddl.options[1] = new Option("Cosmopolitan", "Cosmopolitan");
           ddl.options[2] = new Option("Company", "Company");
           ddl.options[3] = new Option("Elle", "Elle");
           ddl.options[4] = new Option("Glamour", "Glamour");
           ddl.options[5] = new Option("New Woman", "New Woman");
           ddl.options[6] = new Option("Marie Claire", "Marie Claire");
           ddl.options[7] = new Option("Red", "Red");
           ddl.options[8] = new Option("Zest", "Zest");
           ddl.options[9] = new Option("She", "She");
           ddl.options[10] = new Option("Eve", "Eve");
           ddl.options[11] = new Option("Love It", "Love It");
           ddl.options[12] = new Option("Yorkshire Today", "Yorkshire Today");
           ddl.options[13] = new Option("Accent Magazine", "Accent Magazine");
           ddl.options[14] = new Option("Now", "Now");
           ddl.options[15] = new Option("OK!", "OK!");
           ddl.options[16] = new Option("New!", "New!");
           ddl.options[17] = new Option("Reveal", "Reveal");
           ddl.options[18] = new Option("Dare", "Dare");
            ddl.options[19] = new Option("ASOS", "ASOS");
        }
        if (sel == 2)
        {
            ddl.options[0] = new Option("Please Select.......", "Newspaper - Not Selected");
            ddl.options[1] = new Option("News of the World", "News of the World");
            ddl.options[2] = new Option("Sun TV (Sat Sup)", "Sun TV (Sat Sup)");
            ddl.options[3] = new Option("Daily Star", "Daily Star");
            ddl.options[4] = new Option("The Sun", "The Sun");
            ddl.options[5] = new Option("The Daily Mail", "The Daily Mail");
            ddl.options[6] = new Option("Sunday Mirror M Celebs", "Sunday Mirror M Celebs");
        }
        if (sel == 3)
        {
            ddl.options[0] = new Option("Please Select.......", "Online - Not Selected");
            ddl.options[1] = new Option("Google Search", "Google Search");
            ddl.options[2] = new Option("Hotmail Email", "Hotmail Email");
            ddl.options[3] = new Option("Other Search Engine Search", "Other Search Engine Search");
            ddl.options[4] = new Option("MSN Banner", "MSN Banner");
            ddl.options[5] = new Option("Hotmail Banner", "Hotmail Banner");
            ddl.options[6] = new Option("Friends Reunited Bannner", "Friends Reunited Bannner");
            ddl.options[7] = new Option("Private Healthcare Website", "Private Healthcare Website");
            
            ddl.options[8] = new Option("My Free Implants Website", "My Free Implants Website");
            ddl.options[9] = new Option("Other Online Banner", "Other Online Banner");
            ddl.options[10] = new Option("Other Website Link", "Other Website Link");
            ddl.options[11] = new Option("Net Doctor", "Net Doctor");
        }
        if (sel == 4)
        {
            ddl.options[0] = new Option("Please Select.......", "Referral - Not Selected");
            ddl.options[1] = new Option("MYA News Email", "MYA News Email");
            ddl.options[2] = new Option("Late Space Offer Email", "Late Space Offer Email");

        }
        if (sel == 5)
        {
            ddl.options[0] = new Option("Please Select.......", "Referral - Not Selected");
            ddl.options[1] = new Option("MYA Referral Scheme", "MYA Referral Scheme");
            ddl.options[2] = new Option("Friends and Family Referral", "Friends and Family Referral");
            ddl.options[3] = new Option("Other Referral", "Other Referral");
        }
        if (sel == 6)
        {
            ddl.options[0] = new Option("Please Select.......", "Radio - Not Selected");
            ddl.options[1] = new Option("Local Radio", "Local Radio");
            ddl.options[2] = new Option("National Radio", "National Radio");
        }
        if (sel == 7)
        {
            ddl.options[0] = new Option("Please Select.......", "Directory - Not Selected");
            ddl.options[1] = new Option("Thompson Directory", "Thompson Directory");
            ddl.options[2] = new Option("Yellow Pages", "Yellow Pages");
            ddl.options[3] = new Option("Yell.co.uk", "Yell.co.uk");
        }
        if (sel == 8)
        {
            ddl.options[0] = new Option("Please Select.......", "Mail - Not Selected");
            ddl.options[1] = new Option("Mail Order Catalogue", "Mail Order Catalogue");
            ddl.options[2] = new Option("Leaflet Through The Door", "Leaflet Through The Door");
            ddl.options[3] = new Option("Letter Addressed To Me", "Letter Addressed To Me");
        }
        if (sel == 9)
        {
            ddl.options[0] = new Option("Please Select.......", "Leaflet - Not Selected");
            ddl.options[1] = new Option("Mail Order Catalogue", "Mail Order Catalogue");
            ddl.options[2] = new Option("Leaflet Through The Door", "Leaflet Through The Door");
            ddl.options[3] = new Option("Letter Addressed To Me", "Letter Addressed To Me");
            ddl.options[4] = new Option("Leaflet Handed To Me", "Leaflet Handed To Me");
        }
        if (sel == 10)
        {
            ddl.options[0] = new Option("Please Select.......", "Press Story - Not Selected");
            ddl.options[1] = new Option("Daily Telegraph", "Daily Telegraph");
            ddl.options[2] = new Option("Daily Star", "Daily Star");
            ddl.options[3] = new Option("Doncaster Advertiser", "Doncaster Advertiser");
            ddl.options[4] = new Option("Doncaster Star", "Doncaster Star");
            ddl.options[5] = new Option("Yorkshire Evening Post", "Yorkshire Evening Post");
            ddl.options[6] = new Option("Yorkshire Post", "Yorkshire Post");
            ddl.options[7] = new Option("Yorkshire Today", "Yorkshire Today");
        }
        if (sel == 11)
        {
            ddl.options[0] = new Option("Please Select.......", "Poster - Not Selected");
            ddl.options[1] = new Option("Bathroom Poster", "Bathroom Poster");
            ddl.options[2] = new Option("Outdoor Poster", "Outdoor Poster");
            ddl.options[3] = new Option("Bus Shelter", "Bus Shelter");
        }
        if (sel == 12)
        {
            ddl.options[0] = new Option("Please Select.......", "Shopping Centre - Not Selected");
            ddl.options[1] = new Option("Leaflet Handed To Me", "Leaflet Handed To Me");
        }
        if (sel == 13)
        {
            ddl.options[0] = new Option("Please Select.......", "Other - Not Selected");
            ddl.options[1] = new Option("Voucher For Me", "Voucher For Me");
            ddl.options[2] = new Option("Clinic Open Evening", "Clinic Open Evening");
        }
    }
}

