﻿var currentlyShownBalloonGroupIndex = null;

var Balloons = new Array(13);
var CurrentBalloons = new Array(13);
var AssociatedControls = new Array(13);
var CheckBalloons = new Array(13);
var currentlyFocusedObj = null;
var currentlyBlurredObj = null;
var currentlyBlurredObjIndex = null;
var balloonBeforeCurrentlyBlurredObjBlurred = 0;


CurrentBalloons[0] = 0;
CurrentBalloons[1] = 0;
CurrentBalloons[2] = 0;
CurrentBalloons[3] = 0;
CurrentBalloons[4] = 0;
CurrentBalloons[5] = 0;
CurrentBalloons[6] = 0;
CurrentBalloons[7] = 0;
CurrentBalloons[8] = 0;
CurrentBalloons[9] = 0;
CurrentBalloons[10] = 0;
CurrentBalloons[11] = 0;
CurrentBalloons[12] = 0;

CheckBalloons[0] = 0;
CheckBalloons[1] = 0;
CheckBalloons[2] = 0;
CheckBalloons[3] = 0;
CheckBalloons[4] = 0;
CheckBalloons[5] = 0;
CheckBalloons[6] = 0;
CheckBalloons[7] = 0;
CheckBalloons[8] = 0;
CheckBalloons[9] = 0;
CheckBalloons[10] = 0;
CheckBalloons[11] = 0;
CheckBalloons[12] = 0;



//Balloons' 1st dimension order : 0:LoginID, 1:Forum ID, 2: Password, 3:PasswordConfirmation, 4:Email, 5:EmailConfirmation, 6:Name, 7:BirthDate, 8:Security Answer, 9:Gendar,10:Captcha,11:Name, 12:Country
//Balloons' 2nd dimension order : 0:guidance, 1:verified check, 2<=:errors.... (required order)

Balloons[0] = new Array("balloon_txtLoginId_Guidance", "balloon_txtLoginId_Verified", "balloon_txtLoginId_isNotAvailable","balloon_txtLoginId_isNotAvailableForbidden","balloon_txtLoginId_isNotAvailable", "balloon_txtLoginId_isAlreadyBeingUsed","balloon_txtLoginId_isNotAvailable","balloon_txtLoginId_isNotAvailableSame");
Balloons[1] = new Array("balloon_txtForumId_Guidance", "balloon_txtForumId_Verified", "balloon_txtForumId_isNotAvailable","balloon_txtForumId_isNotAvailableForbidden","balloon_txtForumId_isNotAvailable", "balloon_txtForumId_isAlreadyBeingUsed","balloon_txtForumId_isNotAvailable","balloon_txtForumId_isNotAvailableSame");
Balloons[2] = new Array("balloon_txtPassword_Guidance", "balloon_txtPassword_Verified", "balloon_txtPassword_PasswordDoesNotMeetCharacterLimit");
Balloons[3] = new Array("balloon_txtPasswordConfirmation_Guidance", "balloon_txtPasswordConfirmation_Verified", "balloon_txtPasswordConfirmation_InputFieldIsNotFilledOut", "balloon_txtPasswordConfirmation_PasswordsDoNotMatch");
Balloons[4] = new Array("balloon_txtEmail_Guidance", "balloon_txtEmail_Verified", "balloon_txtEmail_isNotAvailableLength","balloon_txtEmail_isNotAvailableDomain","balloon_txtEmail_InvalidEmailIsEntered", "balloon_txtEmail_EmailIsInUse");
Balloons[5] = new Array("balloon_txtEmailConfirmation_Guidance", "balloon_txtEmailConfirmation_Verified", "balloon_txtEmailConfirmation_InputFieldIsNotFilledOut", "balloon_txtEmailConfirmation_EmailsDonotMatch");
Balloons[6] = new Array(null, "balloon_txtLastName_Verified", "balloon_txtFirstName_NoFirstNameIsEntered", "balloon_txtLastName_InvalidCharactersOnlySpacesLettersAndHyphens");
Balloons[7] = new Array("balloon_ddlBirthYear_Guidance", "balloon_ddlBirthYear_Verified", "balloon_ddlBirthYear_isNotAvailableTooYoung", "balloon_ddlBirthYear_NotSelected");
Balloons[8] = new Array("balloon_txtSecurityQ2_A_Guidance", "balloon_txtSecurityQ2_A_Verified", "balloon_txtSecurityQ2_A_isNotAvailable");
Balloons[9] = new Array(null, "balloon_rbGender_Verified", "balloon_rbGender_GenderIsUnchecked");
Balloons[10] = new Array("balloon_txtChar_Guidance", null, "balloon_txtChar_TextIsNotFilledOut", "balloon_txtChar_TextDoesNotMatchImage");
Balloons[11] = new Array(null, "balloon_txtLastName_Verified", "balloon_txtLastName_NoLastNameIsEntered", "balloon_txtLastName_InvalidCharactersOnlySpacesLettersAndHyphens");
Balloons[12] = new Array("balloon_ddlCountry_Guidance", "balloon_ddlCountry_Verified","balloon_ddlCountry_NotSelected");

