function explode( delimiter, string ) {    // Split a string by string
    //
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: kenneth
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)

    var emptyArray = { 0: '' };

    if ( arguments.length != 2
        || typeof arguments[0] == 'undefined'
        || typeof arguments[1] == 'undefined' )
    {
        return null;
    }

    if ( delimiter === ''
        || delimiter === false
        || delimiter === null )
    {
        return false;
    }

    if ( typeof delimiter == 'function'
        || typeof delimiter == 'object'
        || typeof string == 'function'
        || typeof string == 'object' )
    {
        return emptyArray;
    }

    if ( delimiter === true ) {
        delimiter = '1';
    }

    return string.toString().split ( delimiter.toString() );
}

function wpShow(div){
	$.blockUI({ message: null, baseZ: 100, focusInput: true});

	$(div).css("left", ($('body').width() - $(div).width()) / 2);
	$(div).css("top", (document.documentElement.scrollTop + 20) + 'px');

	$(div).show();
}

function wpHide(div){
	$.unblockUI();
	$(div).hide();
}

function run_script(_div) {

	var divContent = _div.childNodes;
	for (var i = 0; i < divContent.length; i++) {
		requestItem = divContent.item(i);
		if (requestItem.tagName)
		{
			alert(requestItem.text);
			if (requestItem.tagName.toUpperCase() == 'SCRIPT') eval(requestItem.text);
		}
		else run_script(requestItem);
	}
}

function load_item(ctrl, div, fn) {
 	var height = $(div).height();
	var margin = Math.ceil(height/2);


	$(div).html('<div style="margin: '+margin+'px 0px; text-align: center;"><img src="/img/loader1.gif"></div>');
	$.post( ctrl, {type: 'ajax-request'},
	function(data){
		$(div).html(data);
		eval($(div + ' > script', data.responseXML).html());
		eval($('#swf_cnt > script', data.responseXML).html());
		if (fn) {
			fn();
		}
	});
}

function isShow(div){
	if ($(div).css('display') != 'none') return 1;
}

function goodOpen(id){
	if	(! $('#item-'+id).attr('class'))
		if (! isShow('#item-'+id+' .wrp-goods-full')) {
			if (jQuery.browser.msie) {
				$('#item-'+id+' .wrp-goods-full').show();
				$('#item-'+id+' .wrp-goods table').addClass('open');
			} else {
				$('#item-'+id+' .wrp-goods-full').fadeIn('slow');
				$('#item-'+id+' .wrp-goods table').addClass('open');
			}
		} else {
	 			$('#item-'+id+' .wrp-goods-full').hide();
	 			$('#item-'+id+' .wrp-goods table').removeClass('open');
 		}
}

function continueLogin() {
	$('.wrp-login .form').show();
	$('.wrp-login .hint').hide();
	$('#wpLogin').css("left", ($('body').width() - $('#wpLogin').width()) / 2);
}

function tiny(selector) {
	$(selector).each(function() {
		$(this).tinymce({
			language : "en",
			mode : "exact",
			element_format : "html",
			theme : "advanced",
			theme_advanced_buttons1 : "fullscreen,code,|,bold,italic,|,justifyleft,justifycenter,justifyright,|,styleselect,formatselect,|,pasteword,|,bullist,numlist,|,link,unlink,|,images",
			theme_advanced_buttons2 : "",
			theme_advanced_buttons3 : "",
			plugins : "style,advlink,paste,fullscreen,images",

			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "top",
			theme_adsvanced_resizing : false,
			verify_css_classes : true,
			relative_urls : false,
		  remove_script_host : true,
			content_css : "/css/editor.css",
			width : '78%',
			height: 400
		});
	});
}
