/**
 * PixmaCMS
 *
 * LICENSE
 *
 * This source file is subject to the GPL license that is bundled
 * with this package in the file LICENSE.txt.
 *
 * @package		PixmaCMS
 * @copyright	Copyright © 2009, PixmaSoft OÜ (http://www.pixmasoft.ee)
 * @license		http://www.gnu.org/licenses/gpl.txt     GPL  
 */

/**
 * A class that consist main PixmaCMS javascript functions. Through this class,
 * other javascript scripts get system config, translations and useful functions.
 *  
 * @class		PixmaCMS
 * @author		Raido Orumets <raido@pixmasoft.ee>
 * @created		2009-06-15
 * @modified	2009-08-23
 * @version		0.2 2009-06-15
 */

PixmaCMS = {
	
	init: function(){
				
		if(PixmaCMS.config.disable_copying){
			PixmaCMS.disableCopying();
		}
				
		$("input").defaultValue();
		$("input").keypress(function (event){ return (event.keyCode == 13)?$(this).parents("form:first").submit():true; });
		$("#search form img").click(function(){ $(this).parents("form:first").submit(); });
		$('#right').height($('#content_container').height());
		//$('.product_detail_image').height($('.product_detail').height());
		
		//$(document).pngFix({ blankgif:'img/blank.gif' });
		
		//$('.top_line a').click(function(){ $('html, body').animate({scrollTop:0}, 'slow'); });
		
		// $('input[type=radio].rating_star').rating({
		/*$('input.rating_star').rating({
			required: true,
			callback: function(value, link){
		
			},
			focus: function(value, link){
				var tip = $('.rating_title', this.form);
				tip[0].data = tip[0].data || tip.html();
				tip.html(link.title || 'value: '+value);
			},
			blur: function(value, link){
				var tip = $('.rating_title', this.form);
				$('.rating_title').html(tip[0].data || '');
			}
		});*/
	},
	
	redirect: function(url){
		window.location.href = url;
	},
	
	nospam: function(user, domain) {
		window.location = "mailto:" + user + "@" + domain;
	},
	
	smilie: function(smilietext, form, name) {
		eval('document.' + form + '.' + name + '.value += "' + smilietext + ' ";');
	},
	
	array_repair: function(_array){
		var array = new Array();
		for (var i in _array){
			array[array.length] = _array[i];
		}
		
		return array;
	},
	
	disableCopying: function(){
		$(document).bind("contextmenu", function(e){return false;});
		$(document).disableTextSelect();
	},
	
	enableCopying: function(){
		$(document).unbind("contextmenu");
		$(document).enableTextSelect();
	}
}

PixmaCMS.config = {
	
	url: "/",
	language: "ee",
	country: "ee",
	disable_copying: false
}

PixmaCMS.text = {
	
	//TODO
}

$(function() {
	PixmaCMS.init();
});
