﻿// JScript File

function onclickrad(flag, ID, DelNo) {
    var SelFees = document.getElementById("selfee" + DelNo.toString());
    if (flag=="Y")
        SelFees.value = (SelFees.value == "" ? ID.value : SelFees.value + ',' + ID.value);
    else {
        SelFees.value = SelFees.value.replace(ID.value, '');
        SelFees.value = (SelFees.value == "," ? "" : SelFees.value);
    }
    SelFees.value = SelFees.value.replace(',,', ',');    
}
function CheckBoxClicked(ID,DelNo) {
    var getTb = document.getElementById(ID.name + "tbl");
    var SelFees = document.getElementById("selfee" + DelNo.toString());
    if (getTb != null) {
        if (ID.checked == false) {
            getTb.style.position = "absolute";
            getTb.style.visibility = "hidden";
        }
        else {
            getTb.style.position = "relative";
            getTb.style.visibility = "visible";
        }
    }
    if (ID.checked)
        SelFees.value = (SelFees.value == "" ? ID.name : SelFees.value + ',' + ID.name);
    else {
        SelFees.value = SelFees.value.replace(ID.name, '');
        SelFees.value = (SelFees.value == "," ? "" : SelFees.value);
    }
    SelFees.value = SelFees.value.replace(',,', ',');
    for (i = 0; i <= 10; i++) {
        var GetRadID = document.getElementsByName(ID.name + i.toString());
        if (GetRadID != null) {
            if (GetRadID[0]) {
                for (var j = 0; j < GetRadID.length; j++) {
                    GetRadID[j].disabled = (ID.checked == false);
                    GetRadID[j].checked = (ID.checked == false ? false : GetRadID.checked)
                }
            }
        }
    }
}
function ValidateActivity(ID) {
    
    for (var o = 1; o <= 5; o++) {
        var GetRadID1 = document.getElementById('chklist' + o.toString());
        if (GetRadID1 != null) {
            var Arr = GetRadID1.value.split(",");
            if (Arr[0]) {
                var FeeSelected = false;
                
                for (var j = 0; j < Arr.length; j++) {
                    //Start
                    var ChkBox1 = document.getElementById(Arr[j])
                    if (ChkBox1.checked == true) {
                        FeeSelected = true;
                        for (m = 0; m <= 10; m++) {
                            var GetRadID = document.getElementsByName(Arr[j] + m.toString());
                            if (GetRadID != null) {
                                if (GetRadID[0]) {
                                    var RadCheck = false;
                                    for (var k = 0; k < GetRadID.length; k++) {
                                        RadCheck = (GetRadID[k].checked ? true : false);
                                        if (RadCheck == true) break;
                                    }
                                    if (RadCheck == false) {
                                        alert("Please Select No for optional activities which u dont want to attend !");
                                        return false;

                                    }
                                }
                            }
                        }
                    }
                    //End

                }
                if (FeeSelected == false) {
                    alert("You have to select atleast one activity per delegate !");
                    return false;
                }
            }
        }
        else 
            return true;
    }
}
function TellaFriend(Code)
{
    if(Code!='')
    {
        window.open("tellafriend.aspx?ev=" + Code+ "&",'_tella','height=220,width=550,menubar=no,location=no,toolbar=no,statusbar=no');
    }
}
function trim(str)
{
    return str.replace(/^\s+|\s+$/, '');
}
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
function DoTellSubmit()
{
    
    var fname = document.getElementById('fName');
    var femail = document.getElementById('fEmail');
    var yName = document.getElementById('yName');
    var yEmail = document.getElementById('yEmail');
    
    if(fname!=null && femail!= null && yName != null && yEmail !=null)
    {
    
        if(trim(fname.value) =="" || trim(yName.value) =="" || trim(femail.value) =="" || trim(yEmail.value) =="")
            alert("All Fields are mandatory !!");
         else
         {
            
            if(echeck(yEmail.value)== false)
                {
                    yEmail.focus();
                    return;
                }
            if(echeck(femail.value)== false)
                {
                    femail.focus();
                    return;
                }
            
            document.forms[0].submit();
         }
            
    }
}
function ResizeImg(IDImg)
{
    if(IDImg!=null)
    {
        if(IDImg.width>160)
        {
            IDImg.width=160;
        }
        if(IDImg.height>60)
        {
            IDImg.height=60;
        }
    }
    else
        Alert("Null");
}
function detectBrowser()
{
    var browser=navigator.appName;
    var b_version=navigator.appVersion;
    var version=parseFloat(b_version);
    if (browser=="Netscape")
        return "NN";
    if(browser=="Microsoft Internet Explorer") 
        return "IE";
}
    
    function MouseOver(Sel)
    {
    var ID=Sel;
    if(ID!=null)
    {
        //ID.style.color = 'White';
        ID.style.borderBottom='inset 2px Orange';
    }
    else
        alert("Nul");
    }

    function MouseOut(Sel)
    {
    var ID=Sel;
    if(ID!=null)
    {
        //ID.style.color = 'black';
        ID.style.borderBottom='inset 0px Orange';
    }
    else
        alert("Null");
    }
    function hideSub()
    {
        if(ActiveSub!=null)
        {
            ActiveSub.style.visibility="hidden";
            ActiveSub=null;
        }
    }
    
    function hidethis(ID)
    {
        if(ID!=null)
            ID.style.visibility="hidden";
    }
    var GlobSch=null;
    function SetupPosSch(tmpID)
    {
        
        
        var ID=null;
        var ID2=null;
        
        if(GlobSch==null)
            ID=document.getElementById('tb1');
        else
            ID=GlobSch;

            
        
        var StrH = ID.id.substr(2,1);
        var StrS = tmpID.id.substr(2,1);
        ID2 =document.getElementById('tb'+StrS);
        var daycap=document.getElementById('daycap');
        daycap.setAttribute("innerText",tmpID.title);
        
        var TDShow  = document.getElementById("td"+StrS);
        var TDHide  = document.getElementById("td"+StrH);
        
        if(ID2==GlobSch || ID==ID2)
            return;
        
        if(ID!=null && ID2!=null)
        {
            GlobSch=ID2;
            var Obj=findPos(ID);
            
           
            ID2.style.left=Obj[0];
            ID2.style.top=Obj[1];
            ID2.style.width = ID.offsetWidth;
            if(detectBrowser()!="IE")
            {
                ID.style.position="absolute";
                //ID2.style.position="relative";
            }
            ID2.style.visibility="visible";
            ID.style.visibility="hidden";
            document.getElementById("tmpTd").setAttribute("height",ID2.offsetHeight);
            TDHide.style.backgroundColor="gray";
            TDHide.style.color="black";
            TDHide.style.borderTop="outset 0px";
            TDShow.style.color="white";
            TDShow.style.borderTop="outset 3px Orange";
            TDShow.style.backgroundColor="#9F0206";
            
            
        }
        else
            alert("Null");
            
    }
    function SetupPos(tbShow,tbHide)
    {
    
        var ID=document.getElementById(tbHide);
        
        var ID2=document.getElementById(tbShow);
        
        var TDShow  = document.getElementById("td"+tbShow);
        var TDHide  = document.getElementById("td"+tbHide);
        
        if(ID!=null && ID2!=null)
        {
        
            var Obj=findPos(ID);
            
            ID2.style.left=Obj[0];
            ID2.style.top=Obj[1];
            ID2.style.width = ID.offsetWidth;
            
            if(detectBrowser()!="IE")
            {
                ID.style.position="absolute";
               // ID2.style.position="relative";
            }
            
            ID2.style.visibility="visible";
            ID.style.visibility="hidden";
            
            document.getElementById("tmpTd").setAttribute("height",ID2.offsetHeight + 10 +"px");
            document.getElementById("tmpTd").style.height=ID2.offsetHeight + 10 +"px";
            
            TDShow.style.backgroundColor="#9F0206";
            TDShow.style.borderTop="outset 3px Orange";
            TDShow.style.color="Black";
            TDShow.style.borderTop="outset 3px Orange";
            
            TDHide.style.backgroundColor="gray";
            TDHide.style.color="White";
            TDHide.style.borderTop="outset 0px";
            
            
        }
        else
            alert("Null");
    }
    var ActiveSub=null;
    function ShowSubMenu(TD,DIV)
    {
        var ID=document.getElementById(DIV);
        if(ID!=null && TD!=null)
        {
            ActiveSub=ID;
            var Obj=findPos(TD);
            ID.style.visibility="visible";
            ID.style.left=Obj[0] - (ID.offsetWidth- TD.offsetWidth) +"px";
            ID.style.top=Obj[1]+30 +"px";
        }
        else
            alert("Null");
    }
    
    function findPos(obj) 
    {
        var curleft = curtop = 0;
        if (obj.offsetParent) 
        {
            do
             {
			    curleft += obj.offsetLeft;
			    curtop += obj.offsetTop;
             } 
			while (obj = obj.offsetParent);
        }			
        
    return [curleft,curtop];
    }
    
