﻿
    /* 
    so finally you reach here...  
    
    rather then making 2-3 people sit to understand and develop this of javascript, 
    we suggest you to buy it from us with source code.
    it will be cost effective for you. call us on +91 93229 45245 or mail us info@iginisolutions.com
    
    dont waste you time in understanding it
    
    Thanks, Regards & All the best
    On behalf of iGini Team    
    */
    
    // JScript File

    var StrCallerClientId, StrNumber;

    //create control    
    function iGiniDialerCreateControl(ClientId)
    {
        StrCallerClientId = ClientId;
        
        var CookieValue = iGiniDialerReadCookie('Show');
        //alert('cookievalue : ' + CookieValue)
        if (CookieValue != 'N')
        {
        var newdiv = document.createElement('div');
        newdiv.setAttribute('id', 'iGiniControlCointainer');
        newdiv.setAttribute('align', 'right');
        newdiv.style.width = 200 + "px";
        newdiv.style.height = 130 + "px";
        newdiv.style.position = "absolute";
        newdiv.style.left = 0 + "px";
        newdiv.style.top = -141  + "px";
        //newdiv.style.top = 0;
        //newdiv.style.padding = 2  + "px";
        //newdiv.style.background = "#E99";        
        newdiv.style.background = "url(http://www.iginisolutions.com/DialAdmin/images/Img2a.jpg)";        
        newdiv.style.border = "2px solid #333";
        
        //newdiv.innerHTML = "<div align='Right' onclick=\"iGiniDialerCreateCookie('Show','N',1,1);\"> x </div>";
        
        newdiv.innerHTML = "<div style='height: 20px; width:15px; padding-bottom:15px;'><a href='#' onclick='iGiniDialerClosePopup();' style='background-color: #BD0000;color: #FFFFFF;font-size: 11px; padding: 3px;'>X</a></div>"
        //newdiv.innerHTML = "<div style='cursor:hand;' align='Right' onclick='iGiniDialerClosePopup();'>&nbsp; X &nbsp;</div>";        
        //newdiv.innerHTML = newdiv.innerHTML + "Give us your number if you want us to call you <br><br> &nbsp;";
        
        //Create an input type dynamically.
        var element = document.createElement("input");
        
        //Assign different attributes to the element.
        element.setAttribute("type", "text");
        element.setAttribute("name", "TxtIginiSumbitInqMyNumber");
        element.setAttribute("id", "TxtIginiSumbitInqMyNumber");
        element.setAttribute("style", "font-family: Arial, Helvetica, sans-serif; background-color: #DBDCD3; border: 1px solid #BCBDB7; height: 20px; width: 110px; color: #555555; text-decoration: none; font-size: 11px; margin-left:70px;");//"width:80px");
        newdiv.appendChild(element);
        
        newdiv.innerHTML = newdiv.innerHTML + "&nbsp;&nbsp;"
        var element2 = document.createElement("input");
        element2.setAttribute("type", "button");
        element2.setAttribute("value", "submit");
        element2.setAttribute("id", "BtnIginiSumbitInqMyNumber");
        element2.setAttribute("name", "BtnIginiSumbitInqMyNumber");
        element2.setAttribute("style", "font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #FFFFFF; text-decoration: none; background-color: #BD0000; border: none; padding: 3px; margin-left:70px; margin-top:10px;");//"width:40px");
        element2.setAttribute("onclick", "iGiniDialerSubmitInq();");
        newdiv.appendChild(element2);
        
        document.body.appendChild(newdiv);
        
        window.setTimeout('iGiniDialerSlideMe1(' + i + ');', 5000);
        }       
    }
    
    function iGiniDialerClosePopup()
    {
        document.getElementById("iGiniControlCointainer").style.display="none";
        iGiniDialerCreateCookie('Show','N',1,1);        
    }
    
    function iGiniDialerSubmitInq()
    {   
        StrNumber = document.getElementById("TxtIginiSumbitInqMyNumber").value;
        
        //call webservice to send email/sms by passing website owner id & number
        document.getElementById("TxtIginiSumbitInqMyNumber").style.display="none";
        document.getElementById("BtnIginiSumbitInqMyNumber").style.display="none";
        document.getElementById("iGiniControlCointainer").style.background = "url(http://www.iginisolutions.com/DialAdmin/images/Img2b.jpg)"
        //document.getElementById("iGiniControlCointainer").innerHTML = "<div align='center'><br><br>Thank you <br><br> our executive will contact you soon</div>"
        
        //calls SlideMeBack1 to slide back the control
        window.setTimeout('iGiniDialerSlideMeBack1(0);', 3000);                
                
        iGiniDialerServerCall();
    }   
    
            
    //Playing with cookie    
    function iGiniDialerCreateCookie(name,value,days,mints) {
        //alert (name +', '  +  value +', '  + days + ', '  + mints);
        if (days) {
	        var date = new Date();
	        date.setTime(date.getTime()+(days*24*60*mints*1000));
	        var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";	        
        //document.cookie = name+"="+value+expires+"; path=/";        
    }

    function iGiniDialerReadCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
	        var c = ca[i];
	        while (c.charAt(0)==' ') c = c.substring(1,c.length);
	        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return null;
    }

    function iGiniDialerEraseCookie(name) {
        iGiniDialerCreateCookie(name,"",-1);
    }


    
    //code for sliding
    var i=-140;
    function iGiniDialerSlideMe1(i)
    {   
        //alert(i);
        document.getElementById("iGiniControlCointainer").style.top=(i) + "px";
        //document.getElementById("iGiniControlCointainer").setAttribute(top,(i*6));
        i=i+1;
        if (i<1)
            window.setTimeout('iGiniDialerSlideMe2(' + i + ');', 5);
    }     
    function iGiniDialerSlideMe2(i)
    {   
        document.getElementById("iGiniControlCointainer").style.top=(i) + "px";
        //document.getElementById("iGiniControlCointainer").setAttribute(top,(i*6));
        i=i+1;
        if (i<1) 
            window.setTimeout('iGiniDialerSlideMe1(' + i + ');', 5)          
    }    
    function iGiniDialerSlideMeBack1(i)
    {           
        document.getElementById("iGiniControlCointainer").style.top=(i*1) + "px";
        i=i-1;
        if (i>-141)        
            window.setTimeout('iGiniDialerSlideMeBack2(' + i + ');', 5);       
    }     
    function iGiniDialerSlideMeBack2(i)
    {        
        document.getElementById("iGiniControlCointainer").style.top=(i*1) + "px";
        i=i-1;
        if (i>-141) 
            window.setTimeout('iGiniDialerSlideMeBack1(' + i + ');', 5)          
    }    
    
    
    //Ajax call
    var xmlHttpPersonalInfo;
    function iGiniDialerServerCall(){xmlHttpPersonalInfo=iGiniDialerCallCompleteGetXmlHttpObject();if (xmlHttpPersonalInfo==null){alert ("Your browser does not support AJAX!");return;}var url="iGiniDialCaller.asp?ClientId="+StrCallerClientId+"&Number="+StrNumber;xmlHttpPersonalInfo.onreadystatechange=iGiniDialerCallComplete;xmlHttpPersonalInfo.open("GET",url,true);xmlHttpPersonalInfo.send(null);}
    function iGiniDialerCallComplete(){if (xmlHttpPersonalInfo.readyState==4){}}        
    var xmlHttp;
    function iGiniDialerCallCompleteGetXmlHttpObject(){try{xmlHttp=new XMLHttpRequest();}catch (e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}return xmlHttp;}