AssociatedControls[0] = new Array("txtLoginId", "txtLoginId", "txtLoginId", "txtLoginId", "txtLoginId", "txtLoginId", "txtLoginId","txtLoginId","txtLoginId");
AssociatedControls[1] = new Array("txtForumId", "txtForumId", "txtForumId", "txtForumId", "txtForumId", "txtForumId", "txtForumId","txtForumId","txtForumId");
AssociatedControls[2] = new Array("txtPassword", "txtPassword", "txtPassword");
AssociatedControls[3] = new Array("txtPasswordConfirmation", "txtPasswordConfirmation", "txtPasswordConfirmation", "txtPasswordConfirmation");
AssociatedControls[4] = new Array("txtEmail", "txtEmail", "txtEmail","txtEmail", "txtEmail", "txtEmail");
AssociatedControls[5] = new Array("txtEmailConfirmation", "txtEmailConfirmation", "txtEmailConfirmation", "txtEmailConfirmation");
AssociatedControls[6] = new Array("txtFirstName", "txtFirstName", "txtFirstName", "txtFirstName");
AssociatedControls[7] = new Array(null, null, null, null);
AssociatedControls[8] = new Array("txtSecurityQ2_A", "txtSecurityQ2_A", "txtSecurityQ2_A");
AssociatedControls[9] = new Array(null, null, null);
AssociatedControls[10] = new Array("txtChar", "txtChar", "txtChar", "txtChar");
AssociatedControls[11] = new Array("txtLastName", "txtLastName", "txtLastName", "txtLastName");
AssociatedControls[12] = new Array("ddlCountry", "ddlCountry","ddlCountry");

var debugWindow;
var birthMonthFocused = false;
var birthDayFocused = false;
var birthYearFocused = false;

function status()
{
	if(!debugWindow)
		debugWindow = window.open("about:blank", "debug", "menubar=0, resizable=1, width=400, height=600, scrollbars=1");

		debugWindow.document.close();

	for(var i = 0;i < CurrentBalloons.length;i++)
	{

		debugWindow.document.write(CurrentBalloons[i] + "<br />");
	}

	debugWindow.document.write("current balloon group index = " + currentlyShownBalloonGroupIndex);
}
function debug(text)
{
	if(!debugWindow)
		debugWindow = window.open("about:blank", "debug", "menubar=0, resizable=1, width=400, height=600, scrollbars=1");
	try
	{
	debugWindow.document.write(" <br /> <li>" + text + "</li>");
	}
	catch(e)
	{
		return;
	}
}

function doesErrorExist()
{
	for(var i = 0; i < CurrentBalloons.length; i++)
	{
		if(CurrentBalloons[i] > 1)
			return true;
	}
	return false;
}

function restoreFocus()
{
if(currentlyFocusedObj && currentlyFocusedObj.id)
	document.getElementById(currentlyFocusedObj.id).focus();

}

function showBalloon(groupIndex, balloonIndex, doScanBalloons)
{

//debug("showBalloon(" + groupIndex + ", " + balloonIndex + ");");

	if(!balloonIndex)
	{
		balloonIndex = CurrentBalloons[groupIndex];

	}

	if(doScanBalloons == undefined)
	{
		doScanBalloons = true;
	}


	if(balloonIndex > 1)
		showErrorBorder(AssociatedControls[groupIndex][balloonIndex]);
	else
		hideErrorBorder(AssociatedControls[groupIndex][balloonIndex]);

	CurrentBalloons[groupIndex] = balloonIndex;


	if(doScanBalloons)
		scanBalloons(groupIndex);
	else
		showBalloonById(Balloons[groupIndex][balloonIndex])

	if(CurrentBalloons[6] != 1 || CurrentBalloons[11] != 1)
		document.getElementById(Balloons[11][1]).style.display = "none";
}

