
function showModalWin(url, w, h, scorrimento, status, resizable) {
	try{
		settings='dialogWidth:'+w+'px;dialogHeight:'+h+'px';
		o=new Object();
		o.opener=self;
		window.showModalDialog(url,o,settings);
	}catch(e){
		var win = null;
		var pagina, nome, LeftPosition, TopPosition, settings;
		nome='window';
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h-(screen.width*5/100))/2 : 0;
		settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+'yes'+', resizable=' +resizable+', status=' +'yes';
		win = window.open(url,nome,settings);
	}
}

function openWindow(nome, url, w, h, scorrimento, status, resizable) {
	var win = null;
	var pagina, nome, LeftPosition, TopPosition, settings;
	nome=nome;
	// scorrimento [yes | no]
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h-(screen.width*5/100))/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scorrimento+', resizable=' +resizable+', status=' +status;
	win = window.open(url,nome,settings);
}

function view_child(obj) {
	var result = "";
	for (var i in obj) {
		result += 'obj' + "." + i + " = " + obj[i] + "<br>";
	}
	
	var w=window.open()
	w.document.write(result);
	return result;
}

function refresh_obj(id){
/*
	AGGIORNA L' SRC DI UN OGGETTO
*/
	document.getElementById(id).src=document.getElementById(id).src+'?ssid='+Math.random();
}


function php_serialize(obj){
	
	// SERIALIZZA UN OGGETTO PER LA SPEDIZIONE VIA GET O POST O PER IL SALVATAGGIO COME STRINGA.
	
    var string = '';

    if (typeof(obj) == 'object') {
        if (obj instanceof Array) {
            string = 'a:';
            tmpstring = '';
            count = 0;
            for (var key in obj) {
                tmpstring += php_serialize(key);
                tmpstring += php_serialize(obj[key]);
                count++;
            }
            string += count + ':{';
            string += tmpstring;
            string += '}';
        } else if (obj instanceof Object) {
            classname = obj.toString();

            if (classname == '[object Object]') {
                classname = 'StdClass';
            }

            string = 'O:' + classname.length + ':"' + classname + '":';
            tmpstring = '';
            count = 0;
            for (var key in obj) {
                tmpstring += php_serialize(key);
                if (obj[key]) {
                    tmpstring += php_serialize(obj[key]);
                } else {
                    tmpstring += php_serialize('');
                }
                count++;
            }
            string += count + ':{' + tmpstring + '}';
        }
    } else {
        switch (typeof(obj)) {
            case 'number':
                if (obj - Math.floor(obj) != 0) {
                    string += 'd:' + obj + ';';
                } else {
                    string += 'i:' + obj + ';';
                }
                break;
            case 'string':
                string += 's:' + obj.length + ':"' + obj + '";';
                break;
            case 'boolean':
                if (obj) {
                    string += 'b:1;';
                } else {
                    string += 'b:0;';
                }
                break;
        }
    }

    return string;
}


function checkForm(){

	if (document.getElementById('id_recipient').value==0 || document.getElementById('id_recipient').value==''){
			document.getElementById('choose_recipient').className='select_errore';
			return false;
	}

	if (document.getElementById('subject').value==''){
			document.getElementById('subject').className='input_errore';
			return false;
	}

	if (document.getElementById('message').value==''){
			document.getElementById('message').className='textarea_errore';
			return false;
	}

	return true;
}


var wswindow_w=720;
var wswindow_h=690;


function WS_start(step){

        switch(step) {
            case 1:
				openWindow('shop', 'shop/shop.php', wswindow_w, wswindow_h, 'yes', 'yes', 'no')
                break;
				
            case 2:

                break;
				
            case 3:

                break;
        }

}


