$(document).ready(function () {
	
	$('a[href^="http://"]').attr('target', '_blanck');
	$('thead.top_menu a').bind('click', function(event){ event.preventDefault(); toggleVis(this)});
	
	$('input[type="text"]').each(function() {  placeholder(this);  });
	
	$('#queryform').each(function(){ queryFormSubmit(this); });
	$('#login_form').each(function(){ validateLoginFrom(this); });
	$('#partnerForm').each(function() { partnerFormSubmit(this); } );
	
});

function toggleVis(elem){
	
	     var toogleClass = $('.'+elem.className);
	     
	     for (i=0; i<toogleClass.length; i++){
	    		 
	    	  var id = toogleClass[i].href.split('?');
	    	  
	    	  if (toogleClass[i] == elem){
	    		  
	    		  document.getElementById(id[1]).className = 'view';
	    		  elem.parentNode.className = 'active';
	    	  
	    	  }else{
	    		  
	    		  document.getElementById(id[1]).className = 'hidden';
	    		  toogleClass[i].parentNode.className = 'not_active';
	    	  }
	    		 
	     }
}

function showLicense(){
	
	    StickyWin();
	    $('#StickyWin_td').html('<img src="images/license.jpg" />');
	    return false;
}

function StickyWin(){
	
	    $('body').prepend($('<table/>', {id: 'StickyWin',
	    	                             css: {width: '100%',
	    	                                   height: '100%',
	    	                                   backgroundImage: 'url("../images/back_50_opacity.png")',
	    	                                   position: 'fixed',
	    	                                   textAlign: 'center',
	    	                                   verticalAlign: 'middle',
	    	                                   zIndex: '999999999'},
	    	                             click: function(){ $(this).remove(); },
	    	                             html: $('<tr/>',
	    	                             		  {html: $('<td/>', {id: 'StickyWin_td',
	    	                            			                 html: $('<div/>', {id: 'video'})
	    	                            			                 })
	    	                            	      })
	    	                           }
	     
	     ));	
}

function placeholder (elem){

	    var def_elem = $('label.placeholder[for="'+elem.id+'"]');
        var def_text = def_elem.text().replace(/:\s$/, '');
	
	    if (!elem.value.length && def_text){
	    	
	    	 def_elem.css('display', 'none');
	    	
	    	 $(elem).focus(function() {
	    		 
	    		 if (elem.value == def_text){
	    			
	    		     elem.style.color = '#242424';
	    		     elem.value = '';
	    		 }
	    	 });
	    	 $(elem).blur(function() { placeholder(elem); } );
	    	 
	    	 elem.style.color = '#bbb';
	    	 elem.value = def_text;
	    	 
	    }
}