function scanBalloons(targetGroupIndex)
{

	for(var i = CurrentBalloons.length - 1;i >= 0;i--)
	{

		hideGroup(i);							//hide all balloons first

		if(CurrentBalloons[i] == 1)					//show all verified img
			showBalloonById(Balloons[i][CurrentBalloons[i]]);
	}

		//if there's any error and the input balloon is guidance
	if(currentlyShownBalloonGroupIndex != null && CurrentBalloons[currentlyShownBalloonGroupIndex] > 1 && CurrentBalloons[targetGroupIndex] <= 1)			//if there's an error showing up currently
	{
//show the top balloon
showFirstError();
//		targetObjId = Balloons[currentlyShownBalloonGroupIndex][CurrentBalloons[currentlyShownBalloonGroupIndex]];	//show that balloon
	}
	else	//if there's no error
	{


		if((targetGroupIndex==6 || targetGroupIndex==11) && !(CurrentBalloons[6] == 1 && CurrentBalloons[11] == 1) && CurrentBalloons[targetGroupIndex] == 1)
			return; //name exception : first and last name must be verified at the same time. do not show verified img unless both are verified.

		targetObjId = Balloons[targetGroupIndex][CurrentBalloons[targetGroupIndex]];

		if(CurrentBalloons[targetGroupIndex] > 1)
			currentlyShownBalloonGroupIndex = targetGroupIndex;
		else
		{
			currentlyShownBalloonGroupIndex = null;		//if remove currentlyShownBallonGroupIndex if there's no error
		}

		
	}
	showBalloonById(targetObjId);
}


function showBalloonById(targetObjId)
{
	if(targetObjId)
	{
		document.getElementById(targetObjId).style.display = "inline";
	}
}


function hideGroup(targetGroupIndex)
{
	for(var i = 0;i < Balloons[targetGroupIndex].length;i++)
	{
		if(CurrentBalloons[targetGroupIndex] != null 
		&& CurrentBalloons[targetGroupIndex] != undefined 
		&& document.getElementById(Balloons[targetGroupIndex][i]) 
		)
		{
			document.getElementById(Balloons[targetGroupIndex][i]).style.display = "none";
		}
	}
}

function hideBalloon(targetGroupIndex)
{

	if(targetGroupIndex != null 
	&& CurrentBalloons[targetGroupIndex] != null 
	&& CurrentBalloons[targetGroupIndex] != undefined 
	&& document.getElementById(Balloons[targetGroupIndex][CurrentBalloons[targetGroupIndex]]) 
	)
	{
		document.getElementById(Balloons[targetGroupIndex][CurrentBalloons[targetGroupIndex]]).style.display = "none";
	}
	else
	{

	}

}

/* jasmine*/
function CheckValidate(targetGroupIndex, targetValue)
{ 
    switch(targetGroupIndex)
    {
        case 0 :
            NexonEU.Portal.Passport.NXEUWebService.CheckLoginID($get("txtLoginId").value, OnWSRequestComplete_L);   
            break;
        case 1 :
            return NexonEU.Portal.Passport.NXEUWebService.CheckForumID($get("txtForumId").value, OnWSRequestComplete_F);   
            break;
        case 4:
            NexonEU.Portal.Passport.NXEUWebService.CheckEmail($get("txtEmail").value, OnWSRequestComplete_E);   
            break;
        case 7 :
            var vBirth = $get("ddlBirthYear").value+"-"+$get("ddlBirthMonth").value+"-"+$get("ddlBirthDay").value; 
            NexonEU.Portal.Passport.NXEUWebService.CheckBirthday(vBirth, OnWSRequestComplete_B);   
            break;
        case 10 :  
            NexonEU.Portal.Passport.NXEUWebService.CaptchaCheck($get("txtChk").value, $get("txtChar").value, OnWSRequestComplete_C);    
            break;
        default :
            return true;
            
    }
     
}

