//<!--
$(document).ready(function() {
		$(function(){
            $('input').keydown(function(e){
                if (e.keyCode == 13) {
                    xProcessLogin();
                    return false;
                }
            });
        });
	var $mykidImgDlg = $("#main_kids").dialog
	({		
	  		autoOpen: false,
	  		modal: true,
			width: 930,
			height:715,
			title: 'My Kids! Our Inspiration for ChildConnect',
	  		resizable: false
	});

	$("#cc_agreement_radio1").attr('checked', false);
	$("#cc_agreement_continue").attr('disabled', true);
	$("#cc_agreement_continue").css('cursor', 'text');

	
	$("#cc04_d01_d01_d02_io1").click(function(){
		 $mykidImgDlg.dialog('open');
	});
	
	
	$(".cc_innediv_c01").click(function(){
		if($("#cc_agreement_radio1").is(":checkbox:checked")) {
			
			$("#cc_agreement_continue").attr('disabled', false);
			$("#cc_agreement_continue").css('cursor', 'pointer');
			$("#cc_agreement_continue").show();
		}
		else
		{
			$("#cc_agreement_continue").attr('disabled', true);
			$("#cc_agreement_continue").css('cursor', 'text');

		}
		
	});
	$("#cc_agreement_cancel").click(function(){
		
		$.ajax({  
	         type     : "POST",  
	         url      : "/cairs/saveagreement/format/json",  
	         data     : {},
	         datatype : "json",
	         success  : function(data){   		
							window.location.href = data.returnCode.redirect;    						
					    }
	});  
	
	});	
	// Lalith -- Start -- Added XMLHttpRequest -- 05-05-2010
	$.ajaxSetup({
        'xhr':function(){return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();}});
	// Lalith -- End -- 05-05-2010
	
	$("form#ccloginform").bind('submit',function() { xProcessLogin(); return false; });      
	$("#ccloginform_username").focus();	
    // login script
    function xProcessLogin() {  $("#loginerrmsg").html('');
    	//Validate the form, continue processing only if the validation is successful.           
    	if (!($("form#ccloginform").validationEngine({returnIsValid:true}))){
    		return;
    	};
    	if(jQuery('#login_badge').val())
    		url = "login/format/json";
    	else
    		url = $('#login_host').val()+"/auth/login/format/json";
        //r   = true;
        //prereqflag = checkPrereq();
        //prereqflag = 1;
        //if (prereqflag)
        //{
        $.ajax({
                 type     : "POST",
                 url      : url,
                 data     : $("form#ccloginform").serialize(),
                 datatype : "json",
                 success: function(data){
                            if (data.login.isSuccess == 'true'){
                                // Lalith - 01-June-2010 - Start - Modified code to show license agreement form upon login
                                 //window.location.href = 'auth/lagr';
                                // Lalith - 01-June-2010 - End
                                //$.getScript("/scripts/cpdb01.js");
                                if(jQuery('#login_badge').val())
                                    window.open(data.login.result,'mywindow');
                                else
                                    window.location.href = data.login.result;

                            }
                            else {
                                $("#loginerrmsg").html(data.login.result);
                            }
                          }
        });
        //}
      //else
      //{
      //  window.location.href="/index/hphome";
      //}
    };  

   
    /*Submitting dialog box*/ 
    var $submitting = $('#cc_fpwmsgsndg')
    	.dialog({
    		autoOpen: false,
    		title: 'Sending',
    		modal: true,
    		width:300,
    		height:90,
    		resizable: false,
    		open: function(event, ui) {$(".ui-dialog-titlebar-close").hide();},
    		close: function (event, ui){$(".ui-dialog-titlebar-close").show();} 
       	});
        
    $('#cc_fpwform_submit').click(function() {
    	var v=$("#cc_fpwform_email").val();
    	//alert("kkkkkkkkk".v);
    	if(v)
    	{
            if (!($("form#cc_fpwform").validationEngine({returnIsValid:true}))){

                    return;

            };
            $submitting.dialog('open');
    	}
    	
    });
	//var $cc_fpwdialog = $('<div></div>')
	//.html('<input type="text"></input><br/><input type="submit"></input>')
	var $cc_fpwdialog = $('#cc_fpwdiv')
	//.html('')
	.dialog({
		autoOpen: false,
		title: 'Forgot Password',
		width:500,
		height:135,
		resizable: false,
		close: function () {closeErrorPrompts();}
	});

    var $cc_fpwdialog_status = $('#cc_fpwmsgstatus')
	.dialog({
		autoOpen: false,
		title: 'Reset Password',
		width:400,
		height:120,
		resizable: false,
		close: function () {closeErrorPrompts();}
	});

	function displayForgotPWDialog(){
		$.validationEngine.closePrompt('#ccloginform_username');
		$.validationEngine.closePrompt('#ccloginform_password');
		$cc_fpwdialog.dialog('open');
		$("#cc_fpwform_email").focus();                
	}
	function closeErrorPrompts() {
		$.validationEngine.closePrompt('#cc_fpwform_email');
		$("#cc_fpwform_email").val('');		
		$("#cc_fpwerrmsg").html('');
            }
	
	$('#cc_openforgotpwdialog').click( function () { displayForgotPWDialog();});
	$("form#cc_fpwform").bind('submit',function() { xProcessForgotPW(); return false; });
    $('#cc_fpwmsgstatus_d02_ok').click( function () { $cc_fpwdialog_status.dialog('close');});
    // login script
    function xProcessForgotPW() {  
    	//   
    	//Validate the form, continue processing only if the validation is successful.           
    	if (!($("form#cc_fpwform").validationEngine({returnIsValid:true}))){
    		   
                return;
    	};
    	if(jQuery('#login_badge').val())
    		url = "fpw/format/json";
    	else
    		url = $('#login_host').val()+"/auth/fpw/format/json";

    	$.ajax({  
    	         type     : "POST",  
    	         url      : url,  
    	         data     : $("form#cc_fpwform").serialize(),
    	         datatype : "json",
    	         success: function(data){
                            $submitting.dialog('close');
    						switch(data.returnCode.returnCode){
    						case '100': $cc_fpwdialog.dialog('close');
                                        $("#cc_fpwerrmsg").html('An email sent to your ID with new password');
    									$("#cc_fpwerrmsg").css({color:"#75839E"});                                     
                                        
								break;
    						case '101': $("#cc_fpwerrmsg").html('System Error, please contact admin');
    									$("#cc_fpwerrmsg").css({color:"Red"});
								break;    									
    						case '102': $("#cc_fpwerrmsg").html('Invalid Email ID.   Please call customer support at (207) 453-2511');
    									$("#cc_fpwerrmsg").css({color:"Red"});    							    						
								break;
    						}
                            $cc_fpwdialog_status.dialog('open');
    					  }
                                         
    	});  
        return false;  
    };  
	
    // Lalith - 02-June-2010 - Start - script for license/privacy agreement settings.
    
    $("form#cc_agreement_form").bind('submit',function() { xProcessAgreement(); return false; });
    
    /****************************************************************************************
     * Method Name     :	xProcessAgreement												*
     * Created By      :	Lalith															*																		
     * Created Date    :	02-June-2010													*	
     * Description     :	Updates the license/privacy agreement flags in USER table.		*
     ****************************************************************************************/
    function xProcessAgreement() {   	
    	$.ajax({  
    	         type     : "POST",  
    	         url      : "/cairs/saveagreement/format/json",  
    	         data     : $("form#cc_agreement_form").serialize(),
    	         datatype : "json",
    	         success  : function(data){
    							window.location.href = data.returnCode.redirect;    						
    					    }
    	});  
        return false;  
    };  
    
    // Lalith - 02-June-2010 - End
//************************* END ******************************

   // Arun - 18-April-2011 - Start
//************************* END ******************************
var ua = $.browser;
if(ua.msie)
    logdilogwidth = 436;
else
    logdilogwidth = 418;
var $cc_loginauth = $('#auth_login_container')
	//.html('')
	.dialog({
		autoOpen: false,
		title: 'Login',
		width:logdilogwidth,
		Height:160,
		resizable: false,
        open: function () {$("#ccloginform_username").focus();},
		close: function () {closeErrorPrompts();$.validationEngine.closePrompt('.formError',true);}

	});

 $('#auth_login').click( function () { xProcessLoginForm();});

 function xProcessLoginForm()
 {
     $cc_loginauth.dialog('open');
 }
 /*
MSXML = [
 "Msxml2.DOMDocument.6.0",
 "Msxml2.DOMDocument.5.0",
 "Msxml2.DOMDocument.4.0",
 "Msxml2.DOMDocument.3.0",
 "MSXML2.DOMDocument",
 "Microsoft.XMLDOM"
];
function createDocument() {
    var doc;
    if (document.implementation && document.implementation.createDocument) {
        doc = document.implementation.createDocument("", "", null);
    } else if (window.ActiveXObject) {
        for (var i = 0; i < MSXML.length; i++) {
            try {
                doc = new ActiveXObject(MSXML[i]);
            } catch (e) { }
        }
        if (!doc) {
            //alert("Cannot create XMLDocument object");
            return false;
        }
    }
    return true;
}
 function checkPrereq()
 {
    var preqFlag = 1;
    if($('#browser_falg').val() == 1)
        preqFlag = 0;
    var xmlObj = createDocument();
    if(!(xmlObj))
        preqFlag = 0;
    flVer           = PluginDetect.getVersion('Flash');
    if(flVer)
        flashVersion    = flVer.split(',');
    if((!flVer) || (!(PluginDetect.isMinVersion('Flash', '0') >= 0) || flashVersion[0] < parseFloat($('#flash_support_version').val())))
    {
        preqFlag = 0;
    }
    jvVer           = PluginDetect.getVersion('Java');
    if(jvVer)
    {
        javaVersion     = jvVer.split(',');
        current_JVVer   = javaVersion[0]+'.'+javaVersion[1];
    }
    if((!jvVer) || (!(PluginDetect.isMinVersion('Java', '0') >= 0) || current_JVVer < parseFloat($('#java_support_version').val())))
    {
        preqFlag = 0;
    }
    return preqFlag;
 }

$("#prerequisite").click(function(){
		 $('#prerequisite_div').css('display','block');
	});
*/
 // Arun - 18-April-2011 - End
//************************* END ******************************
});
//-->




