﻿var http = createRequestObject();
function createRequestObject() {
    // find the correct xmlHTTP, works with IE, FF and Opera
    var xmlhttp;
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) {
            xmlhttp = null;
        }
    }
    if (!xmlhttp && typeof XMLHttpRequest != "undefined") {
        xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp;

}
function SetHTTP_Header(params) {
   
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");
}
function getFrom_dealerPage() {
    alert('l');
    var params = 'action=display';
    http.open('get', 'dealer.aspx?' + params, true);
    http.onreadystatechange = Handle_dealer;
    http.send(null);
}
function Handle_dealer() {
    if (http.readyState == 4) {
        var response = http.responseText;
        if (response.indexOf('<!--dealer_page_starts_here-->') != -1) {
            var arr = new Array();
            arr = response.split('<!--dealer_page_starts_here-->');
            arr = arr[1].split('<!--dealer_page_ends_here-->');
            document.getElementById('').innerHTML = arr[0];
        }
    }
}


function minimizeFlash() {


    document.getElementById('div_maincontent').style.display = "block";
    document.getElementById('div_flash').innerHTML = "";
    document.getElementById('div_flash').style.display = "none";
    var str = document.getElementById('hiden_flash').value;
   // document.getElementById('div_out_' + str).style.display = "block";
    window.document.body.style.backgroundColor = "White";
    //document.getElementById('div_Master_main_wrapper').style.opacity = "1";
    //document.getElementById('div_Master_main_wrapper').style.filter = "alpha(opacity=100)";


}
function getTextFromFlash(str, toOpen) {

  
    flash_file = toOpen;
    var width = "1180";
    var height = "908";
    var sc_wd = screen.width;
    var sc_ht = screen.height;
    var perc_wd = "0%";
    var perc_ht = "0%";

    if (sc_wd < 1600) {

        var newWd = 0;
        if (sc_wd < 1180) {

            newWd = 1180 - sc_wd;
            width = screen.width - 10;
        }
        else {
            newWd = sc_wd - 1180;

        }
        var per_w_int = parseInt(newWd * .024);
        perc_wd = per_w_int + "%";
        
        document.getElementById('div_flash').style.left = perc_wd;
        
    }

    if (sc_ht < 1200) {

        var newHt = 0;
        if (sc_ht < 908) {
            newHt = 908 - sc_ht;
            height = screen.height - 10;
        }
        else {
            newHt = sc_ht - 908
        }
        var per_h_int = parseInt(newHt * .055);
        perc_ht = per_h_int + "%";
       
        document.getElementById('div_flash').style.left = perc_ht;
    }
//    filename=flash_file;
//    alert(filename);
// alert(document.getElementById('div_flash_'+filename ));
// alert(document.getElementById('div_out_'+filename ));
// alert(document.getElementById('jud_'+filename ));

// document.getElementById('div_flash_'+filename ).style.display = "block";
// document.getElementById('div_out_'+filename ).style.width = width;
// document.getElementById('div_out_'+filename ).style.height = height;
// document.getElementById('jud_'+filename ).style.width = width;
// document.getElementById('jud_'+filename ).style.height = height;







    var filename = str;
var strs="";
 width = "1032";
    height = "827";
if(filename.indexOf('thumb_')!=-1)
{

var oldfilename=filename;
filename=filename.replace("thumb_","");

strs="<div id=\"currentflash\" style=\"width:700px;float:left;text-align:center;pading:0;margin:0;\"><a style=\"text-decoration:none;border-width:0px;\" href=\"javascript:minimizeFlash()\"><img  src=\"flash/closeflash.jpg\" style=\"border-width:0px;border:2px solid lime;\"/></a></div>";
 strs+="<div id=\"div_back\" style=\"width:"+width+"px;height:"+height+"px;background-image: url('http://www.judahsoftware.com/flash/screenshot_"+filename+".gif');background-color:Transparent;\">"; 
strs+="<div id=\"middle_flash\">";
strs +="<div id=\"inner_flash\"><a  style=\"text-decoration:none;border-width:0px;cursor:pointer\"  href=\"javascript:getTextFromFlash('"+filename+"','"+filename+"')\" /><img style=\"border-width:0px;\" src=\"http://www.judahsoftware.com/Images/Home/playbutton.png\"/></a>";
strs +="</div></div></div>";


}
else{
    //flash_file = "http://judahsoftware.net/editing/" + flash_file;
     flash_file = "flash/" + flash_file;
   
    document.getElementById('div_maincontent').style.display = "none";
   
    strs="<div id=\"currentflash\" style=\"width:700px;float:left;text-align:center;pading:0;margin:0;\"><a style=\"text-decoration:none;border-width:0px;\" href=\"javascript:minimizeFlash()\"><img  src=\"flash/closeflash.jpg\" style=\"border-width:0px;border:2px solid lime;\"/></a></div>";
    strs += "<object style=\"float:left;text-align:left;paddin:0;margin:0;border:5px solid #A2BDDF;\" id=\"jud_" + filename + "\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"" + width + "\" height=\"" + height + "\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version==8\">";
    strs += "<param name=\"src\" value=\"" + flash_file + "_controller.swf#\"/>";
    strs += "<param name=\"bgcolor\" value=\"FFFFFF\"/>";
    strs += "<param name=\"quality\" value=\"best\"/>";
    strs += "<param name=\"allowScriptAccess\" value=\"always\"/>";
    strs += "<param name=\"flashVars\" value=\"csConfigFile=" + flash_file + "_config.xml&csColor=FFFFFF\"/>";
    strs += "<embed name=\"jud_" + filename + "\" src=\"" + flash_file + "_controller.swf\" width=\"" + width + "\" height=\"" + height + "\" bgcolor=\"FFFFFF\" flashVars=\"csConfigFile="+flash_file+"_config.xml&csColor=FFFFFF\" quality=\"best\" allowScriptAccess=\"always\" pluginspage=\"http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></embed>";
    strs += "</object>";

 
    }
  
    var widthofscreen=screen.width;
    var widthofelement=1032;
    var widthoccupied=parseInt(widthofscreen)-parseInt(widthofelement);
    var marginLR=parseInt(widthoccupied)/2;
   
    var heightofscreen=screen.height;
    var heightofelement=827;
    var heightoccupied=parseInt(heightofscreen)-parseInt(heightofelement);
    var margintop=parseInt(heightoccupied)/2;

   margintop=56; 
  
  
    document.getElementById('div_flash').style.top=margintop;
    document.getElementById('div_maincontent').style.display = "none";
    document.getElementById('div_flash').style.display = "block";
    document.getElementById('div_flash').innerHTML = strs;
    document.getElementById('div_flash').style.left=marginLR+"px";
    document.getElementById('div_flash').style.right=marginLR+"px";
    document.getElementById('hiden_flash').value = str;
   


}

