/* 
Derived from a script by Alejandro Gervasio. 
Modified to work in FireFox by Stefan Mischook for Killersites.com

How it works: just apply the CSS class of 'column' to your pages' main columns.
*/
matchColumns=function(){ 

     var divs,contDivs,maxHeight,divHeight,d; 
	
     // get all <div> elements in the document 

     divs=document.getElementsByTagName('div'); 

     contDivs=[]; 

     // initialize maximum height value 

     maxHeight=0; 

     // iterate over all <div> elements in the document 

     for(var i=0;i<divs.length;i++){ 

          // make collection with <div> elements with class attribute 'container' 

          if(/\bcolumn\b/.test(divs[i].className)){ 

                d=divs[i]; 

                contDivs[contDivs.length]=d; 

                // determine height for <div> element 

                if(d.offsetHeight){ 

                     divHeight=d.offsetHeight; 					

                } 

                else if(d.style.pixelHeight){ 

                     divHeight=d.style.pixelHeight;					 

                } 

                // calculate maximum height 

                maxHeight=Math.max(maxHeight,divHeight); 

          } 

     } 

     // assign maximum height value to all of container <div> elements 

     for(var i=0;i<contDivs.length;i++){ 

          contDivs[i].style.height=maxHeight + "px"; 

     } 

} 

// Runs the script when page loads 
window.onload=function(){ 

    if(document.getElementsByTagName){ 

        matchColumns();			 

    } 

} 

function poll(baseurl){
    var pollid = $('#pollid').val();
    var choice = $("input[@name='poll']:checked").val();

    $.ajax({
        type: "post",
        url:baseurl+"/poll/poll_result.php",
        data: "pollID="+pollid+"&Choice="+choice+"&ITLPollCheckCookie",
        cache:false,
        success: function(data){
            //$("#pollresult").clear();
            $("#pollresult").html(data);
        }
    });
    
}

function alwaysCheck(){
    $('#newsletters').attr('checked');
}

// Begin - Registration scripts

function showParticipants(){
    var participants = $('#participants').val();
    if(participants==1){
        $('#p1fnln').hide();
        $('#participants_option').hide();
    } else {
        $('#p1fnln').show();
        $('#participants_option').show();
    }
    var event = $('#event').attr('checked');
    for(var i=2; i<=10; i++){
        $('#participants'+i).hide();
        if(event==true){
            $('#eventDiv'+i).hide();
        } else {
            $('#eventDiv'+i).show();
        }
    }
    for(var i=2; i<=participants; i++){
        $('#participants'+i).show();
    }
}

function participants_option(option){
    var participants = $('#participants').val();
    for(var i=2; i<=participants; i++){
        if(option==0)
            $('#eventDiv'+i).show();
        else
            $('#eventDiv'+i).hide();
    }
}

function hideShowPaydetails(option){
    if(option){
        $('#paydetails').show();
        $('.regPaymentbtn').hide();
    } else {
        $('#paydetails').hide();
        $('.regPaymentbtn').show();
    }
    
}


function hideShowHoteldetails(option){
    if(option){
        $('#hotelAccomodationDiv').show();
    } else {
        $('#hotelAccomodationDiv').hide();
    }
    
}

