/*
$(document).ready(function(){
	$('img[src$=.png], .rightside .news h1, .rightside .gallups h1, .rightside .leftBlock .login,#topMenu').ifixpng(); 
});
*/
var Common = {
	ChangeLang: function(obj){
		obj.form.submit();

	},
	NavigateToFrame: function(url,id) {
		$('#theContent').html('<iframe src="'+url+'"  frameborder="no" width="555px" name="topFrame" height="300px" id="'+id+'" scrolling="no"></iframe>');
		window.frames["topFrame"].location.href=url;
	},	
	ShowForm: function(formDoc){
			if(formDoc) {	
				
				if ( $("#overForm").length == 0) {
					$('body').append('<iframe id="overlay" name="overLay" bgcolor="#000000"  frameborder="0" style="display: none;" ></iframe>');		
					$('body').append('<iframe id="overForm" name="overForm" style="display: none;" frameborder="0" ></iframe>');
				}

				$('#overlay').height($(document).height()).show();
				var leftpos = ($(window).width()/2)-($('#overForm').width()/2);
				var commentPos = $('#addComment').position();
				var toppos = ((commentPos.top - $('#overForm').height()));
				$('#overForm').css('left', leftpos).css('top',toppos).show();
						
				$(window.frames['overForm'].document).ready(function() {
					setTimeout( function() {
					var doc = window.frames["overLay"].document;
						var $overbody = $('body',doc);
						$overbody.html('<style> body {background: #000000;} </style>');
						var doc = window.frames["overForm"].document;
						var $formbody = $('body',doc);
						$formbody.html(formDoc);
						$formbody.css('background','#3c3c3c');
					}, 500 );
				}); 

			} else {
				return false;
			}
	},
	SubmitComment: function (formdata) {

		jQuery.ajax({
		  type: "post",
		  data: this.SerializeForm(formdata), 
		  url: 'index.php?id='+formdata.id.value+'&detail='+formdata.detail.value
		});

		var breakTag = '<br />';
		var comment = formdata.comment.value;
		var name = formdata.name.value;

		if($('#addComment').css('text-align') == 'left') {
			$('#addComment').css('text-align','right');
		}

		comment =  (comment + '').replace(/([^>]?)\n/g, '$1'+ breakTag +'\n');
		$('#commentTable').prepend('<tr><td><font color="#fda000">'+formdata.name.value+'</font><br />'+comment+'</td></tr>');	
		this.HideForm();
	},
	ShowComments: function (id,movieId) {
			$.ajax({
			   type: "get",
			   url: 'index.php',
			   data: 'id='+id+'&detail='+movieId+'&showcomments='+movieId,
			   success: function(msg){
					$('#readAll').html('');
					$('#commentTable').html(msg);
			   }
			 });
	},
	HideForm: function() {
				$('#overlay, #overForm').hide();
	},
	SerializeForm: function(data) {	
		var toReturn    = [];
        var els         = $(data).find(':input').get();
        $.each(els, function() {
			if (this.name && !this.disabled && (this.checked || /select|textarea/i.test(this.nodeName) || /text|hidden|password/i.test(this.type))) {
					var val = $(this).val();
					toReturn.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( val ) );

            }
        });   
        return toReturn.join("&").replace(/%20/g, "+");
	}
}	

