$(document).ready(function(){

    // drop down menu

    $('#menu li').hover(function() {
        $('a.sub:first', this).addClass("hover");
        $('ul:first', this).show();
    
        }, function() {
                $('a.sub', this).removeClass("hover");
                $('ul', this).hide();
            });

}); 

function assosiativeCount(stack) {
	
	var counter = 0;
	
	for (key in stack) {
		
		if (!stack.hasOwnProperty(key)) {
			continue ;
		}
		
		counter++;
	}
	
	return counter;
}

function trim(str) {
	return str.replace(/^\s+|\s+$/g, '');
}

function Clone() { }

function clone(obj) {
    Clone.prototype = obj;
    return new Clone();
}

function formAutoPopulate() {

	$('input[type="text"]').each(function() {
	
		var name = $(this).attr('name').toLowerCase();	
		var value = name.indexOf('email') > -1 ? 'test@sample.com' : name.toString() + ' sample text' ;
		
		$(this).val(value);
	})
	
	$('textarea').each(function() {
	
		var html = $(this).attr('name').toString() + ' sample long-long text';
		$(this).html(html);
	})
	
	$('select').each(function() {
	
		var Owner = $(this);
		
		$('option:selected', Owner).removeAttr('selected');
		$('option:first', Owner).attr('selected', 'selected');
	})
	
	$('input[type="checkbox"]').attr('checked', 'checked');
}	