function OnWSRequestComplete_C(results)
{  
     if (results != null)
     {
        switch(results)
        {
            case 0 :
                hideBalloon(10);
                break;
            default :
                showBalloon(10,results);
                break;
        }
         if ( results == "1")
         {            
           CheckBalloons[10] = 1; 
         }
     }
}

function OnWSRequestComplete_B(results)
{  
     if (results != null)
     {
        switch(results)
        {
            case 0 :
                hideBalloon(7);
                break;
            default :
                showBalloon(7,results);
                break;
        }
        if ( results == "1")
           CheckBalloons[7] = 1;     
     }
}

function OnWSRequestComplete_E(results)
{  
     if (results != null)
     {
        switch(results)
        {
            case 0 :
                hideBalloon(4);
                break;
            default :
                showBalloon(4,results);
                break;
        }
        
        if (results == "1")
            CheckBalloons[4]=1;
     }
}

function OnWSRequestComplete_L(results)
{ 
    //alert("loginid"); 
   // alert("loginid results :"+results);
     if (results != null)
     {
        switch(results)
        {
            case 0 :
                hideBalloon(0);
                break;
            default :
                showBalloon(0,results);
                break;
        } 
        if ( results == "1")
        {
           CheckBalloons[0] = 1;      
        }
     } 
}

function OnWSRequestComplete_F(results)
{  
     if (results != null)
     {
        switch(results)
        {
            case 0 :
                hideBalloon(1);
                break;
            default :
                showBalloon(1,results);
                break;
        }
        if ( results == "1")
            CheckBalloons[1] = 1;
              
     } 
}