function getFlashMovie(movieName)
{ var isIE = navigator.appName.indexOf("Microsoft") != -1;return (isIE) ? window[movieName] : document[movieName]; }


function formSend(moviename) {

   
    document.getElementById('flashmovieX').sendTextToFlash();
}

function insertintoflash(moviename) {
  
//    var params = 'count='+document.getElementById('hiden_Flashcount').value;
//    http.open('post', 'flashfunction.aspx?' + params);
//    http.onreadystatechange = GetFlashText;
//    SetHTTP_Header(params);
//    http.send(params);
//    return document.getElementById('hiden_flashtext').value;

}

function GetFlashText() 
{
    if (http.readyState == 4) 
    {
        var response = http.responseText;
        if (response.indexOf('flashText:') != -1) 
        {
            var arr = new Array();
            arr = response.split('flashText:');
            arr = arr[1].split(':flashText');
            document.getElementById('hiden_flashtext').value = arr[0];
            themessage = arr[0];
            arr = new Array();
            arr = response.split('flashCount:');
            arr = arr[1].split(':flashCount');

            document.getElementById('hiden_Flashcount').value = arr[0];

            position_at_top(); expand();
            
           
        }
    }
}

function insertintoflash_dup(ss) {
    alert(ss);
}


function textEffectHTML() {

try{
    fontsize = 1;
    var params = 'count=' + document.getElementById('hiden_Flashcount').value;
    http.open('post', 'flashfunction.aspx?' + params);
    http.onreadystatechange = GetFlashText;
    SetHTTP_Header(params);
    http.send(params);
    }
    catch(ifnotflashpage)
    {
    }
    
}

    
   var themessage="Welcome to Dynamic Drive!"
var fontsize=1
//Below determines how long the message will appear before disappearing. 3000=3 seconds
var appearfor = 12000;

function position_at_top()
{

    if (document.layers) {
        
        document.test.top = pageYOffset
    }
    else if (document.all) {

    test.innerHTML = '<div style="float:left;text-align:left;">' + themessage + '</div>'
        setTimeout("test.style.top=document.body.scrollTop+10;test.style.left=document.body.scrollLeft+10", 100)
    }
    else if (document.getElementById) {

    document.getElementById("test").innerHTML = '<div style="float:left;text-align:left;">' + themessage + '</div>'

        document.getElementById("test").style.top = pageYOffset
    }
}

function expand()
{

        if (document.layers)
        {
            document.test.document.write('<div  style="float:left;text-align:left;font-size:' + fontsize + 'px">' + themessage + '</div>')
            document.test.document.close();
        }
    else if (document.all)
    test.style.fontSize=fontsize+'px'
    else if (document.getElementById)
    document.getElementById("test").style.fontSize=fontsize+'px'
    fontsize+=2
    if (fontsize > 14)
    {
        if (document.layers)
            setTimeout("textEffectHTML();", appearfor)
        else if (document.all)
            setTimeout("textEffectHTML();", appearfor)
        else if (document.getElementById) {
        
            setTimeout("textEffectHTML();", appearfor)
        }
        return
    }
    else
     setTimeout("expand()",50)
    
}






// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("-")!=-1)bracket=bracket+1
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
var brchr=strPhone.indexOf("(")
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function ValidateForm(phonenumber){
	var Phone=document.getElementById(phonenumber);
	
	if ((Phone.value==null)||(Phone.value=="")){
		//alert("Please Enter your Phone Number")
		//Phone.focus()
		return true
	}
	if (checkInternationalPhone(Phone.value)==false){
		alert("Please Enter a Valid Phone Number")
		Phone.value=""
		Phone.focus()
		return false
	}
	return true
 }




