﻿// JScript File

function CheckDiscountCode()
{
    var DiscountCode = document.getElementById('txtDiscountCode').value;
    xmlHttp.open("GET","Process.aspx?DiscountCode="+DiscountCode,true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange = function func()
    {
        if(xmlHttp.readyState==4 && xmlHttp.status ==200)
        {
            var response =  xmlHttp.responseText;
            var index1,index2;
            index1 = response.indexOf('<result>');
            index2 = response.indexOf('</result>');
            if(index1 != -1 && index2 != -1)
            {
                var Result = response.substring(index1+8,index2);    
                if(Result==-1)
                {                    
                    alert("Invalid Discount Code..!!");
                }                
                else
                {
                    document.getElementsByName('hosted_button_id')[0].value = Result;
	        document.getElementById('spnRate').innerHTML = 'at $25';
                    alert("Discount Code successfully applied. \nPlease go ahead and order your custom Ambigram..!!");                    
                }
            }
        }
    }
}
var xmlHttp;
ajaxFunction();
function ajaxFunction()
{
    try
    {        
        var IEver = getIEVersionNumber();  
        if(IEver>6)
        {
            xmlHttp=new XMLHttpRequest();
        }
        else
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");            
        }
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            //xmlHttp=new XMLHttpRequest();
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlHttp=new XMLHttpRequest();
            }
            catch (e)
            {
                try
                {
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (e)
                {
                    alert("Your browser does not support AJAX! You will not be able to use the Discount code if you have any..!!");
                    return false;
                }
            }
        }
    }
}
function HighlightMail()
{
    var mail = document.getElementById('imgMail');
    mail.src = "Images/imgContactHighLight.jpg";
    
}
function NormalMail()
{
    var mail = document.getElementById('imgMail');
    mail.src = "Images/imgContact.jpg";
}



var imgTest;
function SwapImages()
{
    imgTest = document.getElementById('imgTest');
    var tableTest = document.getElementById('tableTest');
    var imgSrc = tableTest.style.backgroundImage;
    tableTest.style.backgroundImage = 'url('+imgTest.src+')';

    if (window.sidebar)
    {
        imgTest.style.MozOpacity="0%";
        imgTest.src = imgSrc.replace('url(','').replace(')','');
        for(i=0;i<=100;i+=1)
        {
            setTimeout("SetOpacityMoz("+ i +")",i*15)
        }
    }
    else
    {
        imgTest = document.getElementById('imgTest');
        imgTest.filters[0].opacity=0;
        imgTest.src = imgSrc.replace('url(','').replace(')','');
        for(i=0;i<=100;i+=1)
        {
            setTimeout("SetOpacityIE("+ i +")",i*15)
        }
    }

}
function SetOpacityMoz(opac)
{
    imgTest.style.MozOpacity= opac + "%";
}
function SetOpacityIE(opac)
{
    imgTest.filters[0].opacity=opac;    
}
setInterval("SwapImages()",10000);