function clientCheck(targetGroupIndex, targetControlIndex)
{
	var targetObj;

	if(AssociatedControls[targetGroupIndex][targetControlIndex] != null)
		targetObj = document.getElementById(AssociatedControls[targetGroupIndex][targetControlIndex]); 
		
	//CurrentBalloons[targetGroupIndex] = 0;
	switch(targetGroupIndex)
	{
		case 0:	//login id check;server side validation will occur as well 
			if(targetObj.value == "")
				showBalloon(targetGroupIndex, 2);
			else
			{
			    if ($get("txtLoginId").value == $get("txtForumId").value)
			        showBalloon(targetGroupIndex, 7);
			    else
			        CheckValidate(targetGroupIndex, $get("txtLoginId").value); 
			}
				
		break;
		case 1:	//forum id check;server side validation will occur as well 
			if(targetObj.value == "")
				showBalloon(targetGroupIndex, 2);
			else
			{
			    if ($get("txtLoginId").value == $get("txtForumId").value)
			        showBalloon(targetGroupIndex, 7);
			    else
			        CheckValidate(targetGroupIndex, $get("txtForumId").value); 
			}
				
		break;
		case 2: //password check
			if(targetObj.value.length < 6 || targetObj.value.length > 12)		//length of password must be between 6 and 12
				showBalloon(targetGroupIndex, 2);
			else
			{									//otherwise, good
				showBalloon(targetGroupIndex, 1);

				if(CurrentBalloons[3] != 0)	//if password confirmation field has set before,
					clientCheck(3,2);	//check password confirmation too
				else
				    CheckBalloons[2] = 1;

				return true;
			}
		break;
		case 3: //password confirmation check
			if(targetObj.value == "")
				showBalloon(targetGroupIndex, 2);
			else if(targetObj.value != $get("txtPassword").value)
				showBalloon(targetGroupIndex, 3);
			else
			{
				showBalloon(targetGroupIndex, 1);
				CheckBalloons[3] = 1;
				return true;
			}
		break;
		case 4:	//email check;server side validation will occur as well
			if(targetObj.value == "")
				showBalloon(targetGroupIndex, 2);
			{
			    CheckValidate(targetGroupIndex, $get("txtEmail").value); 
				if(CurrentBalloons[5] != 0)	//if email confirmation field has set before
					clientCheck(5, 2);	//check email confirmation too

				return true;
			}
		break;
		case 5: //email confirmation check
			if(targetObj.value == "")
				showBalloon(targetGroupIndex, 2);
			else if(targetObj.value != $get("txtEmail").value)
				showBalloon(targetGroupIndex, 3);
			else
			{
				showBalloon(targetGroupIndex, 1);
				CheckBalloons[5]=1;
				return true;
			}
		break;
		case 6:	//firstname check; server side validation will occur as well
			if(targetObj.value == "")
			{
				showBalloon(targetGroupIndex, 2);
			}
			else if(!(new RegExp("(^[a-zA-Z]*$)|(^[a-zA-Z][a-zA-Z- ]*[a-zA-Z]$)").test(targetObj.value)))	//alphabet,-, and blank (- and blank only in the middle of alphabets)
			{
				showBalloon(targetGroupIndex, 3);
			}
			else
			{
				showBalloon(targetGroupIndex, 1);
				CheckBalloons[6] = 1;
				return true;
			}

		break;
		case 7:	//birthdate check;server side validation will occur as well
			if(!(birthMonthFocused && birthDayFocused && birthYearFocused))
			{
				return false;
			}
 
			if(document.getElementById("ddlBirthMonth").selectedIndex == 0 || document.getElementById("ddlBirthDay").selectedIndex == 0 || document.getElementById("ddlBirthYear").selectedIndex == 0)
			{
				showBalloon(targetGroupIndex, 3);
				return false;
			}
			else
			{
			    var vBirth = $get("ddlBirthYear").value+"-"+$get("ddlBirthMonth").value+"-"+$get("ddlBirthDay").value; 
			    CheckValidate(targetGroupIndex, vBirth); 
			    
			} 
		break;
		case 8:	//security question
			if(targetObj.value == "")
			{
				showBalloon(targetGroupIndex, 2);
			}
			else if(!(OnlyEngNumCheck(targetObj.value)))
			{
				showBalloon(targetGroupIndex, 2);
			}
			else
			{
				showBalloon(targetGroupIndex, 1);
				CheckBalloons[8]=1;
				return true;
			}

		break;
		case 9:	//Gender check
			if(document.getElementById("rbGenderMale").checked || document.getElementById("rbGenderFemale").checked)
			{
				showBalloon(targetGroupIndex, 1);
				CheckBalloons[9]=1;
				return true;
			}
			else
			{
				showBalloon(targetGroupIndex, 2);
			}
		break;
		case 10:	//captcha check;server side validation will occur as well
			if(targetObj.value == "")
			{
				showBalloon(targetGroupIndex, 2);
			}
			else if(!(OnlyEngNumCheck(targetObj.value)))
			{
				showBalloon(targetGroupIndex, 2);
			}
			else
			{
				showBalloon(targetGroupIndex, 1);
				return true;
			}
		break;
		case 11: // lastname check 
		    if(targetObj.value == "")
			{
				showBalloon(targetGroupIndex, 2);
			}
			else if(!(new RegExp("(^[a-zA-Z]*$)|(^[a-zA-Z][a-zA-Z- ]*[a-zA-Z]$)").test(targetObj.value)))	//alphabet,-, and blank (- and blank only in the middle of alphabets)
			{
				showBalloon(targetGroupIndex, 3);
			}
			else
			{
				showBalloon(targetGroupIndex, 1);
				CheckBalloons[11] = 1;
				return true;
			} 
		break;
		case 12:	//country check 
			if(document.getElementById("ddlCountry").selectedIndex == 0)
			{ 
				showBalloon(targetGroupIndex, 2); 
				return false;
			}
			else
			{
			    if ( $get("ddlCountry").value != "-1" )
			    {  
			        showBalloon(targetGroupIndex, 1);   
			        CheckBalloons[12] = 1;
			    }
			    else
			    { 
			        showBalloon(targetGroupIndex, 2);		 
			    }
			}
		break;
		default:
			return true;
		
	}

	return false;
}

// 영어와 숫자만 입력 받는 지 확인
function OnlyEngNumCheck(str)
{  
	if (str.length > 0) { 
        for (i = 0; i < str.length; i++) { 
            if ((str.charAt(i) < '0' || str.charAt(i) > '9') &&
			   (str.charAt(i) < 'A' || str.charAt(i) > 'Z') &&
			   (str.charAt(i) < 'a' || str.charAt(i) > 'z'))
            {  
				return false;
            }
        }
        return true;
    }
}
// alphbet, num, -, blank
function StringCheck(str)
{  
	if (str.length > 0) { 
        for (i = 0; i < str.length; i++) { 
            if ((str.charAt(i) < '0' || str.charAt(i) > '9') &&
			   (str.charAt(i) < 'A' || str.charAt(i) > 'Z') &&
			   (str.charAt(i) < 'a' || str.charAt(i) > 'z') &&
			   (str.charAt(i) != ' ') && (str.charAt(i) != '-'))
            {  
				return false;
            }
        }
        return true;
    }
}

