function do_link(module,page,params){
         DaLink=path_index+"?_init="+module+"."+page+"&"+params;

         return DaLink;
}

function do_command_img(module,params,have_path){

         var img_handle = new Image();
         var seed = Math.random();
         var cmds_path = 0;
         
         if(have_path){
            cmds_path = have_path + params +'&rndseed=' + seed;
         }
         else{
            cmds_path = path_index + '?_init=' + module + '.cmds' + params +'&rndseed=' + seed;
         }

         img_handle.width=0;

         //document.location = cmds_path;
         img_handle.src = cmds_path;
}

function add_comment(PARAM,mode,width,height){
	if(!width){
		width = 600;
	}
	if(!height){
		height = 560;
	}
         window.open(path_index+'?_init=global.add_comment&pp=up' + PARAM,'Comment','width=' + width + ',height=' + height + ',top=100,left=100,copyhistory=no,scrollbars=yes');
}

function add_report(PARAM,mode,width,height){
	
	if(!width){
		width = 400;
	}
	if(!height){
		height = 400;
	}

         if(confirm('Are you sure you wish to report this as a site violation?')){
            if(mode=='remote'){
                  do_command_img('',PARAM,path_index + '?_init=global.add_report&pp=up&mode=' + mode +'&');
                  alert('Your report was posted successfully.');
            }
            else{
                  window.open(path_index+'?_init=global.add_report&pp=up&mode=' + mode +'&' + PARAM,'Report','width=' + width + ',height=' + height + ',top=100,left=100,copyhistory=no,scrollbars=yes');
            }
         }
}

function set_contact_rel(logins_key,width,height){
	if(logins_key){
		poplink = do_link('global','contact_rels','pp=up&set=1&logins_key='+logins_key);
		window.open(poplink,"SetContact","width=500,height=390,copyhistory=no,scrollbars=yes");
	}
}

function add_pics(picpage){
        if(pic_nr = prompt('How many pictures do you wish to add (max 20) ?','1')){
                if(pic_nr > 0 && pic_nr <= 20){
                        document.location= picpage + escape(pic_nr);
                }
                else{
                        alert("Please provide a number between 1 and 20");
                }
        }
}

function close_win(msg){
	if(msg){
		window.opener.alert(msg);
	}
	window.self.close();
}