﻿/////////////////////////////////////////////////////////////////////////////////
///////////////////          License Request            /////////////////////////
/////////////////////////////////////////////////////////////////////////////////
function LicenseRequest()
{
    window.showModelessDialog("/licreq.aspx", null, "dialogWidth:400px;dialogHeight:470px;");
}

function TellAFriend(productName)
{
    window.showModelessDialog("/tellfriend.aspx", productName, "dialogWidth:400px;dialogHeight:260px;");
}
/////////////////////////////////////////////////////////////////////////////////
///////////////////          Screen Shots               /////////////////////////
/////////////////////////////////////////////////////////////////////////////////
var zoomPopup = null;
function ZoomPicture(o)
{
    if (!zoomPopup)
    {
        zoomPopup = window.createPopup();
        zoomPopup.document.body.style.cursor = "hand";
        zoomPopup.document.body.style.backgroundColor = "#f8f8ff";
        zoomPopup.document.body.style.border = "1px solid #b3b3b3";
        zoomPopup.document.body.onclick = function () {zoomPopup.hide();}
    }
    
    var html = '<table border="0" cellpadding="10" cellspacing="0" style="height: 100%; width: 100%"><tr><td align="center" valign="middle">';
        html += '<div style="width: 760px; height: 530px; overflow: hidden;"><img alt="Click to close" src="' + o.src + '" /></div>';
        html += '</td></tr></table>';
        
    zoomPopup.document.body.innerHTML = html;
    zoomPopup.show(0, 0, 780, 550, document.getElementById("tdContent"));
    
    //zoomPopup.
}

/////////////////////////////////////////////////////////////////////////////////
///////////////////          News Letter                /////////////////////////
/////////////////////////////////////////////////////////////////////////////////
    var emailRegxp = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;
    function NewsLetter()
    {
        var email = document.getElementById("email").value;
        
        //test email
        if (emailRegxp.test(email) != true)
        {
            alert("Email address is incorrect");
            document.getElementById("email").value = "";
            return;
        }
        if(email)
        {
            var xmlDoc = getXMLDocument();
            xmlDoc.async="false";
            xmlDoc.loadXML('<Request></Request>');
            xmlDoc = AppendElement("email", email, xmlDoc);
            
            sendRequest("http://www.CastorSoft.com/Service/XHttpRequests.aspx?Type=1",xmlDoc,"POST",NewsLetterResult);
        }
        else
            alert("Please Enter Valid Email!");
    }
    function NewsLetterResult()
    {
        var ready=req.readyState;
        var data=null;
        if (ready==READY_STATE_COMPLETE){
            data=req.responseText;
            alert(data.substring(0,10));
            document.getElementById("email").value = "";
        }
    }
    
    var req=null;
    var READY_STATE_UNINITIALIZED=0;
    var READY_STATE_LOADING=1;
    var READY_STATE_LOADED=2;
    var READY_STATE_INTERACTIVE=3;
    var READY_STATE_COMPLETE=4;

    function sendRequest(url,params,HttpMethod,callBack){
        if (!HttpMethod){
            HttpMethod="GET";
        }
        req=initXMLHTTPRequest();
        if (req){
            req.onreadystatechange=callBack;
            req.open(HttpMethod,url,true);
            req.setRequestHeader
            ("Content-Type", "application/x-www-form-urlencoded");
            req.send(params);
        }
    }
    function initXMLHTTPRequest(){
        var xRequest=null;
        if (window.XMLHttpRequest){
            xRequest=new XMLHttpRequest();
        } else if (window.ActiveXObject){
                xRequest=new ActiveXObject("Microsoft.XMLHTTP");
                }
        return xRequest;
    }
    function getXMLDocument()
    {
        var xDoc=null;
        if (document.implementation && document.implementation.createDocument)
        {
            xDoc = document.implementation.createDocument("","",null);
        }
        else 
        {
            if (typeof ActiveXObject != "undefined")
            {
                var msXmlAx = null;
                try{
                    msXmlAx = new ActiveXObject("Msxml2.DOMDocument");
                }catch (e)
                {
                    msXmlAx = new ActiveXObject("Msxml.DOMDocument");
                }
                xDoc = msXmlAx;
            }
        }
        if (xDoc == null || typeof xDoc.load == "undefined")
        {
            xDoc = null;
        }
        return xDoc;
    }
    function AppendElement(title, val, xmlDoc)
    {
        if(val)
        {
            var node = xmlDoc.createElement(title);
            node.text = val;
            xmlDoc.documentElement.appendChild(node);
        }
        return xmlDoc;
    }