function formvalidationStep11(){
    var participants = $('#participants').val();
   // alert(document.regForm.event1.length);
}

    function checkArray(form, arrayName){
        var retval = new Array();
        for(var i=0; i < form.elements.length; i++) {
            var el = form.elements[i];
            if(el.type == "checkbox" && el.name == arrayName && el.checked) {
                retval.push(el.value);
            }
        }
        return retval;
    }

    function formvalidationStep1(form){
        var participants = $('#participants').val();
        var strRE = /^[\s ]*$/gi;

        if(participants==1){
            var itemsChecked = checkArray(form, "event1[]");
            if(itemsChecked.length==0){
                alert('Atleast select one event for particpant 1');
                return false;
            }
        } else {
            var event = $('input[name=event]:checked').val() 
            var itemsChecked = checkArray(form, "event1[]");
            if(itemsChecked.length<1){
                alert('Atleast select one event for particpant 1');
                return false;
            }

            var fname = 1;
            var lname = 1;
            var firstname = $('#cname'+fname).val();
            var lastname = $('#clastname'+lname).val();
            if(strRE.test(firstname)){
                alert('Enter the first name for participant 1');
                $('#cname'+fname).focus();
                return false;
            } else if(strRE.test(lastname)){
                alert('Enter the last name for participant 1');
                $('#clastname'+fname).focus();
                return false;
            }

            if(event=='No'){
                for(i=2;i<=participants;i++){
                    var itemsChecked = checkArray(form, "event"+i+"[]");
                    if(itemsChecked.length<1){
                        alert('Atleast select one event for particpant '+i);
                        return false;
                    }
                    var firstname = $('#cname'+i).val();
                    var lastname = $('#clastname'+i).val();
                    if(strRE.test(firstname)){
                        alert('Enter the first name for participant '+i);
                        $('#cname'+i).focus();
                        return false;
                    } else if(strRE.test(lastname)){
                        alert('Enter the last name for participant'+i);
                        $('#clastname'+i).focus();
                        return false;
                    }
                }
            } else {

                for(i=2;i<=participants;i++){
                    var firstname = $('#cname'+i).val();
                    var lastname = $('#clastname'+i).val();
                    if(strRE.test(firstname)){
                        alert('Enter the first name for participant '+i);
                        $('#cname'+i).focus();
                        return false;
                    } else if(strRE.test(lastname)){
                        alert('Enter the last name for participant'+i);
                        $('#clastname'+i).focus();
                        return false;
                    }
                }

            }
            
        }

        this.form.submit();
    }

    function formvalidationStep2(form){

        var totalparticipants = $('#totalparticipants').val();
        var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,5}$/;
        var strRE = /^[\s ]*$/gi;
        
        for(var i=1; i<=totalparticipants; i++){
            var firstname = $('#cname'+i).val();
            var lastname = $('#clastname'+i).val();
            var company = $('#ccompany'+i).val();
            var title = $('#ctitle'+i).val();
            var email = $('#cemail'+i).val();
            if(i==1){
                var confirmemail = $('#cemail2'+i).val();
            }
            var phone = $('#cphone'+i).val();
            if(strRE.test(firstname)){
                alert('Enter the first name for participant '+i);
                $('#cname'+i).focus();
                return false;
            } else if(strRE.test(lastname)){
                alert('Enter the last name for participant '+i);
                $('#clastname'+i).focus();
                return false;
            } else if(strRE.test(company)){
                alert('Enter the company for participant '+i);
                $('#ccompany'+i).focus();
                return false;
            } else if(strRE.test(title)){
                alert('Enter the title for participant '+i);
                $('#ctitle'+i).focus();
                return false;
            } else if(!email.match(emailExp)){
                alert('Enter the email for participant '+i);
                $('#cemail'+i).focus();
                return false;
            } else if(i==1 && !confirmemail.match(emailExp)){
                alert('Enter the confirm email for participant '+i);
                $('#cemail2'+i).focus();
                return false;
            } else if(i==1 && confirmemail!=email){
                alert('Email and confirm email should be same for participant '+i);
                $('#cemail2'+i).focus();
                return false;
            } else if(strRE.test(phone)){
                alert('Enter the phone for participant '+i);
                $('#cphone'+i).focus();
                return false;
            }

        }
        this.form.submit();
    }

    function formvalidationStep3(form){
        
        var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,5}$/;
        var strRE = /^[\s ]*$/gi;
        
        var firstname = $('#cname').val();
        var lastname = $('#clastname').val();
        var email = $('#cemail').val();
        var company = $('#ccompany').val();
        var street = $('#cstreet').val();
        var zip = $('#czip').val();
        var city = $('#ccity').val();
        var comments = $('#comments').val();
        if(strRE.test(firstname)){
            alert('Enter the first name');
            $('#cname').focus();
            return false;
        } else if(strRE.test(lastname)){
            alert('Enter the last name');
            $('#clastname').focus();
            return false;
        } else if(!email.match(emailExp)){
            alert('Enter the email');
            $('#cemail').focus();
            return false;
        } else if(strRE.test(company)){
            alert('Enter the company');
            $('#ccompany').focus();
            return false;
        } else if(strRE.test(street)){
            alert('Enter the street address');
            $('#cstreet').focus();
            return false;
        } else if(strRE.test(zip)){
            alert('Enter the zip code');
            $('#czip').focus();
            return false;
        } else if(strRE.test(city)){
            alert('Enter the city');
            $('#ccity').focus();
            return false;
        } else if(strRE.test(comments)){
            alert('Enter the comments');
            $('#comments').focus();
            return false;
        }

        this.form.submit();
        
    }

    // End - Registration scripts

////////Rounded Corners Starts

$(document).ready(function() {

$("img.rounded").load( function () {
	var img = $(this);
	
	// build wrapper
	var wrapper = $('<div class="rounded_wrapper"></div>');
	wrapper.width(img.width());
	wrapper.height(img.height());
	
	// move CSS properties from img to wrapper
	wrapper.css('float', img.css('float'));
	img.css('float', 'none')
	
	wrapper.css('margin-right', img.css('margin-right'));
	img.css('margin-right', '0')

	wrapper.css('margin-left', img.css('margin-left'));
	img.css('margin-left', '0')

	wrapper.css('margin-bottom', img.css('margin-bottom'));
	img.css('margin-bottom', '0')

	wrapper.css('margin-top', img.css('margin-top'));
	img.css('margin-top', '0')

	wrapper.css('display', 'block');
	img.css('display', 'block')

	// wrap image
	img.wrap(wrapper);
	
	// add rounded corners
	img.after('<div class="tl"></div>');
	img.after('<div class="tr"></div>');
	img.after('<div class="bl"></div>');
	img.after('<div class="br"></div>');
});

	
});

////////Rounded Corner Ends