function doblur(obj, groupIndex)
{
	currentlyBlurredObj = obj;
	currentlyBlurredObjGroupIndex =  groupIndex;
	balloonBeforeCurrentlyBlurredObjBlurred = CurrentBalloons[groupIndex];
}
function validateAll()
{
	var returnValue = true;
	birthMonthFocused = true;
	birthDayFocused = true;
	birthYearFocused = true; 
	
	CheckBalloons[0] = 0;
	CheckBalloons[1] = 0;
	CheckBalloons[2] = 0;
	CheckBalloons[3] = 0;
	CheckBalloons[4] = 0;
	CheckBalloons[5] = 0;
	CheckBalloons[6] = 0;
	CheckBalloons[7] = 0;
	CheckBalloons[8] = 0;
	CheckBalloons[9] = 0;
	CheckBalloons[10] = 0;
	CheckBalloons[11] = 0;
	CheckBalloons[12] = 0;
//CheckBalloons' 1st dimension order
//0:LoginID, 1:Forum ID, 2: Password, 3:PasswordConfirmation, 4:Email, 5:EmailConfirmation, 6:Name, 7:BirthDate, 8:Security Answer, 9:Gendar,10:Captcha,11:Name, 12:Country	

    for(var i=0; i < CheckBalloons.length;i++)
    {
        switch(i)
	    {
		    case 0:	//login id check;server side validation will occur as well 
			    if($get("txtLoginId").value == "")
			    {
			        showBalloon(0, 2);
			        returnValue = false; break;
			    }			        
			    else
			    {
			        if ($get("txtLoginId").value == $get("txtForumId").value)
			        {
			            showBalloon(0, 2);
			            returnValue = false; break;
			        }
			        else
			        {
			            if (!OnlyEngNumCheck($get("txtLoginId").value))
			            {
			                showBalloon(0, 2);
			                returnValue = false; break;			                			                
			            }
			        }
			    }    				
		    break;
		    case 1:	//forum id check;server side validation will occur as well 
			    if($get("txtForumId").value == "")
			    {
				    showBalloon(1, 2);
				    returnValue = false; break;
				}
			    else
			    {
			        if ($get("txtLoginId").value == $get("txtForumId").value)
			        {
			            showBalloon(1, 7);
			            returnValue = false; break;
			        }
			        else
			        {
			            if (!OnlyEngNumCheck($get("txtForumId").value))
			            {
			                showBalloon(1, 2);
			                returnValue = false; break;			                			                
			            }			            
			        } 
			    }
    				
		    break;
		    case 2: //password check
			    if($get("txtPassword").value.length < 6 || $get("txtPassword").value.length > 12)		//length of password must be between 6 and 12
			    {
				    showBalloon(2, 2);
				    returnValue = false; break;
				}
			    else
			    {									//otherwise, good
				    if ($get("txtPassword").value != $get("txtPasswordConfirmation").value)
				    {
				        showBalloon(2, 3);
				        returnValue = false; break;
				    }
			    }
		    break;
		     case 3: //password check
			    if($get("txtPasswordConfirmation").value.length < 6 || $get("txtPasswordConfirmation").value.length > 12)		//length of password must be between 6 and 12
			    {
				    showBalloon(3, 2);
				    returnValue = false; break;
				}
			    else
			    {									//otherwise, good
				    if ($get("txtPassword").value != $get("txtPasswordConfirmation").value)
				    {
				        showBalloon(3, 3);
				        returnValue = false; break;
				    }
			    }
		    break;
		    case 4:	//email check;server side validation will occur as well
			    if($get("txtEmail").value == "")
			    {
				    showBalloon(4, 2);
				    returnValue = false; break;
				}
				else
			    {
			        if ($get("txtEmail").value != $get("txtEmailConfirmation").value)
				    {
				        showBalloon(5, 3);
				        returnValue = false; break;
				    }
			    }
		    break; 
		    case 5:	//email check;server side validation will occur as well
			    if($get("txtEmailConfirmation").value == "")
			    {
				    showBalloon(5, 2);
				    returnValue = false; break;
				}
				else
			    {
			        if ($get("txtEmail").value != $get("txtEmailConfirmation").value)
				    {
				        showBalloon(5, 3);
				        returnValue = false; break;
				    }
			    }
		    break; 
		    case 6:	//firstname check; server side validation will occur as well 
			    if($get("txtFirstName").value == "" || $get("txtLastName").value == "")
			    {
				    showBalloon(6, 2);
				    returnValue = false; break;
			    }
			    else
			    {
			        if ( !(StringCheck($get("txtFirstName").value) && StringCheck($get("txtLastName").value)))
			        {
			            showBalloon(6, 3);
				        returnValue = false; break;
			        }
			    } 
		    break;
		    case 7:	//birthdate check;server side validation will occur as well 
			    if(document.getElementById("ddlBirthMonth").selectedIndex == 0 || document.getElementById("ddlBirthDay").selectedIndex == 0 || document.getElementById("ddlBirthYear").selectedIndex == 0)
			    {
				    showBalloon(7, 3);
				    returnValue = false; break;
			    } 
		    break;
		    case 8:	//security question
			    if($get("txtSecurityQ2_A").value == "")
			    {
				    showBalloon(8, 2);
				    returnValue = false; break;
			    }
			    else if(!(OnlyEngNumCheck($get("txtSecurityQ2_A").value)))
			    {
				    showBalloon(8, 2);
				    returnValue = false; break;
			    } 
		    break;
		    case 9:	//Gender check
			    if(!(document.getElementById("rbGenderMale").checked || document.getElementById("rbGenderFemale").checked))
			    {
				    showBalloon(9, 2);
				    returnValue = false; break; 
			    } 
		    break;
		    case 10:	//captcha check;server side validation will occur as well
			    if($get("txtChar").value == "")
			    {
				    showBalloon(10, 2);
				    returnValue = false; break; 
			    }
			    else if(!(OnlyEngNumCheck($get("txtChar").value)))
			    {
				    showBalloon(10, 2);
				    returnValue = false; break; 
			    } 
		    break; 
		    case 12:	//country check 
			    if(document.getElementById("ddlCountry").selectedIndex == 0)
			    { 
				    showBalloon(12, 2); 
				    returnValue = false; break; 
			    }
			    else
			    {
			        if ( $get("ddlCountry").value == "-1" )
			        {  
			            showBalloon(12, 1);   
			            returnValue = false; break; 
			        } 
			    }
		    break;     		
	    }        
    }
    
	 
//    for(var i = 0;i < CheckBalloons.length;i++)
//    { 
//	    if (i < 2 || i == 4|| i == 7 || i == 10 )
//	        CheckValidate(i,"");
//	    else
//	        clientCheck(i, 2);   
//	        
//	    if ( i != 10 )
//	        if (eval(CheckBalloons[i]) < 1 || eval(CheckBalloons[i]) > 1 ) {showBalloon(i);returnValue = false; break;} 
//    }   
	return returnValue;
}
function showFirstError()
{
	for(var i = 0;i < CurrentBalloons.length;i++)
	{
	    //alert("CB["+i+"] : "+CurrentBalloons[i]);
		if(CurrentBalloons[i] > 1)
		{
			showBalloon(i);
			//CurrentBalloons[i] = 0; 
			return false;
		}
	}
}

 

function showErrorBorder(targetObjId)
{
	var targetObj = document.getElementById(targetObjId);

	if(!targetObj)
		return;

	targetObj.style.borderStyle = "solid"; 
	targetObj.style.borderWidth = "1px";
	targetObj.style.borderColor = "#CC0000";




}

function hideErrorBorder(targetObjId)
{
	var targetObj = document.getElementById(targetObjId);

	if(!targetObj)
		return;

	targetObj.style.borderStyle = "solid"; 
	targetObj.style.borderWidth = "1px";
	targetObj.style.borderColor = "#c3cddc";


}

 

function resetRegistration()
{
	window.location.replace(window.location);
}



if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();   