function RoundCorner(ObjectId,Corner,AdoptColor)
{
    var ParentDiv=document.getElementById(ObjectId);
    for(i=1; i<=6; i++)
    {
        var t, l, w, h;
        switch (i)
        {
            case 1 :
                t=0; l=0; w=1; h=9;
                if (Corner=="LB" || Corner=="RB") {t=(ParentDiv.style.pixelHeight-9);}
                if (Corner=="RT" || Corner=="RB") {l=(ParentDiv.style.pixelWidth-1);} 
                break;
            case 2 :
                t=0; l=1; w=1; h=6;
                if (Corner=="LB" || Corner=="RB") {t=(ParentDiv.style.pixelHeight-6);}
                if (Corner=="RT" || Corner=="RB") {l=(ParentDiv.style.pixelWidth-2);} 
                break;
            case 3 :
                t=0; l=2; w=1; h=4;
                if (Corner=="LB" || Corner=="RB") {t=(ParentDiv.style.pixelHeight-4);}                        
                if (Corner=="RT" || Corner=="RB") {l=(ParentDiv.style.pixelWidth-3);} 
                break;
            case 4 :
                t=0; l=3; w=1; h=3;
                if (Corner=="LB" || Corner=="RB") {t=(ParentDiv.style.pixelHeight-3);}
                if (Corner=="RT" || Corner=="RB") {l=(ParentDiv.style.pixelWidth-4);} 
                break;
            case 5 :
                t=0; l=4; w=2; h=2;
                if (Corner=="LB" || Corner=="RB") {t=(ParentDiv.style.pixelHeight-2);}                        
                if (Corner=="RT" || Corner=="RB") {l=(ParentDiv.style.pixelWidth-6);} 
                break;
            case 6 :
                t=-1; l=4; w=5; h=1;
                if (Corner=="LB" || Corner=="RB") {t=(ParentDiv.style.pixelHeight-1);}                        
                if (Corner=="RT" || Corner=="RB") {l=(ParentDiv.style.pixelWidth-9);} 
                break;
        }
        var NewDiv=document.createElement("div"); 
        NewDiv.setAttribute("id",Corner+i);
        NewDiv.style.position="absolute"; NewDiv.style.fontSize="1px";
        if (AdoptColor=="Y")
        {
            NewDiv.style.backgroundColor=document.getElementById(ObjectId).parentElement.style.backgroundColor;
        }
        else
        {
            NewDiv.style.backgroundColor=document.body.style.backgroundColor;
        }
        NewDiv.style.top=t+"px"; NewDiv.style.left=l+"px"; NewDiv.style.width=w+"px"; NewDiv.style.height=h+"px";
        ParentDiv.appendChild(NewDiv);
        NewDiv="";
    }
    }