function checkemail(email)
{

 var str=document.getElementById(email).value;
 if(str=="")
 {
  result=true
 }
 else
 {
     var filter=/^.+@.+\..{2,3}$/;
     
     if (filter.test(str))
        result=true
     else {
        alert("Please input a valid email address!")
        result=false
        }
 }
    return result;
    
}


function checkall(email)
{

return checkemail(email)
//if (document.layers||document.all)
//return checkemail(email)
//else
//return true
}
function openformwindow(from)
{

  document.getElementById('div_downloadButton').style.display="block";
          var formdiv=document.getElementById('div_downloadButton');
             formdiv.style.display="block";
             formdiv.style.position="absolute";
             var width  = 200;
             var height = 50;
             var middle_screenwidth=document.getElementById('master_center').clientWidth;
             var middle_screenheight=document.getElementById('master_center').clientHeight;
             var left=(parseInt(middle_screenwidth)-width)/2;
             var top=(parseInt(middle_screenheight)-height)/2;
             formdiv.style.top=top+"px";
             formdiv.style.left=left+"px";
             formdiv.focus();
}
var currentdownload="";
function submit_download_form(email,phone)
{

var downloadfrom=document.getElementById('hiden_down').value;

currentdownload=downloadfrom;

//var valEmail=checkall(email);
//var valphone=ValidateForm(phone);
//if(valEmail==true && valphone==true)
//{
   // var params = 'download=' +downloadfrom+'&email='+document.getElementById(email).value+'&phone='+document.getElementById(phone).value;
    var params = 'download=' +downloadfrom;
    http.open('post', 'downloadform.aspx?' + params);
    http.onreadystatechange = Handle_downloadForm;
    SetHTTP_Header(params);
    http.send(params);
   // }
    
}

function Handle_downloadForm()
{ if (http.readyState == 4) 
    {
        var response = http.responseText;
       
        
      
        //var array_download=new Array();
//        array_download=response.split('server_path:');
//        array_download=array_download[1].split(':server_path');
//        location.href="http://judahsoftware.com/judah/"+array_download[0];
        
//        var array_download=new Array();
//        array_download=response.split('<!--downloadform_starts_here-->');
//        array_download=array_download[1].split('<!--downloadform_ends_here-->');
//        document.getElementById('div_form').innerHTML= array_download[0];
//        if(response.indexOf('Your Email Has been Saved in Our Account')!=-1)
//        {
//        document.getElementById('hiden_submited').value='true';
//        
//        document.getElementById('div_form').style.display="none";
//        if(currentdownload.toLowerCase()=="client")
//        {
//         location.href="http://judahsoftware.com/judah/clientsetup.exe";
//          //window.open("http://judahsoftware.com/judah/clientsetup.exe");
//          }
//          else
//          {
          document.getElementById('div_downloadButton').style.display="block";
          var formdiv=document.getElementById('div_downloadButton');
             formdiv.style.display="block";
             formdiv.style.position="absolute";
             var width  = 200;
             var height = 50;
             var middle_screenwidth=document.getElementById('master_center').clientWidth;
             var middle_screenheight=document.getElementById('master_center').clientHeight;
             var left=(parseInt(middle_screenwidth)-width)/2;
             var top=(parseInt(middle_screenheight)-height)/2;
             formdiv.style.top=top+"px";
             formdiv.style.left=left+"px";
             formdiv.focus();
//          
//          }
//        }
       
    }
}


//function SysFolder(){
//var w;
//w = new ActiveXObject("Shell.Application");
//// Change Number for different folders
//w.Open(32);
//}

function clickplusBox(dv,bx)
    {
   
        if(document.getElementById(dv).style.display=="none")
        {
          document.getElementById(dv).style.display="block";
          document.getElementById(bx).innerHTML="<img alt=\"\" src=\"Images/Home/newhome/minus.png\" style=\"border:0;\" />";
        }
        else
        {
          document.getElementById(dv).style.display="none";
          document.getElementById(bx).innerHTML="<img alt=\"\" src=\"Images/Home/newhome/plus.png\" style=\"border:0;\" />";
        }
  heightAdjust();
    }
    function subscribe() 
{

    var email = document.getElementById('txt_subscribe').value;
    var params = 'action=display&email=' + email;
    http.open('post', 'subscribe.aspx?' + params, true);
  http.onreadystatechange = Handle_subscribe;
 SetHTTP_Header(params);
  http.send(params);
}
function Handle_subscribe() 
{
    if (http.readyState == 4) {
        var response = http.responseText;
     
        if (response.indexOf('ERROR') != -1) {
            alert('Email Id should be in acceptable format');
        }
        else {
            if (response.indexOf('Already Exist') != -1) 
            {
                alert('We have a subscription with the same Email Id');
            }
            else 
            {
            document.getElementById('txt_subscribe').value="";
                alert('Your Email Id Has been Saved');
            }
        }
    }
}
