function $vmt() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}
VMTSubmitForm = {
    frame : function(c) {
        var n = 'cible_' + Math.floor(Math.random() * 99999);
        var d = document.createElement('DIV');
        d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="VMTSubmitForm.loaded(\''+n+'\')"></iframe>';
        document.body.appendChild(d);
        var i = document.getElementById(n);
        if (c && typeof(c.onComplete) == 'function') {
			i.onComplete = c.onComplete;
			i.idform = c.idform;
		}
        return n;
    },
    form : function(f, name) {
        f.setAttribute('target', name);
    },
    submit : function(f, c) {
        VMTSubmitForm.form(f, VMTSubmitForm.frame(c));
        if (c && typeof(c.onStart) == 'function') return c.onStart(c.idform);
        else return true;
    },
    loaded : function(id) {
        var i = document.getElementById(id);		
        if (i.contentDocument) var d = i.contentDocument;
        else if (i.contentWindow) var d = i.contentWindow.document;
        else var d = window.frames[id].document;
        if (d.location.href == "about:blank") return;
        if (typeof(i.onComplete) == 'function') i.onComplete(d.body.innerHTML,i.idform);
		var idframe = $(i).attr('id');
		setTimeout('$("#' + idframe + '").parent().remove();',200);
    }
}
function vmtPressSubmitForm(object,idform)
{
	return VMTSubmitForm.submit(object, {'onStart' : vmtStartSubmitForm, 'onComplete' : vmtCompleteSubmitForm, 'idform' : idform});
}
function vmtStartSubmitForm(idform) 
{	
	vmtOpenProcessModal();
	return true;
}
function vmtOpenProcessModal()
{
	$.modal('<div style="border: 3px solid #FF0000; position:absolute; text-align:center; padding:10px; width: 274px; background-color: #FFFFFF;"><img src="' + VMT_URL + 'images/ajax_loader_01.gif" /><div style="margin-top:10px; color:#FF0000;"><b>' + _LB_PROCESSING + '...</b></div></div>');	
}
function vmtCompleteSubmitForm(response,idform) 
{
	//alert (response);
	$.modal.close();
	eval('var data = ' + response);
	for(var x in data) {
		switch(x) {
			case 'tagid' :
				for(var y in data[x]) {
					$('#' + y).html(data[x][y]);
				}
				break;
			case 'script' :
				for(var y in data[x]) {
					eval(data[x][y]);
				}				
				break;
			case 'message' :
				alert(data[x]);
				//vmtDlgMessage(data[x]);
				break;
			case 'location' :
				var link = data[x].replace(/&amp;/g,"&");
				window.location.href = link;
				break;
			case 'open_link' :
				for(var y in data[x]) {
					var link = data[x][y].replace(/&amp;/g,"&");					
					window.open(link);
				}				
				break;
		}
	}
}

function vmtValidate(obj,idform)
{
	$('.warning_check').remove();
	var check = true;
	for(var i=0; i<$('#' + idform + ' .vmtCheckNoEmpty').length; i++) {
	    var xx = $('#' + idform + ' .vmtCheckNoEmpty')[i];
	    if(xx.value=="") {
	        $(xx).parent().append('<div class="warning_check">' + _LB_NO_EMPTY + '</div>');
	        check = false;
	    }
	}
	for(var i=0; i<$('#' + idform + ' .vmtCheckEmail').length; i++) {
	    var xx = $('#' + idform + ' .vmtCheckEmail')[i];
	    var filter = /.+@.+\..+/;
	    if (!filter.test(xx.value)) {
	        $(xx).parent().append('<div class="warning_check">' + _LB_EMAIL_NOT_CORRECT + '</div>');
	        check = false;
	    }
	}
	for(var i=0; i<$('#' + idform + ' .vmtCheckPhone').length; i++) {
	    var xx = $('#' + idform + ' .vmtCheckPhone')[i];
	    var filter = /^[\(]?[\+]?[\d\s]{1,}[\)]?[\d\s\-]{3,}$/;
	    if (xx.value != "" && !filter.test(xx.value)) {	
	        $(xx).parent().append('<div class="warning_check">' + _LB_PHONE_NOT_CORRECT + '</div>');
	        check = false;
	    }
	}
	
	if(!check) return false;
	return vmtPressSubmitForm(obj,idform);
}

function vmtConfirm(label,link,object) {
	object.addClass('rowDelete');
	var answer = confirm(label);
	if (answer) {
		window.location = link;
		return true;
	}
	object.removeClass('rowDelete');
	return false;
}

function vmtDlgMessage(msg)
{
	var str = '';
	$.modal('<div style="border: 3px solid #FF0000; position:absolute; text-align:center; padding:10px; width: 274px; background-color: #FFFFFF;"><div style="margin-top:10px; margin-bottom:10px; color:#333333;"><b>' + msg + '</b></div><button style="width:100px" class="simplemodal-close">OK</button></div>');
}


function go_linkweb(obj){
	for(var i=1;i<obj.options.length;i++)
		if(obj.options[i].selected) window.open(obj.options[i].value);
	return false;
}

(function($) { 
	var ELMS = []; 
	$.fn.jdNewsScroll = function(settings) { 
		settings = $.extend({}, arguments.callee.defaults, settings); 
		$(this).each(function() { 
			this.$settings = settings; 
			this.$pause = false; 
			this.$counter = (Math.floor(Math.random() * 10) * 10); 
			$(this).hover(function() { 
				$(this).jdNewsScrollPause(true) 
				}, function() { 
					$(this).jdNewsScrollPause(false) }); 
			$('> ul', this).bind('mouseover', function(e) { 
				if ($(e.target).is('li')) { 
					$(e.target).addClass('hover') } }).bind('mouseout', function(e) { 
						if ($(e.target).is('li')) { 
							$(e.target).removeClass('hover') } }); 
			ELMS.push(this) }); return this }; 
			$.fn.jdNewsScroll.defaults = { delay: 0, step: 2 }; 
			$.fn.jdNewsScrollPause = function(pause) { 
				return this.each(function() { this.$pause = pause }) }; 
				setInterval(scroll, 85); function scroll() { 
					for (var i = 0; i < ELMS.length; i++) { 
						var elm = ELMS[i]; if (elm && !elm.$pause) { 
							if (elm.$counter == 0) { var ul = $('> ul', elm)[0]; 
							if (!elm.$steps) { elm.$steps = $('> li:last-child', ul).outerHeight(); 
							elm.$step = 0 } if ((elm.$steps + elm.$step) <= 0) { 
								elm.$counter = elm.$settings.delay; elm.$steps = false; 
								$(ul).css('top', '0').find('> li:last-child').after($('> li:first-child', ul)); 
								$('> *', ul).not('li').remove() } else { 
									elm.$step -= elm.$settings.step; if (-elm.$step > elm.$steps) { 
										elm.$step = -elm.$steps } ul.style.top = elm.$step + 'px' } } 
							else { elm.$counter-- } } } } })(jQuery);


